summaryrefslogtreecommitdiff
path: root/cmake/Modules
diff options
context:
space:
mode:
authorJosh Blum2011-11-05 13:16:27 -0700
committerJosh Blum2011-11-05 13:16:27 -0700
commit2a0d169a5cc3856f77091cb755770b0e42d9fbd9 (patch)
tree38b552a4bd8a8031ef03f756036b609ffa95832e /cmake/Modules
parent0b3a4a2c43e9fd4e3cc03c694b408034954c9d74 (diff)
downloadgnuradio-2a0d169a5cc3856f77091cb755770b0e42d9fbd9.tar.gz
gnuradio-2a0d169a5cc3856f77091cb755770b0e42d9fbd9.tar.bz2
gnuradio-2a0d169a5cc3856f77091cb755770b0e42d9fbd9.zip
cmake: make the swig cxx file gen depend on the specified targets
made a handy helper macro in grmisc to make this simpler
Diffstat (limited to 'cmake/Modules')
-rw-r--r--cmake/Modules/GrMiscUtils.cmake19
-rw-r--r--cmake/Modules/GrSwig.cmake8
2 files changed, 24 insertions, 3 deletions
diff --git a/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake
index f96dbee74..de2683d9c 100644
--- a/cmake/Modules/GrMiscUtils.cmake
+++ b/cmake/Modules/GrMiscUtils.cmake
@@ -176,3 +176,22 @@ function(GR_LIBRARY_FOO target)
endif(LIBRARY_EXTRAS)
endfunction(GR_LIBRARY_FOO)
+
+########################################################################
+# Create a dummy custom command that depends on other targets.
+# Usage:
+# GR_GEN_TARGET_DEPS(unique_name target_deps <target1> <target2> ...)
+# ADD_CUSTOM_COMMAND(<the usual args> ${target_deps})
+#
+# Custom command cant depend on targets, but can depend on executables,
+# and executables can depend on targets. So this is the process:
+########################################################################
+function(GR_GEN_TARGET_DEPS name var)
+ set(_dummy_target _${name}_dummy_target)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_dummy_target}.cpp "int main(void){return 0;}\n")
+ add_executable(${_dummy_target} ${CMAKE_CURRENT_BINARY_DIR}/${_dummy_target}.cpp)
+ if(ARGN)
+ add_dependencies(${_dummy_target} ${ARGN})
+ endif(ARGN)
+ set(${var} "DEPENDS;${_dummy_target};COMMAND;${_dummy_target}" PARENT_SCOPE)
+endfunction(GR_GEN_TARGET_DEPS)
diff --git a/cmake/Modules/GrSwig.cmake b/cmake/Modules/GrSwig.cmake
index f8f339f1b..1dfd62af2 100644
--- a/cmake/Modules/GrSwig.cmake
+++ b/cmake/Modules/GrSwig.cmake
@@ -47,17 +47,19 @@ macro(GR_SWIG_MAKE name)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
- #create a dummy target that depend on other targets
+ #Create a dummy custom command that depends on other targets
+ include(GrMiscUtils)
+ GR_GEN_TARGET_DEPS(${name} tag_deps ${GR_SWIG_TARGET_DEPS})
set(tag_file ${CMAKE_CURRENT_BINARY_DIR}/${name}.tag)
add_custom_command(
OUTPUT ${tag_file}
- DEPENDS ${GR_SWIG_TARGET_DEPS}
+ DEPENDS ${GR_SWIG_SOURCE_DEPS} ${tag_deps}
COMMAND ${CMAKE_COMMAND} -E touch ${tag_file}
)
#append the specified include directories
include_directories(${GR_SWIG_INCLUDE_DIRS})
- list(APPEND SWIG_MODULE_${name}_EXTRA_DEPS ${GR_SWIG_SOURCE_DEPS} ${tag_file})
+ list(APPEND SWIG_MODULE_${name}_EXTRA_DEPS ${tag_file})
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_DIRS})