Allow not to link tests against cppunit

This commit is contained in:
Martchus 2017-05-23 00:10:27 +02:00
parent 3bc1756425
commit 13ac2305d5
1 changed files with 13 additions and 5 deletions

View File

@ -7,12 +7,17 @@ endif()
option(EXCLUDE_TESTS_FROM_ALL "specifies whether to exclude tests from the \"all\" target (enabled by default)" ON) option(EXCLUDE_TESTS_FROM_ALL "specifies whether to exclude tests from the \"all\" target (enabled by default)" ON)
# find cppunit (I always use it for tests of my libs/applications but maybe this should be made optional in the future) # find and link against cppunit if required (used by all my projects, so it is required by default)
find_library(CPP_UNIT_LIB cppunit) if(NOT META_NO_CPP_UNIT)
find_library(CPP_UNIT_LIB cppunit)
if(CPP_UNIT_LIB)
list(APPEND TEST_LIBRARIES ${CPP_UNIT_LIB})
endif()
endif()
if(CPP_UNIT_LIB) if(CPP_UNIT_LIB OR META_NO_CPP_UNIT)
# always link test applications against c++utilities and cppunit # always link test applications against c++utilities
list(APPEND TEST_LIBRARIES ${CPP_UTILITIES_LIB} ${CPP_UNIT_LIB}) list(APPEND TEST_LIBRARIES ${CPP_UTILITIES_LIB})
# set compile definitions # set compile definitions
if(NOT META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS) if(NOT META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS)
@ -110,8 +115,11 @@ if(CPP_UNIT_LIB)
endif() endif()
endif() endif()
set(META_HAVE_TESTS YES)
else() else()
message(WARNING "Unable to add test target because cppunit could not be located.") message(WARNING "Unable to add test target because cppunit could not be located.")
set(META_HAVE_TESTS NO)
endif() endif()
set(TEST_CONFIG_DONE YES) set(TEST_CONFIG_DONE YES)