CMakeLists.txt: clean up and fix build rules
The multiple-output custom command ran separately for each binary.
This commit is contained in:
parent
500c83231f
commit
577fd1b446
@ -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)
|
||||
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 (degesch degesch.c kike-replies.c
|
||||
${common_sources} ${common_headers})
|
||||
target_link_libraries (degesch ${project_libraries} ${degesch_libraries})
|
||||
add_threads (degesch)
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user