Cmake Improve Finder for CppUnit
Define an imported target for the system CppUnit, so we can correctly pass includes locations to FgfsTestSuite
This commit is contained in:
parent
4c42600898
commit
dc467ebdfa
3 changed files with 15 additions and 4 deletions
|
@ -183,7 +183,7 @@ option(SYSTEM_SPEEX "Set to ON to build IAXClient with the system's speex a
|
|||
option(SYSTEM_GSM "Set to ON to build IAXClient with the system's GSM library" ${SYSTEM_GSM_DEFAULT})
|
||||
option(SYSTEM_FLITE "Set to ON to build Flightgear with the system's Flite library" ${SYSTEM_FLITE_DEFAULT})
|
||||
option(SYSTEM_HTS_ENGINE "Set to ON to build Flightgear with the system's HTS Engine library" ${SYSTEM_HTS_ENGINE_DEFAULT})
|
||||
option(SYSTEM_CPPUNIT "Set to ON to build Flightgear with the system's CppUnit library")
|
||||
option(SYSTEM_CPPUNIT "Set to ON to build Flightgear with the system's CppUnit library" OFF)
|
||||
|
||||
# additional utilities
|
||||
option(ENABLE_FGELEV "Set to ON to build the fgelev application (default)" ON)
|
||||
|
@ -266,6 +266,7 @@ endif(EVENT_INPUT)
|
|||
include(SetupSwiftLibraries)
|
||||
|
||||
if (SYSTEM_CPPUNIT)
|
||||
message(STATUS "Looking for system CppUnit")
|
||||
find_package(CppUnit REQUIRED)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
# CPPUNIT_FOUND
|
||||
# CPPUNIT_LIBRARIES
|
||||
# CPPUNIT_INCLUDE_DIR
|
||||
#
|
||||
# And defines the imported target CppUnitLib
|
||||
|
||||
# Find CppUnit.
|
||||
if (NOT CPPUNIT_LIBRARIES AND NOT CPPUNIT_INCLUDE_DIR)
|
||||
|
@ -39,4 +41,12 @@ if (CPPUNIT_LIBRARIES AND CPPUNIT_INCLUDE_DIR)
|
|||
set(CPPUNIT_FOUND TRUE)
|
||||
message(STATUS "CppUnit library found: ${CPPUNIT_LIBRARIES}")
|
||||
message(STATUS "CppUnit include directory found: ${CPPUNIT_INCLUDE_DIR}")
|
||||
|
||||
if(NOT TARGET CppUnitLib)
|
||||
add_library(CppUnitLib UNKNOWN IMPORTED)
|
||||
set_target_properties(CppUnitLib PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${CPPUNIT_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${CPPUNIT_LIBRARIES}")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@ if (NOT SYSTEM_CPPUNIT)
|
|||
add_library(CppUnitLib STATIC ${CPPUNIT_SOURCES} ${CPPUNIT_HEADERS})
|
||||
|
||||
target_include_directories(CppUnitLib PUBLIC "${PROJECT_SOURCE_DIR}/3rdparty/cppunit/include")
|
||||
|
||||
set(CPPUNIT_LIBRARIES CppUnitLib)
|
||||
elseif(NOT TARGET CppUnitLib)
|
||||
message(FATAL_ERROR "CppUnit: system CppUnit library not found correctly")
|
||||
else()
|
||||
message(STATUS "CppUnit: Linking to the system supplied CppUnit library")
|
||||
endif()
|
||||
|
@ -151,7 +151,7 @@ target_include_directories(fgfs_test_suite PUBLIC ${PROJECT_SOURCE_DIR})
|
|||
target_compile_definitions(fgfs_test_suite PUBLIC BUILDING_TESTSUITE)
|
||||
|
||||
# Additional libraries just for the test suite.
|
||||
target_link_libraries(fgfs_test_suite ${CPPUNIT_LIBRARIES})
|
||||
target_link_libraries(fgfs_test_suite CppUnitLib)
|
||||
|
||||
# target to run the tests
|
||||
if (MSVC)
|
||||
|
|
Loading…
Add table
Reference in a new issue