aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-10-28 11:13:48 +0100
committerPřemysl Eric Janouch <p@janouch.name>2020-10-28 11:23:39 +0100
commit577fd1b446ead2d98a68a10b2938151d6e824612 (patch)
treeaf765ca9d107ed142f0ab6fee98d3331884aafac
parent500c83231f1f13a7b02da1bfa8c848e765b9d3d0 (diff)
downloadxK-577fd1b446ead2d98a68a10b2938151d6e824612.tar.gz
xK-577fd1b446ead2d98a68a10b2938151d6e824612.tar.xz
xK-577fd1b446ead2d98a68a10b2938151d6e824612.zip
CMakeLists.txt: clean up and fix build rules
The multiple-output custom command ran separately for each binary.
-rw-r--r--CMakeLists.txt52
1 files changed, 18 insertions, 34 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 80ac1dc..015e044 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,7 +84,7 @@ list (APPEND degesch_libraries ${libffi_LIBRARIES})
include_directories (${libffi_INCLUDE_DIRS})
link_directories (${libffi_LIBRARY_DIRS})
-# FIXME: other Lua versions may be acceptable, don't know yet
+# XXX: other Lua versions may be acceptable, don't know yet
pkg_search_module (lua lua53 lua5.3 lua-5.3 lua54 lua5.4 lua-5.4 lua>=5.3)
option (WITH_LUA "Enable support for Lua plugins" ${lua_FOUND})
@@ -137,51 +137,35 @@ set (zyklonb_plugin_dir ${CMAKE_INSTALL_LIBDIR}/zyklonb/plugins)
configure_file (${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h)
include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
-# Project source files
-set (common_sources)
-set (common_headers ${PROJECT_BINARY_DIR}/config.h)
-
+# Generate IRC replies--we need a custom target because of the multiple outputs
add_custom_command (OUTPUT kike-replies.c kike.msg
COMMAND ${PROJECT_SOURCE_DIR}/kike-gen-replies.sh
> kike-replies.c < ${PROJECT_SOURCE_DIR}/kike-replies
DEPENDS ${PROJECT_SOURCE_DIR}/kike-replies
COMMENT "Generating files from the list of server numerics")
-set_source_files_properties (${PROJECT_BINARY_DIR}/kike-replies.c
- PROPERTIES HEADER_FILE_ONLY TRUE)
+add_custom_target (replies DEPENDS ${PROJECT_BINARY_DIR}/kike-replies.c)
# Build
-add_executable (zyklonb zyklonb.c ${common_sources} ${common_headers})
-target_link_libraries (zyklonb ${project_libraries})
-add_threads (zyklonb)
-
-add_executable (degesch degesch.c kike-replies.c
- ${common_sources} ${common_headers})
-target_link_libraries (degesch ${project_libraries} ${degesch_libraries})
-add_threads (degesch)
+foreach (name zyklonb degesch kike)
+ add_executable (${name} ${name}.c ${PROJECT_BINARY_DIR}/config.h)
+ target_link_libraries (${name} ${project_libraries})
+ add_threads (${name})
+endforeach (name)
-add_executable (kike kike.c kike-replies.c ${common_sources} ${common_headers})
-target_link_libraries (kike ${project_libraries})
-add_threads (kike)
+add_dependencies (kike replies)
+add_dependencies (degesch replies)
+target_link_libraries (degesch ${degesch_libraries})
# Tests
-function (make_tests_for target_name)
- get_target_property (sources ${target_name} SOURCES)
- get_target_property (libraries ${target_name} LINK_LIBRARIES)
- get_target_property (options ${target_name} COMPILE_OPTIONS)
-
- set (test test-${target_name})
- add_executable (${test} ${sources})
- target_link_libraries (${test} ${libraries})
- set_target_properties (${test} PROPERTIES
- COMPILE_DEFINITIONS TESTING
- COMPILE_OPTIONS "${options}")
-
- add_test (NAME ${test} COMMAND ${test})
-endfunction (make_tests_for)
-
include (CTest)
if (BUILD_TESTING)
- make_tests_for (degesch)
+ add_executable (test-degesch $<TARGET_PROPERTY:degesch,SOURCES>)
+ set_target_properties (test-degesch PROPERTIES COMPILE_DEFINITIONS TESTING)
+ target_link_libraries (test-degesch $<TARGET_PROPERTY:degesch,LINK_LIBRARIES>)
+ add_threads (test-degesch)
+ add_dependencies (test-degesch replies)
+
+ add_test (NAME test-degesch COMMAND test-degesch)
add_test (NAME custom-static-analysis
COMMAND ${PROJECT_SOURCE_DIR}/test-static)
endif (BUILD_TESTING)