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_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_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_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
|
# additional utilities
|
||||||
option(ENABLE_FGELEV "Set to ON to build the fgelev application (default)" ON)
|
option(ENABLE_FGELEV "Set to ON to build the fgelev application (default)" ON)
|
||||||
|
@ -266,6 +266,7 @@ endif(EVENT_INPUT)
|
||||||
include(SetupSwiftLibraries)
|
include(SetupSwiftLibraries)
|
||||||
|
|
||||||
if (SYSTEM_CPPUNIT)
|
if (SYSTEM_CPPUNIT)
|
||||||
|
message(STATUS "Looking for system CppUnit")
|
||||||
find_package(CppUnit REQUIRED)
|
find_package(CppUnit REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
# CPPUNIT_FOUND
|
# CPPUNIT_FOUND
|
||||||
# CPPUNIT_LIBRARIES
|
# CPPUNIT_LIBRARIES
|
||||||
# CPPUNIT_INCLUDE_DIR
|
# CPPUNIT_INCLUDE_DIR
|
||||||
|
#
|
||||||
|
# And defines the imported target CppUnitLib
|
||||||
|
|
||||||
# Find CppUnit.
|
# Find CppUnit.
|
||||||
if (NOT CPPUNIT_LIBRARIES AND NOT CPPUNIT_INCLUDE_DIR)
|
if (NOT CPPUNIT_LIBRARIES AND NOT CPPUNIT_INCLUDE_DIR)
|
||||||
|
@ -39,4 +41,12 @@ if (CPPUNIT_LIBRARIES AND CPPUNIT_INCLUDE_DIR)
|
||||||
set(CPPUNIT_FOUND TRUE)
|
set(CPPUNIT_FOUND TRUE)
|
||||||
message(STATUS "CppUnit library found: ${CPPUNIT_LIBRARIES}")
|
message(STATUS "CppUnit library found: ${CPPUNIT_LIBRARIES}")
|
||||||
message(STATUS "CppUnit include directory found: ${CPPUNIT_INCLUDE_DIR}")
|
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 ()
|
endif ()
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ if (NOT SYSTEM_CPPUNIT)
|
||||||
add_library(CppUnitLib STATIC ${CPPUNIT_SOURCES} ${CPPUNIT_HEADERS})
|
add_library(CppUnitLib STATIC ${CPPUNIT_SOURCES} ${CPPUNIT_HEADERS})
|
||||||
|
|
||||||
target_include_directories(CppUnitLib PUBLIC "${PROJECT_SOURCE_DIR}/3rdparty/cppunit/include")
|
target_include_directories(CppUnitLib PUBLIC "${PROJECT_SOURCE_DIR}/3rdparty/cppunit/include")
|
||||||
|
elseif(NOT TARGET CppUnitLib)
|
||||||
set(CPPUNIT_LIBRARIES CppUnitLib)
|
message(FATAL_ERROR "CppUnit: system CppUnit library not found correctly")
|
||||||
else()
|
else()
|
||||||
message(STATUS "CppUnit: Linking to the system supplied CppUnit library")
|
message(STATUS "CppUnit: Linking to the system supplied CppUnit library")
|
||||||
endif()
|
endif()
|
||||||
|
@ -151,7 +151,7 @@ target_include_directories(fgfs_test_suite PUBLIC ${PROJECT_SOURCE_DIR})
|
||||||
target_compile_definitions(fgfs_test_suite PUBLIC BUILDING_TESTSUITE)
|
target_compile_definitions(fgfs_test_suite PUBLIC BUILDING_TESTSUITE)
|
||||||
|
|
||||||
# Additional libraries just for the test suite.
|
# 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
|
# target to run the tests
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
|
|
Loading…
Add table
Reference in a new issue