diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 66a0777c..a353516d 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -2,6 +2,6 @@ if (NOT SYSTEM_EXPAT) add_subdirectory(expat) endif() -if (ENABLE_DNS AND NOT SYSTEM_UDNS) +if (NOT SYSTEM_UDNS) add_subdirectory(udns) endif() diff --git a/3rdparty/expat/CMakeLists.txt b/3rdparty/expat/CMakeLists.txt index badfd61c..e4271408 100644 --- a/3rdparty/expat/CMakeLists.txt +++ b/3rdparty/expat/CMakeLists.txt @@ -26,8 +26,24 @@ set(expat_sources sg_expat_external.h ) -foreach(s ${expat_sources}) - set_property(GLOBAL - APPEND PROPERTY LOCAL_EXPAT_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/${s}") -endforeach() +add_library(FGExpat STATIC ${expat_sources}) + +target_include_directories(FGExpat BEFORE PUBLIC + $ + $) + +# for the config file above +target_include_directories(FGExpat PRIVATE ${PROJECT_BINARY_DIR}/3rdparty/expat) + +target_compile_definitions(FGExpat PUBLIC HAVE_SIMGEAR_EXPAT_CONFIG_H XML_STATIC) + +# look like Expat found by find() +add_library(EXPAT::EXPAT ALIAS FGExpat) + +# in the non-shared case, we need to export these as well +if (NOT SIMGEAR_SHARED) + install(TARGETS FGExpat + EXPORT SimGearTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() diff --git a/3rdparty/udns/CMakeLists.txt b/3rdparty/udns/CMakeLists.txt index e4f14cbf..a66c66ec 100644 --- a/3rdparty/udns/CMakeLists.txt +++ b/3rdparty/udns/CMakeLists.txt @@ -13,7 +13,6 @@ CHECK_SYMBOL_EXISTS(AF_INET6 "netinet/in.h" HAVE_IPv6) check_include_file(windows.h WINDOWS) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h) -include_directories(${CMAKE_BINARY_DIR}) set(HEADERS ) @@ -38,4 +37,21 @@ set(SOURCES udns_XtoX.c ) -simgear_component(udns 3rdparty/udns "${SOURCES}" "${HEADERS}") +add_library(FGUdns STATIC ${SOURCES}) + +target_include_directories(FGUdns BEFORE PUBLIC + $ + $) + +target_include_directories(FGUdns PRIVATE ${CMAKE_BINARY_DIR}) + +# match the name of imported UDns +add_librarY(Udns::Udns ALIAS FGUdns) + +# in the non-shared case, we need to export these as well +if (NOT SIMGEAR_SHARED) + install(TARGETS FGUdns + EXPORT SimGearTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 187b18ca..179ed51d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,33 +60,12 @@ if(InSourceBuild) message(WARNING " mkdir ../sgbuild && cd ../sgbuild && cmake ${CMAKE_SOURCE_DIR}") endif(InSourceBuild) -#packaging -SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING") -SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README") -SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simulation support libraries for FlightGear and related projects") -SET(CPACK_PACKAGE_VENDOR "The FlightGear project") -SET(CPACK_GENERATOR "TBZ2") -SET(CPACK_INSTALL_CMAKE_PROJECTS ${CMAKE_CURRENT_BINARY_DIR};SimGear;ALL;/) - - -# split version string into components, note CMAKE_MATCH_0 is the entire regexp match -string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" CPACK_PACKAGE_VERSION ${SIMGEAR_VERSION} ) -set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1}) -set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2}) -set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3}) - -message(STATUS "version is ${CPACK_PACKAGE_VERSION_MAJOR} dot ${CPACK_PACKAGE_VERSION_MINOR} dot ${CPACK_PACKAGE_VERSION_PATCH}") - -set(CPACK_SOURCE_GENERATOR TBZ2) -set(CPACK_SOURCE_PACKAGE_FILE_NAME "simgear-${SIMGEAR_VERSION}" CACHE INTERNAL "tarball basename") -set(CPACK_SOURCE_IGNORE_FILES - "^${PROJECT_SOURCE_DIR}/.git;\\\\.gitignore;Makefile.am;~$;${CPACK_SOURCE_IGNORE_FILES}") - -include (CPack) # We have some custom .cmake scripts not in the official distribution. set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}") +include(Packaging) + # Change the default build type to something fast if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING @@ -108,8 +87,6 @@ if (NOT MSVC) option(SIMGEAR_SHARED "Set to ON to build SimGear as a shared library/framework" OFF) option(SYSTEM_EXPAT "Set to ON to build SimGear using the system expat library" OFF) option(SYSTEM_UDNS "Set to ON to build SimGear using the system udns library" OFF) -option(ENABLE_ASAN "Set to ON to build SimGear with LLVM AddressSanitizer (ASan) support" OFF) - else() # Building SimGear DLLs is currently not supported for MSVC. set(SIMGEAR_SHARED OFF) @@ -125,10 +102,9 @@ option(ENABLE_TESTS "Set to OFF to disable building SimGear's test applicati option(ENABLE_SOUND "Set to OFF to disable building SimGear's sound support" ON) option(USE_AEONWAVE "Set to ON to use AeonWave instead of OpenAL" ON) option(ENABLE_PKGUTIL "Set to ON to build the sg_pkgutil application (default)" ON) -option(ENABLE_DNS "Set to ON to use udns library and DNS service resolver" ON) option(ENABLE_SIMD "Enable SSE/SSE2 support for compilers" ON) option(ENABLE_SIMD_CODE "Enable SSE/SSE2 support code for compilers" OFF) -option(ENABLE_OPENMP "Enable OpenMP compiler support" OFF) +option(ENABLE_ASAN "Set to ON to build SimGear with LLVM AddressSanitizer (ASan) support" OFF) if (NOT ENABLE_SIMD AND ENABLE_SIMD_CODE) set(ENABLE_SIMD_CODE OFF) @@ -210,9 +186,7 @@ if(APPLE) find_library(COCOA_LIBRARY Cocoa) endif() -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - find_package(Threads REQUIRED) -endif() +find_package(Threads REQUIRED) find_package(Boost REQUIRED) set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION -DBOOST_NO_STDLIB_CONFIG -DBOOST_NO_AUTO_PTR -DBOOST_NO_CXX98_BINDERS") @@ -270,9 +244,6 @@ if (SYSTEM_EXPAT) else() message(STATUS "Using built-in expat code") - set(EXPAT_INCLUDE_DIRS - ${PROJECT_SOURCE_DIR}/3rdparty/expat - ${PROJECT_BINARY_DIR}/3rdparty/expat) endif(SYSTEM_EXPAT) check_include_file(inttypes.h HAVE_INTTYPES_H) @@ -280,11 +251,6 @@ check_include_file(sys/time.h HAVE_SYS_TIME_H) check_include_file(unistd.h HAVE_UNISTD_H) check_include_file(windows.h HAVE_WINDOWS_H) -if(HAVE_INTTYPES_H) - # ShivaVG needs inttypes.h - add_definitions(-DHAVE_INTTYPES_H) -endif() - if(ENABLE_RTI) find_package(PkgConfig) if(PKG_CONFIG_FOUND) @@ -302,60 +268,9 @@ endif(ENABLE_RTI) if(ENABLE_GDAL) find_package(GDAL 2.0.0 REQUIRED) - if (GDAL_FOUND) - include_directories(${GDAL_INCLUDE_DIR}) - endif(GDAL_FOUND) endif(ENABLE_GDAL) -check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) -check_function_exists(rint HAVE_RINT) -check_function_exists(mkdtemp HAVE_MKDTEMP) -check_function_exists(bcopy HAVE_BCOPY) -check_function_exists(mmap HAVE_MMAP) - -if (NOT MSVC) - check_function_exists(timegm HAVE_TIMEGM) - if (NOT HAVE_TIMEGM) - message(FATAL_ERROR "Non-Windows platforms must support timegm()") - endif() -endif() - -if(HAVE_UNISTD_H) - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH}) - check_cxx_source_compiles( - "#include - #if !defined(_POSIX_TIMERS) || (0 >= _POSIX_TIMERS) - #error clock_gettime is not supported - #endif - - int main() { return 0; } - " - HAVE_CLOCK_GETTIME) -endif(HAVE_UNISTD_H) - -set(RT_LIBRARY "") -if(HAVE_CLOCK_GETTIME) - check_library_exists(rt clock_gettime "" HAVE_RT) - if(HAVE_RT) - set(RT_LIBRARY rt) - endif(HAVE_RT) -endif(HAVE_CLOCK_GETTIME) - -set(DL_LIBRARY "") -check_cxx_source_compiles( - "#include - int main(void) { - return 0; - } - " - HAVE_DLFCN_H) - -if(HAVE_DLFCN_H) - check_library_exists(dl dlerror "" HAVE_DL) - if(HAVE_DL) - set(DL_LIBRARY "dl") - endif() -endif() +include(CheckPOSIXFeatures) SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually 'd' on windows") SET(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows") @@ -415,29 +330,16 @@ if (CLANG) set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG") set(SIMD_COMPILER_FLAGS "-msse2 -mfpmath=sse -ftree-vectorize -ftree-slp-vectorize") - - if (ENABLE_ASAN) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") - - # needed for check_cxx_source_compiles - set(CMAKE_REQUIRED_LINK_OPTIONS "-fsanitize=address") - endif() endif() -if (ENABLE_OPENMP) - find_package(OpenMP) - if(OPENMP_FOUND) - message(STATUS "OpenMP: ENABLED") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - else() - message(STATUS "OpenMP: NOT FOUND") - endif() -else() - message(STATUS "OpenMP: DISABLED") +if (ENABLE_ASAN) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") + + # needed for check_cxx_source_compiles + set(CMAKE_REQUIRED_LINK_OPTIONS "-fsanitize=address") endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") @@ -496,14 +398,6 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}") include(CheckCXXFeatures) -# use BEFORE to ensure local directories are used first, -# ahead of system-installed libs -include_directories(BEFORE ${PROJECT_BINARY_DIR}/simgear) - -if(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") - include_directories("/usr/X11R6/include") -endif() - add_definitions(-DHAVE_CONFIG_H) # configure a header file to pass some of the CMake settings @@ -513,49 +407,18 @@ configure_file ( "${PROJECT_BINARY_DIR}/simgear/simgear_config.h" ) -if(ENABLE_TESTS) - # enable CTest / make test target - message(STATUS "Tests: ENABLED") - - include (Dart) - enable_testing() -else() - message(STATUS "Tests: DISABLED") -endif(ENABLE_TESTS) - -# always set TEST_LIBS as it is also used by other tools/applications -set(TEST_LIBS_INTERNAL_CORE - ${CMAKE_THREAD_LIBS_INIT} - ${ZLIB_LIBRARY} - ${WINSOCK_LIBRARY} - ${SHLWAPI_LIBRARY} - ${RT_LIBRARY} - ${DL_LIBRARY} - ${COCOA_LIBRARY} - ${CURL_LIBRARIES} - ${GDAL_LIBRARY}) -set(TEST_LIBS SimGearCore ${TEST_LIBS_INTERNAL_CORE}) - -if(NOT SIMGEAR_HEADLESS) - set(TEST_LIBS SimGearScene ${OPENGL_LIBRARIES} ${TEST_LIBS}) -endif() +include (Dart) +enable_testing() +include(AddSimGearTest) # helper to setup a test install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h DESTINATION include/simgear/) -if(ENABLE_DNS) - if(SYSTEM_UDNS) - message(STATUS "Requested to use system udns library, forcing SIMGEAR_SHARED to true") - set(SIMGEAR_SHARED ON) - find_package(Udns REQUIRED) - else() - message(STATUS "DNS resolver: ENABLED") - include_directories(3rdparty/udns) - endif() -else() - message(STATUS "DNS resolver: DISABLED") +if(SYSTEM_UDNS) + message(STATUS "Requested to use system udns library, forcing SIMGEAR_SHARED to true") + set(SIMGEAR_SHARED ON) + find_package(Udns REQUIRED) endif() - add_subdirectory(3rdparty) add_subdirectory(simgear) diff --git a/CMakeModules/AddSimGearTest.cmake b/CMakeModules/AddSimGearTest.cmake new file mode 100644 index 00000000..c7e8309f --- /dev/null +++ b/CMakeModules/AddSimGearTest.cmake @@ -0,0 +1,30 @@ + +function(add_simgear_test _name _sources) + add_executable(${_name} ${_sources}) + target_link_libraries(${_name} SimGearCore) + + # for simgear_config.h + target_include_directories(${_name} PRIVATE ${PROJECT_BINARY_DIR}/simgear) +endfunction() + + +function(add_simgear_autotest _name _sources) + add_executable(${_name} ${_sources}) + target_link_libraries(${_name} SimGearCore) + + # for simgear_config.h + target_include_directories(${_name} PRIVATE ${PROJECT_BINARY_DIR}/simgear) + + add_test(${_name} ${EXECUTABLE_OUTPUT_PATH}/${_name}) +endfunction() + + +function(add_simgear_scene_autotest _name _sources) + add_executable(${_name} ${_sources}) + target_link_libraries(${_name} SimGearScene) + + # for simgear_config.h + target_include_directories(${_name} PRIVATE ${PROJECT_BINARY_DIR}/simgear) + + add_test(${_name} ${EXECUTABLE_OUTPUT_PATH}/${_name}) +endfunction() diff --git a/CMakeModules/CheckPOSIXFeatures.cmake b/CMakeModules/CheckPOSIXFeatures.cmake new file mode 100644 index 00000000..6fbbd43f --- /dev/null +++ b/CMakeModules/CheckPOSIXFeatures.cmake @@ -0,0 +1,50 @@ +check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) +check_function_exists(rint HAVE_RINT) +check_function_exists(mkdtemp HAVE_MKDTEMP) +check_function_exists(bcopy HAVE_BCOPY) +check_function_exists(mmap HAVE_MMAP) + +if (NOT MSVC) + check_function_exists(timegm HAVE_TIMEGM) + if (NOT HAVE_TIMEGM) + message(FATAL_ERROR "Non-Windows platforms must support timegm()") + endif() +endif() + +if(HAVE_UNISTD_H) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH}) + check_cxx_source_compiles( + "#include + #if !defined(_POSIX_TIMERS) || (0 >= _POSIX_TIMERS) + #error clock_gettime is not supported + #endif + + int main() { return 0; } + " + HAVE_CLOCK_GETTIME) +endif(HAVE_UNISTD_H) + +set(RT_LIBRARY "") +if(HAVE_CLOCK_GETTIME) + check_library_exists(rt clock_gettime "" HAVE_RT) + if(HAVE_RT) + set(RT_LIBRARY rt) + endif(HAVE_RT) +endif(HAVE_CLOCK_GETTIME) + +set(DL_LIBRARY "") +check_cxx_source_compiles( + "#include + int main(void) { + return 0; + } + " + HAVE_DLFCN_H) + +if(HAVE_DLFCN_H) + check_library_exists(dl dlerror "" HAVE_DL) + if(HAVE_DL) + set(DL_LIBRARY "dl") + endif() +endif() + diff --git a/CMakeModules/FindUdns.cmake b/CMakeModules/FindUdns.cmake index 14594d0d..260bbc11 100644 --- a/CMakeModules/FindUdns.cmake +++ b/CMakeModules/FindUdns.cmake @@ -39,4 +39,19 @@ else () # show the UDNS_INCLUDE_DIRS and UDNS_LIBRARIES variables only in the advanced view mark_as_advanced(UDNS_INCLUDE_DIRS UDNS_LIBRARIES) + if(UDNS_FOUND) + + if(NOT TARGET Udns::Udns) + add_library(Udns::Udns UNKNOWN IMPORTED) + set_target_properties(Udns::Udns PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${UDNS_INCLUDE_DIRS}") + + set_target_properties(Udns::Udns PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${UDNS_LIBRARIES}") + + endif() +endif() + + endif () diff --git a/CMakeModules/Packaging.cmake b/CMakeModules/Packaging.cmake new file mode 100644 index 00000000..66ec57f3 --- /dev/null +++ b/CMakeModules/Packaging.cmake @@ -0,0 +1,23 @@ +#packaging +SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING") +SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README") +SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simulation support libraries for FlightGear and related projects") +SET(CPACK_PACKAGE_VENDOR "The FlightGear project") +SET(CPACK_GENERATOR "TBZ2") +SET(CPACK_INSTALL_CMAKE_PROJECTS ${CMAKE_CURRENT_BINARY_DIR};SimGear;ALL;/) + + +# split version string into components, note CMAKE_MATCH_0 is the entire regexp match +string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" CPACK_PACKAGE_VERSION ${SIMGEAR_VERSION} ) +set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1}) +set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2}) +set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3}) + +message(STATUS "version is ${CPACK_PACKAGE_VERSION_MAJOR} dot ${CPACK_PACKAGE_VERSION_MINOR} dot ${CPACK_PACKAGE_VERSION_PATCH}") + +set(CPACK_SOURCE_GENERATOR TBZ2) +set(CPACK_SOURCE_PACKAGE_FILE_NAME "simgear-${SIMGEAR_VERSION}" CACHE INTERNAL "tarball basename") +set(CPACK_SOURCE_IGNORE_FILES + "^${PROJECT_SOURCE_DIR}/.git;\\\\.gitignore;Makefile.am;~$;${CPACK_SOURCE_IGNORE_FILES}") + +include (CPack) \ No newline at end of file diff --git a/simgear/CMakeLists.txt b/simgear/CMakeLists.txt index aee895a2..5d15f8b5 100644 --- a/simgear/CMakeLists.txt +++ b/simgear/CMakeLists.txt @@ -48,7 +48,6 @@ install (FILES ${HEADERS} DESTINATION include/simgear/) get_property(coreSources GLOBAL PROPERTY CORE_SOURCES) get_property(sceneSources GLOBAL PROPERTY SCENE_SOURCES) get_property(publicHeaders GLOBAL PROPERTY PUBLIC_HEADERS) -get_property(localExpatSources GLOBAL PROPERTY LOCAL_EXPAT_SOURCES) if(SIMGEAR_SHARED) message(STATUS "Library building mode: SHARED LIBRARIES") @@ -89,7 +88,7 @@ else() source_group("${name}\\Headers" FILES ${g2}) endforeach() - add_library(SimGearCore STATIC ${coreSources} ${localExpatSources}) + add_library(SimGearCore STATIC ${coreSources}) if(NOT SIMGEAR_HEADLESS) get_property(FG_GROUPS_SCENE_SOURCES_C GLOBAL PROPERTY FG_GROUPS_SCENE_SOURCES_C) @@ -111,6 +110,11 @@ else() endforeach() add_library(SimGearScene STATIC ${sceneSources}) + + if(HAVE_INTTYPES_H) + # ShivaVG needs inttypes.h + target_compile_definitions(SimGearScene PRIVATE HAVE_INTTYPES_H) + endif() endif(NOT SIMGEAR_HEADLESS) endif(SIMGEAR_SHARED) @@ -118,45 +122,16 @@ target_include_directories(SimGearCore BEFORE PUBLIC $ $) -# so simgear/simgear_config.h is found -target_include_directories(SimGearCore BEFORE PUBLIC - $ - $) +# for simgear_config.h +target_include_directories(SimGearCore PRIVATE ${PROJECT_BINARY_DIR}/simgear) target_include_directories(SimGearCore PUBLIC ${Boost_INCLUDE_DIRS}) -target_include_directories(SimGearCore PRIVATE - ${EXPAT_INCLUDE_DIRS} ) -if (NOT SYSTEM_EXPAT) - # XML_STATIC is important to avoid sg_expat_external.h - # declaring symbols as declspec(import) - target_compile_definitions(SimGearCore PRIVATE HAVE_SIMGEAR_EXPAT_CONFIG_H XML_STATIC) -endif() - - install(TARGETS SimGearCore - EXPORT SimGearTargets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -if (NOT SIMGEAR_HEADLESS) - install(TARGETS SimGearScene - EXPORT SimGearTargets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - - target_include_directories(SimGearScene BEFORE PUBLIC - $ - $) - - target_include_directories(SimGearScene PUBLIC ${OPENSCENEGRAPH_INCLUDE_DIRS}) - - if (USE_AEONWAVE) - target_include_directories(SimGearScene PRIVATE ${AAX_INCLUDE_DIR} ) - else() - target_include_directories(SimGearScene PRIVATE ${OPENAL_INCLUDE_DIR} ) - endif() -endif() +install(TARGETS SimGearCore + EXPORT SimGearTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) # we expose ZLib in some of our headers target_link_libraries(SimGearCore PUBLIC ZLIB::ZLIB) @@ -166,22 +141,18 @@ if (ENABLE_RTI) target_link_libraries(SimGearCore PRIVATE PkgConfig::RTI) endif() +# all of these we keep privately target_link_libraries(SimGearCore PRIVATE + ${SHLWAPI_LIBRARY} ${RT_LIBRARY} ${DL_LIBRARY} - ${CMAKE_THREAD_LIBS_INIT} + Threads::Threads ${COCOA_LIBRARY} CURL::libcurl + EXPAT::EXPAT + Udns::Udns ${WINSOCK_LIBRARY}) -if(SYSTEM_EXPAT) - target_link_libraries(SimGearCore PRIVATE ${EXPAT_LIBRARIES}) -endif() - -if(ENABLE_DNS AND SYSTEM_UDNS) - target_link_libraries(SimGearCore PRIVATE ${UDNS_LIBRARIES}) -endif() - if(NOT SIMGEAR_HEADLESS) target_include_directories(SimGearScene PRIVATE ${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include) @@ -197,9 +168,28 @@ if(NOT SIMGEAR_HEADLESS) ${JPEG_LIBRARY}) if(ENABLE_GDAL) - target_link_libraries(SimGearScene PRIVATE ${GDAL_LIBRARIES}) + target_link_libraries(SimGearScene PRIVATE GDAL::GDAL) endif() # only actually needed by canvas/KeyboardEvent.cxx target_include_directories(SimGearScene PRIVATE ${PROJECT_SOURCE_DIR}/3rdparty/utf8/source) + + install(TARGETS SimGearScene + EXPORT SimGearTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + target_include_directories(SimGearScene BEFORE PUBLIC + $ + $) + + # for simgear_config.h + target_include_directories(SimGearScene PRIVATE ${PROJECT_BINARY_DIR}/simgear) + target_include_directories(SimGearScene PUBLIC ${OPENSCENEGRAPH_INCLUDE_DIRS}) + + if (USE_AEONWAVE) + target_include_directories(SimGearScene PRIVATE ${AAX_INCLUDE_DIR} ) + else() + target_include_directories(SimGearScene PRIVATE ${OPENAL_INCLUDE_DIR} ) + endif() endif() \ No newline at end of file diff --git a/simgear/bucket/CMakeLists.txt b/simgear/bucket/CMakeLists.txt index 6878f123..c667779c 100644 --- a/simgear/bucket/CMakeLists.txt +++ b/simgear/bucket/CMakeLists.txt @@ -6,11 +6,6 @@ set(SOURCES newbucket.cxx) simgear_component(bucket bucket "${SOURCES}" "${HEADERS}") - if(ENABLE_TESTS) - -add_executable(test_bucket test_bucket.cxx) -add_test(test_bucket ${EXECUTABLE_OUTPUT_PATH}/test_bucket) -target_link_libraries(test_bucket ${TEST_LIBS}) - + add_simgear_autotest(test_bucket test_bucket.cxx) endif(ENABLE_TESTS) \ No newline at end of file diff --git a/simgear/bvh/CMakeLists.txt b/simgear/bvh/CMakeLists.txt index 6bb3c551..d3e32915 100644 --- a/simgear/bvh/CMakeLists.txt +++ b/simgear/bvh/CMakeLists.txt @@ -46,7 +46,5 @@ set(SOURCES simgear_component(bvh bvh "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - add_executable(bvhtest bvhtest.cxx) - target_link_libraries(bvhtest SimGearCore) - add_test(bvhtest ${EXECUTABLE_OUTPUT_PATH}/bvhtest) + add_simgear_autotest(bvhtest bvhtest.cxx) endif(ENABLE_TESTS) diff --git a/simgear/canvas/elements/CMakeLists.txt b/simgear/canvas/elements/CMakeLists.txt index 43ff1c1a..61ace024 100644 --- a/simgear/canvas/elements/CMakeLists.txt +++ b/simgear/canvas/elements/CMakeLists.txt @@ -22,5 +22,5 @@ simgear_scene_component(canvas-elements canvas/elements "${SOURCES}" "${HEADERS} add_boost_test(canvas_element SOURCES canvas_element_test.cpp - LIBRARIES ${TEST_LIBS} + LIBRARIES SimGearScene ) \ No newline at end of file diff --git a/simgear/canvas/events/CMakeLists.txt b/simgear/canvas/events/CMakeLists.txt index 63508055..19f73ce8 100644 --- a/simgear/canvas/events/CMakeLists.txt +++ b/simgear/canvas/events/CMakeLists.txt @@ -18,11 +18,10 @@ simgear_scene_component(canvas-events canvas/events "${SOURCES}" "${HEADERS}") add_boost_test(canvas_event SOURCES event_test.cpp - LIBRARIES ${TEST_LIBS} + LIBRARIES SimGearScene ) -add_executable(input_event_demo input_event_demo.cxx) +add_simgear_test(input_event_demo input_event_demo.cxx) target_link_libraries(input_event_demo - ${TEST_LIBS} - ${OPENSCENEGRAPH_LIBRARIES} + SimGearScene ) \ No newline at end of file diff --git a/simgear/canvas/layout/CMakeLists.txt b/simgear/canvas/layout/CMakeLists.txt index ff7c900b..f498a812 100644 --- a/simgear/canvas/layout/CMakeLists.txt +++ b/simgear/canvas/layout/CMakeLists.txt @@ -21,5 +21,5 @@ simgear_scene_component(canvas-layout canvas/layout "${SOURCES}" "${HEADERS}") add_boost_test(canvas_layout SOURCES canvas_layout_test.cxx - LIBRARIES ${TEST_LIBS} + LIBRARIES SimGearScene ) \ No newline at end of file diff --git a/simgear/embedded_resources/CMakeLists.txt b/simgear/embedded_resources/CMakeLists.txt index 0346e613..3f85a274 100644 --- a/simgear/embedded_resources/CMakeLists.txt +++ b/simgear/embedded_resources/CMakeLists.txt @@ -11,8 +11,5 @@ simgear_component(embedded_resources embedded_resources "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - add_executable(test_embedded_resources embedded_resources_test.cxx) - target_link_libraries(test_embedded_resources ${TEST_LIBS}) - add_test(embedded_resources - ${EXECUTABLE_OUTPUT_PATH}/test_embedded_resources) + add_simgear_autotest(test_embedded_resources embedded_resources_test.cxx) endif(ENABLE_TESTS) diff --git a/simgear/emesary/CMakeLists.txt b/simgear/emesary/CMakeLists.txt index 30ca3318..a4bec6d2 100644 --- a/simgear/emesary/CMakeLists.txt +++ b/simgear/emesary/CMakeLists.txt @@ -21,13 +21,8 @@ simgear_component(emesary emesary "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) -add_executable(test_emesary test_emesary.cxx) - +add_simgear_autotest(test_emesary test_emesary.cxx) set_target_properties(test_emesary PROPERTIES COMPILE_DEFINITIONS "SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" ) -target_link_libraries(test_emesary ${TEST_LIBS}) -add_test(emesary ${EXECUTABLE_OUTPUT_PATH}/test_emesary) - - endif(ENABLE_TESTS) diff --git a/simgear/environment/CMakeLists.txt b/simgear/environment/CMakeLists.txt index ddb53166..51916997 100644 --- a/simgear/environment/CMakeLists.txt +++ b/simgear/environment/CMakeLists.txt @@ -7,23 +7,11 @@ set(SOURCES metar.cxx precipitation.cxx) simgear_scene_component(environment environment "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) -add_executable(test_metar test_metar.cxx) -if (SIMGEAR_SHARED) - target_link_libraries(test_metar SimGearScene ${GDAL_LIBRARY}) -else() - target_link_libraries(test_metar - SimGearScene SimGearCore - ${CMAKE_THREAD_LIBS_INIT} - ${ZLIB_LIBRARY} - ${RT_LIBRARY} - ${GDAL_LIBRARY}) -endif() +add_simgear_autotest(test_metar test_metar.cxx) +target_link_libraries(test_metar SimGearScene) -add_test(metar ${EXECUTABLE_OUTPUT_PATH}/test_metar) - -add_executable(test_precipitation test_precipitation.cxx) -target_link_libraries(test_precipitation ${TEST_LIBS}) -add_test(precipitation ${EXECUTABLE_OUTPUT_PATH}/test_precipitation) +add_simgear_autotest(test_precipitation test_precipitation.cxx) +target_link_libraries(test_precipitation SimGearScene) endif(ENABLE_TESTS) diff --git a/simgear/io/CMakeLists.txt b/simgear/io/CMakeLists.txt index c658935a..23e74a38 100644 --- a/simgear/io/CMakeLists.txt +++ b/simgear/io/CMakeLists.txt @@ -20,6 +20,7 @@ set(HEADERS HTTPRequest.hxx HTTPRepository.hxx untar.hxx + DNSClient.hxx ) set(SOURCES @@ -40,55 +41,25 @@ set(SOURCES HTTPRequest.cxx HTTPRepository.cxx untar.cxx + DNSClient.cxx ) -if(ENABLE_DNS) - list(APPEND SOURCES DNSClient.cxx) - list(APPEND HEADERS DNSClient.hxx) -endif() - simgear_component(io io "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) -add_executable(test_sock socktest.cxx) -target_link_libraries(test_sock ${TEST_LIBS}) +add_simgear_test(test_sock socktest.cxx) +add_simgear_autotest(test_http test_HTTP.cxx) +add_simgear_autotest(test_dns test_DNS.cxx) +add_simgear_test(httpget httpget.cxx) +add_simgear_test(http_repo_sync http_repo_sync.cxx) +add_simgear_test(decode_binobj decode_binobj.cxx) +add_simgear_autotest(test_binobj test_binobj.cxx) +add_simgear_autotest(test_repository test_repository.cxx) -add_executable(test_http test_HTTP.cxx) -target_link_libraries(test_http ${TEST_LIBS}) - -add_test(http ${EXECUTABLE_OUTPUT_PATH}/test_http) - -if(ENABLE_DNS) - add_executable(test_dns test_DNS.cxx) - target_link_libraries(test_dns ${TEST_LIBS}) - add_test(dns ${EXECUTABLE_OUTPUT_PATH}/test_dns) -endif() - -add_executable(httpget httpget.cxx) -target_link_libraries(httpget ${TEST_LIBS}) - -add_executable(http_repo_sync http_repo_sync.cxx) -target_link_libraries(http_repo_sync ${TEST_LIBS}) - -add_executable(decode_binobj decode_binobj.cxx) -target_link_libraries(decode_binobj ${TEST_LIBS}) - -add_executable(test_binobj test_binobj.cxx) -target_link_libraries(test_binobj ${TEST_LIBS}) - -add_test(binobj ${EXECUTABLE_OUTPUT_PATH}/test_binobj) - -add_executable(test_repository test_repository.cxx) -target_link_libraries(test_repository ${TEST_LIBS}) -add_test(http_repository ${EXECUTABLE_OUTPUT_PATH}/test_repository) - -add_executable(test_untar test_untar.cxx) +add_simgear_autotest(test_untar test_untar.cxx) set_target_properties(test_untar PROPERTIES COMPILE_DEFINITIONS "SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" ) -target_link_libraries(test_untar ${TEST_LIBS}) -add_test(untar ${EXECUTABLE_OUTPUT_PATH}/test_untar) - endif(ENABLE_TESTS) diff --git a/simgear/io/iostreams/CMakeLists.txt b/simgear/io/iostreams/CMakeLists.txt index 5ad22434..7b218fb5 100644 --- a/simgear/io/iostreams/CMakeLists.txt +++ b/simgear/io/iostreams/CMakeLists.txt @@ -19,17 +19,7 @@ set(SOURCES simgear_component(IOStreams io/iostreams "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - - add_executable(test_streams sgstream_test.cxx ) - target_link_libraries(test_streams ${TEST_LIBS}) - add_test(streams ${EXECUTABLE_OUTPUT_PATH}/test_streams) - - add_executable(test_CharArrayStream CharArrayStream_test.cxx) - target_link_libraries(test_CharArrayStream ${TEST_LIBS}) - add_test(CharArrayStream ${EXECUTABLE_OUTPUT_PATH}/test_CharArrayStream) - - add_executable(test_zlibstream zlibstream_test.cxx) - target_link_libraries(test_zlibstream ${TEST_LIBS}) - add_test(zlibstream ${EXECUTABLE_OUTPUT_PATH}/test_zlibstream) - + add_simgear_autotest(test_streams sgstream_test.cxx ) + add_simgear_autotest(test_CharArrayStream CharArrayStream_test.cxx) + add_simgear_autotest(test_zlibstream zlibstream_test.cxx) endif(ENABLE_TESTS) diff --git a/simgear/math/CMakeLists.txt b/simgear/math/CMakeLists.txt index b82a7243..1de5b00e 100644 --- a/simgear/math/CMakeLists.txt +++ b/simgear/math/CMakeLists.txt @@ -47,16 +47,8 @@ simgear_component(math math "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) -add_executable(sgvec4_test test_sgvec4.cxx) -target_link_libraries(sgvec4_test ${TEST_LIBS}) -add_test(sgvec4 ${EXECUTABLE_OUTPUT_PATH}/sgvec4_test) - -add_executable(math_test SGMathTest.cxx) -target_link_libraries(math_test ${TEST_LIBS}) -add_test(math ${EXECUTABLE_OUTPUT_PATH}/math_test) - -add_executable(geometry_test SGGeometryTest.cxx) -target_link_libraries(geometry_test ${TEST_LIBS}) -add_test(geometry ${EXECUTABLE_OUTPUT_PATH}/geometry_test) +add_simgear_autotest(sgvec4_test test_sgvec4.cxx) +add_simgear_autotest(math_test SGMathTest.cxx) +add_simgear_autotest(geometry_test SGGeometryTest.cxx) endif(ENABLE_TESTS) diff --git a/simgear/misc/CMakeLists.txt b/simgear/misc/CMakeLists.txt index f623903b..7cbfd843 100644 --- a/simgear/misc/CMakeLists.txt +++ b/simgear/misc/CMakeLists.txt @@ -50,43 +50,26 @@ simgear_component(misc misc "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) -add_executable(test_argparse argparse_test.cxx) -target_link_libraries(test_argparse ${TEST_LIBS}) -add_test(argparse ${EXECUTABLE_OUTPUT_PATH}/test_argparse) - -add_executable(test_CSSBorder CSSBorder_test.cxx) -add_test(CSSBorder ${EXECUTABLE_OUTPUT_PATH}/test_CSSBorder) -target_link_libraries(test_CSSBorder ${TEST_LIBS}) - -add_executable(test_tabbed_values tabbed_values_test.cxx) -add_test(tabbed_values ${EXECUTABLE_OUTPUT_PATH}/test_tabbed_values) -target_link_libraries(test_tabbed_values ${TEST_LIBS}) - -add_executable(test_strutils strutils_test.cxx) -target_link_libraries(test_strutils ${TEST_LIBS}) -add_test(strutils ${EXECUTABLE_OUTPUT_PATH}/test_strutils) - -add_executable(test_path path_test.cxx ) -add_test(path ${EXECUTABLE_OUTPUT_PATH}/test_path) -target_link_libraries(test_path ${TEST_LIBS}) - -add_executable(test_sg_dir sg_dir_test.cxx) -target_link_libraries(test_sg_dir ${TEST_LIBS}) -add_test(sg_dir ${EXECUTABLE_OUTPUT_PATH}/test_sg_dir) +add_simgear_autotest(test_argparse argparse_test.cxx) +add_simgear_autotest(test_CSSBorder CSSBorder_test.cxx) +add_simgear_autotest(test_tabbed_values tabbed_values_test.cxx) +add_simgear_autotest(test_strutils strutils_test.cxx) +add_simgear_autotest(test_path path_test.cxx ) +add_simgear_autotest(test_sg_dir sg_dir_test.cxx) endif(ENABLE_TESTS) add_boost_test(SimpleMarkdown SOURCES SimpleMarkdown_test.cxx - LIBRARIES ${TEST_LIBS} + LIBRARIES SimGearCore ) add_boost_test(SVGpreserveAspectRatio SOURCES SVGpreserveAspectRatio_test.cxx - LIBRARIES ${TEST_LIBS} + LIBRARIES SimGearCore ) add_boost_test(utf8tolatin1 SOURCES utf8tolatin1_test.cxx - LIBRARIES ${TEST_LIBS} + LIBRARIES SimGearCore ) diff --git a/simgear/nasal/cppbind/CMakeLists.txt b/simgear/nasal/cppbind/CMakeLists.txt index ca2475c7..a2a1cc9e 100644 --- a/simgear/nasal/cppbind/CMakeLists.txt +++ b/simgear/nasal/cppbind/CMakeLists.txt @@ -37,20 +37,20 @@ simgear_component(nasal/cppbind/detail nasal/cppbind/detail "" "${DETAIL_HEADERS add_boost_test(cppbind_ghost SOURCES test/cppbind_test_ghost.cxx - LIBRARIES ${TEST_LIBS} + LIBRARIES SimGearCore ) add_boost_test(cppbind_misc SOURCES test/cppbind_test.cxx - LIBRARIES ${TEST_LIBS} + LIBRARIES SimGearCore ) add_boost_test(nasal_gc_test SOURCES test/nasal_gc_test.cxx - LIBRARIES ${TEST_LIBS} + LIBRARIES SimGearCore ) add_boost_test(nasal_num SOURCES test/nasal_num_test.cxx - LIBRARIES ${TEST_LIBS} + LIBRARIES SimGearCore ) diff --git a/simgear/package/CMakeLists.txt b/simgear/package/CMakeLists.txt index 7344adb3..ae048978 100644 --- a/simgear/package/CMakeLists.txt +++ b/simgear/package/CMakeLists.txt @@ -24,18 +24,13 @@ set(SOURCES simgear_component(package package "${SOURCES}" "${HEADERS}") if(ENABLE_PKGUTIL) - add_executable(sg_pkgutil pkgutil.cxx) - target_link_libraries(sg_pkgutil ${TEST_LIBS}) + add_simgear_test(sg_pkgutil pkgutil.cxx) endif() if(ENABLE_TESTS) -add_executable(catalog_test CatalogTest.cxx) -target_link_libraries(catalog_test ${TEST_LIBS}) - +add_simgear_autotest(catalog_test CatalogTest.cxx) set_target_properties(catalog_test PROPERTIES COMPILE_DEFINITIONS "SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" ) -add_test(catalog_test ${EXECUTABLE_OUTPUT_PATH}/catalog_test) - endif(ENABLE_TESTS) diff --git a/simgear/props/CMakeLists.txt b/simgear/props/CMakeLists.txt index 3f7e9e3c..92ab7b69 100644 --- a/simgear/props/CMakeLists.txt +++ b/simgear/props/CMakeLists.txt @@ -35,16 +35,8 @@ simgear_component(props props "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) -add_executable(test_props props_test.cxx) -target_link_libraries(test_props ${TEST_LIBS}) -add_test(props ${EXECUTABLE_OUTPUT_PATH}/test_props) - -add_executable(test_propertyObject propertyObject_test.cxx) -target_link_libraries(test_propertyObject ${TEST_LIBS}) -add_test(propertyObject ${EXECUTABLE_OUTPUT_PATH}/test_propertyObject) - -add_executable(test_easing_functions easing_functions_test.cxx) -target_link_libraries(test_easing_functions ${TEST_LIBS}) -add_test(easing_functions ${EXECUTABLE_OUTPUT_PATH}/test_easing_functions) +add_simgear_autotest(test_props props_test.cxx) +add_simgear_autotest(test_propertyObject propertyObject_test.cxx) +add_simgear_autotest(test_easing_functions easing_functions_test.cxx) endif(ENABLE_TESTS) diff --git a/simgear/scene/material/CMakeLists.txt b/simgear/scene/material/CMakeLists.txt index 526fb7ed..b72e4edd 100644 --- a/simgear/scene/material/CMakeLists.txt +++ b/simgear/scene/material/CMakeLists.txt @@ -34,8 +34,7 @@ simgear_scene_component(material scene/material "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) -add_executable(test_parseBlendFunc parseBlendFunc_test.cxx ) -add_test(parseBlendFunc ${EXECUTABLE_OUTPUT_PATH}/test_parseBlendFunc) -target_link_libraries(test_parseBlendFunc ${TEST_LIBS} ${OPENSCENEGRAPH_LIBRARIES}) +add_simgear_autotest(test_parseBlendFunc parseBlendFunc_test.cxx ) +target_link_libraries(test_parseBlendFunc SimGearScene) endif(ENABLE_TESTS) \ No newline at end of file diff --git a/simgear/scene/model/CMakeLists.txt b/simgear/scene/model/CMakeLists.txt index 50227941..9ea57c16 100644 --- a/simgear/scene/model/CMakeLists.txt +++ b/simgear/scene/model/CMakeLists.txt @@ -59,9 +59,5 @@ set(SOURCES simgear_scene_component(model scene/model "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - - add_executable(test_animations animation_test.cxx) - target_link_libraries(test_animations ${TEST_LIBS} ${OPENSCENEGRAPH_LIBRARIES}) - add_test(animations ${EXECUTABLE_OUTPUT_PATH}/test_animations) - + add_simgear_scene_autotest(test_animations animation_test.cxx) endif(ENABLE_TESTS) diff --git a/simgear/scene/tgdb/CMakeLists.txt b/simgear/scene/tgdb/CMakeLists.txt index 590f2270..bbf14e92 100644 --- a/simgear/scene/tgdb/CMakeLists.txt +++ b/simgear/scene/tgdb/CMakeLists.txt @@ -44,9 +44,5 @@ set(SOURCES simgear_scene_component(tgdb scene/tgdb "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - - add_executable(BucketBoxTest BucketBoxTest.cxx) - target_link_libraries(BucketBoxTest ${TEST_LIBS}) - add_test(BucketBoxTest ${EXECUTABLE_OUTPUT_PATH}/BucketBoxTest) - + add_simgear_scene_autotest(BucketBoxTest BucketBoxTest.cxx) endif(ENABLE_TESTS) diff --git a/simgear/scene/util/CMakeLists.txt b/simgear/scene/util/CMakeLists.txt index 7177f87e..09e225c0 100644 --- a/simgear/scene/util/CMakeLists.txt +++ b/simgear/scene/util/CMakeLists.txt @@ -61,8 +61,7 @@ simgear_scene_component(util scene/util "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) -add_executable(test_parse_color parse_color_test.cxx ) -add_test(parse_color ${EXECUTABLE_OUTPUT_PATH}/test_parse_color) -target_link_libraries(test_parse_color ${TEST_LIBS}) +add_simgear_autotest(test_parse_color parse_color_test.cxx ) +target_link_libraries(test_parse_color SimGearScene) endif(ENABLE_TESTS) diff --git a/simgear/sound/CMakeLists.txt b/simgear/sound/CMakeLists.txt index 6695d7b7..b5442963 100644 --- a/simgear/sound/CMakeLists.txt +++ b/simgear/sound/CMakeLists.txt @@ -34,18 +34,19 @@ simgear_scene_component(sound sound "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS AND ENABLE_SOUND) function(create_test TEST_NAME) add_executable(${TEST_NAME} ${TEST_NAME}.cxx) - target_link_libraries(${TEST_NAME} ${SOUND_TEST_LIBS}) + target_link_libraries(${TEST_NAME} SimGearScene ${SOUND_TEST_LIBS}) set_target_properties(${TEST_NAME} PROPERTIES COMPILE_DEFINITIONS "SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" ) + + # for simgear_config.h + target_include_directories(${TEST_NAME} PRIVATE ${PROJECT_BINARY_DIR}/simgear) endfunction() - set( SOUND_TEST_LIBS ${TEST_LIBS} ) - if (USE_AEONWAVE) - set(SOUND_TEST_LIBS ${SOUND_TEST_LIBS} ${AAX_LIBRARY}) + set(SOUND_TEST_LIBS ${AAX_LIBRARY}) create_test(aeonwave_test1) else () - set(SOUND_TEST_LIBS ${SOUND_TEST_LIBS} ${OPENAL_LIBRARY}) + set(SOUND_TEST_LIBS ${OPENAL_LIBRARY}) create_test(openal_test1) endif() diff --git a/simgear/std/CMakeLists.txt b/simgear/std/CMakeLists.txt index ad47054e..9e15ee82 100644 --- a/simgear/std/CMakeLists.txt +++ b/simgear/std/CMakeLists.txt @@ -11,11 +11,6 @@ set(SOURCES simgear_component(std std "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - add_executable(test_integer_sequence integer_sequence_test.cxx) - add_test(integer_sequence ${EXECUTABLE_OUTPUT_PATH}/test_integer_sequence) - target_link_libraries(test_integer_sequence ${TEST_LIBS}) - - add_executable(test_type_traits type_traits_test.cxx) - add_test(type_traits ${EXECUTABLE_OUTPUT_PATH}/test_type_traits) - target_link_libraries(test_type_traits ${TEST_LIBS}) + add_simgear_autotest(test_integer_sequence integer_sequence_test.cxx) + add_simgear_autotest(test_type_traits type_traits_test.cxx) endif() diff --git a/simgear/structure/CMakeLists.txt b/simgear/structure/CMakeLists.txt index 130f1e5e..6f88c17b 100644 --- a/simgear/structure/CMakeLists.txt +++ b/simgear/structure/CMakeLists.txt @@ -45,30 +45,14 @@ set(SOURCES simgear_component(structure structure "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - -add_executable(test_subsystems subsystem_test.cxx) -target_link_libraries(test_subsystems ${TEST_LIBS}) -add_test(subsystems ${EXECUTABLE_OUTPUT_PATH}/test_subsystems) - -add_executable(test_state_machine state_machine_test.cxx) -target_link_libraries(test_state_machine ${TEST_LIBS}) -add_test(state_machine ${EXECUTABLE_OUTPUT_PATH}/test_state_machine) - -add_executable(test_expressions expression_test.cxx) -target_link_libraries(test_expressions ${TEST_LIBS}) -add_test(expressions ${EXECUTABLE_OUTPUT_PATH}/test_expressions) - -add_executable(test_shared_ptr shared_ptr_test.cpp) -target_link_libraries(test_shared_ptr ${TEST_LIBS}) -add_test(shared_ptr ${EXECUTABLE_OUTPUT_PATH}/test_shared_ptr) - -add_executable(test_commands test_commands.cxx) -target_link_libraries(test_commands ${TEST_LIBS}) -add_test(subsystems ${EXECUTABLE_OUTPUT_PATH}/test_commands) - + add_simgear_autotest(test_subsystems subsystem_test.cxx) + add_simgear_autotest(test_state_machine state_machine_test.cxx) + add_simgear_autotest(test_expressions expression_test.cxx) + add_simgear_autotest(test_shared_ptr shared_ptr_test.cpp) + add_simgear_autotest(test_commands test_commands.cxx) endif(ENABLE_TESTS) add_boost_test(function_list SOURCES function_list_test.cxx - LIBRARIES ${TEST_LIBS} + LIBRARIES SimGearCore )