diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-05-06 17:09:33 -0700 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2018-06-21 20:48:26 +0200 |
commit | c59ce7d39fd8e15c87befcd6935649f9b6587993 (patch) | |
tree | 9a6031f58d90e7e2da7af8ffe887329ad5391f18 /cmake | |
parent | 4b046a773c03273431a6b44909c852da077a1523 (diff) |
cmake: Add option for Boost UTF-based C++ unit tests
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Modules/GrBoost.cmake | 1 | ||||
-rw-r--r-- | cmake/Modules/GrTest.cmake | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/cmake/Modules/GrBoost.cmake b/cmake/Modules/GrBoost.cmake index 150009a7b9..e074462602 100644 --- a/cmake/Modules/GrBoost.cmake +++ b/cmake/Modules/GrBoost.cmake @@ -33,6 +33,7 @@ set(BOOST_REQUIRED_COMPONENTS system regex thread + unit_test_framework ) if(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64") diff --git a/cmake/Modules/GrTest.cmake b/cmake/Modules/GrTest.cmake index 5f90be3326..c12601fcc2 100644 --- a/cmake/Modules/GrTest.cmake +++ b/cmake/Modules/GrTest.cmake @@ -141,3 +141,26 @@ function(GR_ADD_TEST test_name) endif(WIN32) endfunction(GR_ADD_TEST) + +######################################################################## +# Add a C++ unit test and setup the environment for a unit test. +# Takes the same arguments as the ADD_TEST function. +# +# test_name -- An identifier for your test, for usage with ctest -R +# test_source -- Path to the .cc file +# +# Before calling set the following variables: +# GR_TEST_TARGET_DEPS - built targets for the library path +######################################################################## +function(GR_ADD_CPP_TEST test_name test_source) + add_executable(${test_name} ${test_source}) + target_link_libraries( + ${test_name} + ${GR_TEST_TARGET_DEPS} + ) + set_target_properties(${test_name} + PROPERTIES COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK;BOOST_TEST_MAIN" + ) + GR_ADD_TEST(${test_name} ${test_name}) +endfunction(GR_ADD_CPP_TEST) + |