aboutsummaryrefslogtreecommitdiffstats
path: root/functions.cmake
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2020-06-20 15:53:39 +0200
committerTor Egge <Tor.Egge@broadpark.no>2020-06-23 13:23:15 +0200
commit9fd21ebae6282e4015f3e33461ef62f62c38371d (patch)
treef1ad0a80a0c6e06868fd0550208d691abad4a1c5 /functions.cmake
parent749b7f7637c8b5c80dfe813d04c5301054b311c4 (diff)
Add source target per module for generated sources.
Diffstat (limited to 'functions.cmake')
-rw-r--r--functions.cmake18
1 files changed, 18 insertions, 0 deletions
diff --git a/functions.cmake b/functions.cmake
index 43dd2d30853..162cb6852b0 100644
--- a/functions.cmake
+++ b/functions.cmake
@@ -101,6 +101,18 @@ function(vespa_add_target_system_dependency TARGET PACKAGE_NAME)
endif()
endfunction()
+function(vespa_add_source_target TARGET)
+ cmake_parse_arguments(
+ ARG
+ ""
+ ""
+ "DEPENDS"
+ ${ARGN}
+ )
+ add_custom_target(${TARGET} DEPENDS ${ARG_DEPENDS})
+ __add_source_target_to_module(${TARGET})
+endfunction()
+
function(vespa_generate_config TARGET RELATIVE_CONFIG_DEF_PATH)
# Generate config-<name>.cpp and config-<name>.h from <name>.def
# Destination directory is always where generate_config is called (or, in the case of out-of-source builds, in the build-tree parallel)
@@ -134,6 +146,7 @@ function(vespa_generate_config TARGET RELATIVE_CONFIG_DEF_PATH)
OUTPUT ${CONFIG_H_PATH} ${CONFIG_CPP_PATH}
COMMAND java -Dconfig.spec=${CONFIG_DEF_PATH} -Dconfig.dest=${CONFIG_DEST_PARENT_DIR} -Dconfig.lang=cpp -Dconfig.subdir=${CONFIG_DEST_DIRNAME} -Dconfig.dumpTree=false -Xms64m -Xmx64m -jar ${PROJECT_SOURCE_DIR}/configgen/target/configgen.jar
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..
+ COMMENT "Generating cpp config for ${CONFIG_NAME} in ${CMAKE_CURRENT_SOURCE_DIR}"
MAIN_DEPENDENCY ${CONFIG_DEF_PATH}
)
@@ -148,6 +161,7 @@ function(vespa_generate_config TARGET RELATIVE_CONFIG_DEF_PATH)
# Needed to be able to do a #include <config-<name>.h> for this target
# This is used within some unit tests
target_include_directories(${TARGET} PRIVATE ${CONFIG_DEST_DIR})
+ vespa_add_source_target("configgen_${TARGET}_${CONFIG_NAME}" DEPENDS ${CONFIG_H_PATH} ${CONFIG_CPP_PATH})
endfunction()
function(vespa_add_library TARGET)
@@ -497,6 +511,10 @@ function(__add_test_target_to_module TARGET)
set_property(GLOBAL APPEND PROPERTY MODULE_${MODULE_NAME}_TEST_TARGETS ${TARGET})
endfunction()
+function(__add_source_target_to_module TARGET)
+ set_property(GLOBAL APPEND PROPERTY MODULE_${MODULE_NAME}_SOURCE_TARGETS ${TARGET})
+endfunction()
+
macro(__handle_test_targets)
# If this is a test executable, add it to the test target for this module
# If building of unit tests is not specified, exclude this target from the all target