Revision 71c0f14a cmake/Modules/GrSwig.cmake
| b/cmake/Modules/GrSwig.cmake | ||
|---|---|---|
| 17 | 17 |
# the Free Software Foundation, Inc., 51 Franklin Street, |
| 18 | 18 |
# Boston, MA 02110-1301, USA. |
| 19 | 19 |
|
| 20 |
IF(DEFINED __INCLUDED_GR_SWIG_CMAKE)
|
|
| 21 |
RETURN()
|
|
| 22 |
ENDIF()
|
|
| 23 |
SET(__INCLUDED_GR_SWIG_CMAKE TRUE)
|
|
| 20 |
if(DEFINED __INCLUDED_GR_SWIG_CMAKE)
|
|
| 21 |
return()
|
|
| 22 |
endif()
|
|
| 23 |
set(__INCLUDED_GR_SWIG_CMAKE TRUE)
|
|
| 24 | 24 |
|
| 25 |
INCLUDE(GrPython)
|
|
| 25 |
include(GrPython)
|
|
| 26 | 26 |
|
| 27 | 27 |
######################################################################## |
| 28 | 28 |
# Build a swig target for the common gnuradio use case. Usage: |
| ... | ... | |
| 35 | 35 |
# - GR_SWIG_SOURCE_DEPS |
| 36 | 36 |
# - GR_SWIG_TARGET_DEPS |
| 37 | 37 |
######################################################################## |
| 38 |
MACRO(GR_SWIG_MAKE name)
|
|
| 39 |
SET(ifiles ${ARGN})
|
|
| 38 |
macro(GR_SWIG_MAKE name)
|
|
| 39 |
set(ifiles ${ARGN})
|
|
| 40 | 40 |
|
| 41 | 41 |
#determine include dependencies for swig file |
| 42 |
EXECUTE_PROCESS(
|
|
| 42 |
execute_process(
|
|
| 43 | 43 |
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/get_swig_deps.py
|
| 44 | 44 |
"${ifiles}" "${GR_SWIG_INCLUDE_DIRS}"
|
| 45 | 45 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
| ... | ... | |
| 48 | 48 |
) |
| 49 | 49 |
|
| 50 | 50 |
#append the specified include directories |
| 51 |
INCLUDE_DIRECTORIES(${GR_SWIG_INCLUDE_DIRS})
|
|
| 52 |
LIST(APPEND SWIG_MODULE_${name}_EXTRA_DEPS ${GR_SWIG_SOURCE_DEPS})
|
|
| 51 |
include_directories(${GR_SWIG_INCLUDE_DIRS})
|
|
| 52 |
list(APPEND SWIG_MODULE_${name}_EXTRA_DEPS ${GR_SWIG_SOURCE_DEPS})
|
|
| 53 | 53 |
|
| 54 |
FIND_PACKAGE(PythonLibs)
|
|
| 55 |
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
|
|
| 54 |
find_package(PythonLibs)
|
|
| 55 |
include_directories(${PYTHON_INCLUDE_DIRS})
|
|
| 56 | 56 |
|
| 57 | 57 |
#setup the swig flags with flags and include directories |
| 58 |
SET(CMAKE_SWIG_FLAGS -fvirtual -modern -keyword -w511 -module ${name} ${GR_SWIG_FLAGS})
|
|
| 59 |
FOREACH(dir ${GR_SWIG_INCLUDE_DIRS})
|
|
| 60 |
LIST(APPEND CMAKE_SWIG_FLAGS "-I${dir}")
|
|
| 61 |
ENDFOREACH(dir)
|
|
| 58 |
set(CMAKE_SWIG_FLAGS -fvirtual -modern -keyword -w511 -module ${name} ${GR_SWIG_FLAGS})
|
|
| 59 |
foreach(dir ${GR_SWIG_INCLUDE_DIRS})
|
|
| 60 |
list(APPEND CMAKE_SWIG_FLAGS "-I${dir}")
|
|
| 61 |
endforeach(dir)
|
|
| 62 | 62 |
|
| 63 | 63 |
#set the C++ property on the swig .i file so it builds |
| 64 |
SET_SOURCE_FILES_PROPERTIES(${ifiles} PROPERTIES CPLUSPLUS ON)
|
|
| 64 |
set_source_files_properties(${ifiles} PROPERTIES CPLUSPLUS ON)
|
|
| 65 | 65 |
|
| 66 | 66 |
#setup the actual swig library target to be built |
| 67 |
INCLUDE(UseSWIG)
|
|
| 67 |
include(UseSWIG)
|
|
| 68 | 68 |
SWIG_ADD_MODULE(${name} python ${ifiles})
|
| 69 | 69 |
SWIG_LINK_LIBRARIES(${name} ${PYTHON_LIBRARIES} ${GR_SWIG_LIBRARIES})
|
| 70 |
IF(GR_SWIG_TARGET_DEPS)
|
|
| 71 |
ADD_DEPENDENCIES(${SWIG_MODULE_${name}_REAL_NAME} ${GR_SWIG_TARGET_DEPS})
|
|
| 72 |
ENDIF(GR_SWIG_TARGET_DEPS)
|
|
| 70 |
if(GR_SWIG_TARGET_DEPS)
|
|
| 71 |
add_dependencies(${SWIG_MODULE_${name}_REAL_NAME} ${GR_SWIG_TARGET_DEPS})
|
|
| 72 |
endif(GR_SWIG_TARGET_DEPS)
|
|
| 73 | 73 |
|
| 74 |
ENDMACRO(GR_SWIG_MAKE)
|
|
| 74 |
endmacro(GR_SWIG_MAKE)
|
|
| 75 | 75 |
|
| 76 | 76 |
######################################################################## |
| 77 | 77 |
# Install swig targets generated by GR_SWIG_MAKE. Usage: |
| ... | ... | |
| 81 | 81 |
# [COMPONENT component] |
| 82 | 82 |
# ) |
| 83 | 83 |
######################################################################## |
| 84 |
MACRO(GR_SWIG_INSTALL)
|
|
| 84 |
macro(GR_SWIG_INSTALL)
|
|
| 85 | 85 |
|
| 86 |
INCLUDE(CMakeParseArgumentsCopy)
|
|
| 86 |
include(CMakeParseArgumentsCopy)
|
|
| 87 | 87 |
CMAKE_PARSE_ARGUMENTS(GR_SWIG_INSTALL "" "DESTINATION;COMPONENT" "TARGETS" ${ARGN})
|
| 88 | 88 |
|
| 89 |
FOREACH(name ${GR_SWIG_INSTALL_TARGETS})
|
|
| 90 |
INSTALL(TARGETS ${SWIG_MODULE_${name}_REAL_NAME}
|
|
| 89 |
foreach(name ${GR_SWIG_INSTALL_TARGETS})
|
|
| 90 |
install(TARGETS ${SWIG_MODULE_${name}_REAL_NAME}
|
|
| 91 | 91 |
DESTINATION ${GR_SWIG_INSTALL_DESTINATION}
|
| 92 | 92 |
COMPONENT ${GR_SWIG_INSTALL_COMPONENT}
|
| 93 | 93 |
) |
| 94 | 94 |
|
| 95 |
INCLUDE(GrPython)
|
|
| 95 |
include(GrPython)
|
|
| 96 | 96 |
GR_PYTHON_INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.py
|
| 97 | 97 |
DESTINATION ${GR_SWIG_INSTALL_DESTINATION}
|
| 98 | 98 |
COMPONENT ${GR_SWIG_INSTALL_COMPONENT}
|
| 99 | 99 |
) |
| 100 |
ENDFOREACH(name)
|
|
| 100 |
endforeach(name)
|
|
| 101 | 101 |
|
| 102 |
ENDMACRO(GR_SWIG_INSTALL)
|
|
| 102 |
endmacro(GR_SWIG_INSTALL)
|
|
| 103 | 103 |
|
| 104 | 104 |
######################################################################## |
| 105 | 105 |
# Generate a python file that can determine swig dependencies. |
| ... | ... | |
| 107 | 107 |
# When you build C++, CMake figures out the header dependencies. |
| 108 | 108 |
# This code essentially performs that logic for swig includes. |
| 109 | 109 |
######################################################################## |
| 110 |
FILE(WRITE ${CMAKE_BINARY_DIR}/get_swig_deps.py "
|
|
| 110 |
file(WRITE ${CMAKE_BINARY_DIR}/get_swig_deps.py "
|
|
| 111 | 111 |
|
| 112 | 112 |
import os, sys, re |
| 113 | 113 |
|
Also available in: Unified diff