From 742555a6521ca90eb5cda791ae9ec96dfce2954d Mon Sep 17 00:00:00 2001 From: Alec Leamas Date: Tue, 22 Sep 2020 14:26:33 +0200 Subject: [PATCH] cmake: Make test program depend on ENABLE_TEST_PROGRAM. Gbp-Pq: Name 0004-cmake-Make-test-program-depend-on-ENABLE_TEST_PROGRA.patch --- CMakeLists.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab371a6..854e739 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,9 @@ if(APPLE) find_library(FOUNDATION_LIBRARY Foundation) endif() +# Public options and command line configuration +option(ENABLE_TEST_PROGRAM "Build test program" OFF) + if(UNIX AND NOT APPLE) # If Linux, add rt and pthread set(rt_LIBRARIES rt) @@ -75,11 +78,6 @@ else() target_link_libraries(${PROJECT_NAME} setupapi) endif() -## Uncomment for example -add_executable(serial_example examples/serial_example.cc) -add_dependencies(serial_example ${PROJECT_NAME}) -target_link_libraries(serial_example ${PROJECT_NAME}) - ## Include headers include_directories(include) @@ -92,7 +90,14 @@ install(TARGETS ${PROJECT_NAME} ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/${PROJECT_NAME} ) -## Tests + +# Other targets: test program, pkg-config and tests. if(CATKIN_ENABLE_TESTING) add_subdirectory(tests) endif() + +if (ENABLE_TEST_PROGRAM) + add_executable(serial_example examples/serial_example.cc) + add_dependencies(serial_example ${PROJECT_NAME}) + target_link_libraries(serial_example ${PROJECT_NAME}) +endif()