-
Notifications
You must be signed in to change notification settings - Fork 179
Adding into a CMake Project
Patrick Mulder edited this page Aug 26, 2019
·
3 revisions
If you've built and installed UnitTest++ from source you simply need to add a find_package()
to your CMakeLists.txt
:
find_package(UnitTest++ REQUIRED)
find_package()
will locate the UnitTest++Config.cmake
and execute it, then define some variables:
UnitTest++_CONFIG=/usr/local/lib/cmake/UnitTest++/UnitTest++Config.cmake
UnitTest++_CONSIDERED_CONFIGS=/usr/local/lib/cmake/UnitTest++/UnitTest++Config.cmake
UnitTest++_CONSIDERED_VERSIONS=unknown
UnitTest++_DIR=/usr/local/lib/cmake/UnitTest++
UnitTest++_FOUND=1
UnitTest++_VERSION_COUNT=0
UnitTest++_VERSION_MAJOR=0
UnitTest++_VERSION_MINOR=0
UnitTest++_VERSION_PATCH=0
UnitTest++_VERSION_TWEAK=0
You can use UnitTest++_FOUND
to perform special handling in your CMakeLists.txt
if UnitTest++ wasn't located.
UnitTest++'s UnitTest++Config.cmake
defines the UTPP_INCLUDE_DIRS
helper variable for you:
UTPP_INCLUDE_DIRS=/usr/local/include
You should use this variable to add the include path for your unit test executables:
include_directories(${UTPP_INCLUDE_DIRS})
Also, to have the linker resolve the library symbols you should add:
target_link_libraries(foo UnitTest++)
Now you should be able to build and test!