| 1 |
# Build and install library |
| 2 |
set(HEADERS hello_world_lib.hpp) |
| 3 |
set(SOURCES hello_world_lib.cpp) |
| 4 |
add_library(hello_world_lib ${SOURCES}) |
| 5 |
install(TARGETS hello_world_lib DESTINATION lib) |
| 6 |
install(FILES ${HEADERS} DESTINATION include) |
| 7 |
|
| 8 |
# Build and install user executable |
| 9 |
add_executable(hello_world hello_world_main.cpp) |
| 10 |
target_link_libraries(hello_world hello_world_lib) |
| 11 |
install(TARGETS hello_world DESTINATION bin) |
| 12 |
|
| 13 |
# Test the executable |
| 14 |
add_test(test ${CMAKE_CURRENT_BINARY_DIR}/hello_world) |
| 15 |
set_tests_properties(test PROPERTIES PASS_REGULAR_EXPRESSION "Hello World") |
| 16 |
|
| 17 |
# Build and run some unit tests |
| 18 |
add_executable(unit_tests hello_world_unit_tests.cpp) |
| 19 |
target_link_libraries(unit_tests hello_world_lib) |
| 20 |
add_test(unit_test ${CMAKE_CURRENT_BINARY_DIR}/unit_tests) |
| 21 |
set_tests_properties(unit_test |
| 22 |
PROPERTIES PASS_REGULAR_EXPRESSION "All unit tests passed") |