summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/Modules/GrBoost.cmake1
-rw-r--r--cmake/Modules/GrTest.cmake23
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)
+