1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 11:44:53 +08:00

cmake: Make test program depend on ENABLE_TEST_PROGRAM.

Gbp-Pq: Name 0004-cmake-Make-test-program-depend-on-ENABLE_TEST_PROGRA.patch
This commit is contained in:
Alec Leamas 2020-09-22 14:26:33 +02:00
parent ed0e389352
commit 742555a652

View File

@ -16,6 +16,9 @@ if(APPLE)
find_library(FOUNDATION_LIBRARY Foundation) find_library(FOUNDATION_LIBRARY Foundation)
endif() endif()
# Public options and command line configuration
option(ENABLE_TEST_PROGRAM "Build test program" OFF)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
# If Linux, add rt and pthread # If Linux, add rt and pthread
set(rt_LIBRARIES rt) set(rt_LIBRARIES rt)
@ -75,11 +78,6 @@ else()
target_link_libraries(${PROJECT_NAME} setupapi) target_link_libraries(${PROJECT_NAME} setupapi)
endif() 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 headers
include_directories(include) include_directories(include)
@ -92,7 +90,14 @@ install(TARGETS ${PROJECT_NAME}
${CATKIN_GLOBAL_INCLUDE_DESTINATION}/${PROJECT_NAME} ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/${PROJECT_NAME}
) )
## Tests
# Other targets: test program, pkg-config and tests.
if(CATKIN_ENABLE_TESTING) if(CATKIN_ENABLE_TESTING)
add_subdirectory(tests) add_subdirectory(tests)
endif() 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()