From e44813dddbf5ba063d29ae1e40862e7a7cbb6f43 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 20 Feb 2015 22:56:22 +0100 Subject: Reorganizing the source code: o Moving main to apps/ o Moving the library sources to ble/ o Creating cmake files for each piece. --- test/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/CMakeLists.txt (limited to 'test/CMakeLists.txt') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..14dcdf7 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,30 @@ +enable_testing() +find_package(Boost COMPONENTS log unit_test_framework REQUIRED) + +# If we can change directory here add_definition and test-specific stuff could be moved to the test directory +file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *Test.cpp) +add_definitions(-DBOOST_TEST_DYN_LINK) + +foreach(testSrc ${TEST_SRCS}) + #Extract the filename without an extension (NAME_WE) + get_filename_component(testName ${testSrc} NAME_WE) + + #Add compile target + add_executable(${testName} ${testSrc}) + + include_directories("${PROJECT_SOURCE_DIR}/ble") + add_dependencies(${testName} ble) + target_link_libraries(${testName} ble) + target_link_libraries(${testName} pthread) + target_link_libraries(${testName} ${Boost_LIBRARIES}) + + #I like to move testing binaries into a testBin directory + set_target_properties(${testName} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test) + + #Finally add it to test execution - + #Notice the WORKING_DIRECTORY and COMMAND + add_test(NAME ${testName} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/testBin + COMMAND ${CMAKE_BINARY_DIR}/testBin/${testName}) +endforeach(testSrc) -- cgit v1.2.3