From 47d88bcfa759d18114ad41acb708763680fb1520 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 16 Sep 2012 16:04:08 +0100 Subject: [PATCH] Standardise SimGear libraries, for static vs shared. Always create only two SimGear libraries: SimGearCore and SimGearStatic, regardless of whether we're building static or shared. This requires an updated to FindSimGear.cmake module, for the static configuration. --- CMakeModules/SimGearComponent.cmake | 25 ++++++++----------------- simgear/CMakeLists.txt | 29 +++++++++++++++++++++-------- simgear/bvh/CMakeLists.txt | 8 +------- simgear/environment/CMakeLists.txt | 2 +- simgear/io/CMakeLists.txt | 3 +-- simgear/magvar/CMakeLists.txt | 8 +------- simgear/math/CMakeLists.txt | 12 ++---------- simgear/misc/CMakeLists.txt | 13 +++---------- simgear/props/CMakeLists.txt | 12 ++---------- simgear/scene/tgdb/CMakeLists.txt | 10 +--------- simgear/scene/tsync/CMakeLists.txt | 5 ----- simgear/sound/CMakeLists.txt | 2 +- 12 files changed, 42 insertions(+), 87 deletions(-) diff --git a/CMakeModules/SimGearComponent.cmake b/CMakeModules/SimGearComponent.cmake index 1c11b855..294a53a2 100644 --- a/CMakeModules/SimGearComponent.cmake +++ b/CMakeModules/SimGearComponent.cmake @@ -1,23 +1,14 @@ macro(simgear_component_common name includePath sourcesList sources headers) - if (SIMGEAR_SHARED) + foreach(s ${sources}) + set_property(GLOBAL + APPEND PROPERTY ${sourcesList} "${CMAKE_CURRENT_SOURCE_DIR}/${s}") + endforeach() - foreach(s ${sources}) - set_property(GLOBAL - APPEND PROPERTY ${sourcesList} "${CMAKE_CURRENT_SOURCE_DIR}/${s}") - endforeach() - - foreach(h ${headers}) - set_property(GLOBAL - APPEND PROPERTY PUBLIC_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${h}") - endforeach() - - else() - set(libName "sg${name}") - add_library(${libName} STATIC ${sources} ${headers}) - - install (TARGETS ${libName} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() + foreach(h ${headers}) + set_property(GLOBAL + APPEND PROPERTY PUBLIC_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${h}") + endforeach() install (FILES ${headers} DESTINATION include/simgear/${includePath}) endmacro() diff --git a/simgear/CMakeLists.txt b/simgear/CMakeLists.txt index 84c1d22b..2ec11752 100644 --- a/simgear/CMakeLists.txt +++ b/simgear/CMakeLists.txt @@ -39,12 +39,17 @@ endif(ENABLE_RTI) set(HEADERS compiler.h constants.h sg_inlines.h ${PROJECT_BINARY_DIR}/simgear/version.h) 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) + +if(LIBSVN_FOUND) + add_definitions(${APR_CFLAGS}) + include_directories(${LIBSVN_INCLUDE_DIR}) +endif() + if(SIMGEAR_SHARED) message(STATUS "Library building mode: SHARED LIBRARIES") - get_property(coreSources GLOBAL PROPERTY CORE_SOURCES) - get_property(sceneSources GLOBAL PROPERTY SCENE_SOURCES) - get_property(publicHeaders GLOBAL PROPERTY PUBLIC_HEADERS) - add_library(SimGearCore SHARED ${coreSources}) # set_property(TARGET SimGearCore PROPERTY FRAMEWORK 1) @@ -56,11 +61,8 @@ if(SIMGEAR_SHARED) set_property(TARGET SimGearCore PROPERTY SOVERSION ${SIMGEAR_SOVERSION}) target_link_libraries(SimGearCore ${ZLIB_LIBRARY} ${RT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) - install(TARGETS SimGearCore LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) if(LIBSVN_FOUND) - add_definitions(${APR_CFLAGS}) - include_directories(${LIBSVN_INCLUDE_DIR}) target_link_libraries(SimGearCore ${LIBSVN_LIBRARIES}) endif(LIBSVN_FOUND) @@ -82,8 +84,19 @@ if(SIMGEAR_SHARED) install(TARGETS SimGearScene LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() - + + install(TARGETS SimGearCore LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) else() message(STATUS "Library building mode: STATIC LIBRARIES") + + add_library(SimGearCore STATIC ${coreSources}) + install(TARGETS SimGearCore ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + if(NOT SIMGEAR_HEADLESS) + add_library(SimGearScene STATIC ${sceneSources}) + install(TARGETS SimGearScene ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif(NOT SIMGEAR_HEADLESS) endif(SIMGEAR_SHARED) + + diff --git a/simgear/bvh/CMakeLists.txt b/simgear/bvh/CMakeLists.txt index b5b47708..6bb3c551 100644 --- a/simgear/bvh/CMakeLists.txt +++ b/simgear/bvh/CMakeLists.txt @@ -46,13 +46,7 @@ set(SOURCES simgear_component(bvh bvh "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - if (SIMGEAR_SHARED) - set(TEST_LIBS SimGearCore) - else() - set(TEST_LIBS sgbvh sgmath sgstructure sgdebug) - endif() - add_executable(bvhtest bvhtest.cxx) - target_link_libraries(bvhtest ${TEST_LIBS}) + target_link_libraries(bvhtest SimGearCore) add_test(bvhtest ${EXECUTABLE_OUTPUT_PATH}/bvhtest) endif(ENABLE_TESTS) diff --git a/simgear/environment/CMakeLists.txt b/simgear/environment/CMakeLists.txt index 8718f9a3..d5255b04 100644 --- a/simgear/environment/CMakeLists.txt +++ b/simgear/environment/CMakeLists.txt @@ -13,7 +13,7 @@ if (SIMGEAR_SHARED) target_link_libraries(test_metar SimGearScene) else() target_link_libraries(test_metar - sgenvironment sgstructure sgmisc sgdebug + SimGearScene SimGearCore ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARY} ${RT_LIBRARY}) diff --git a/simgear/io/CMakeLists.txt b/simgear/io/CMakeLists.txt index f665ebe9..17483d63 100644 --- a/simgear/io/CMakeLists.txt +++ b/simgear/io/CMakeLists.txt @@ -41,8 +41,7 @@ if(ENABLE_TESTS) if (SIMGEAR_SHARED) set(TEST_LIBS SimGearCore) else() - set(TEST_LIBS - sgio sgbucket sgstructure sgthreads sgtiming sgmisc sgdebug + set(TEST_LIBS SimGearCore ${CMAKE_THREAD_LIBS_INIT} ${WINSOCK_LIBRARY} ${ZLIB_LIBRARY} diff --git a/simgear/magvar/CMakeLists.txt b/simgear/magvar/CMakeLists.txt index 2e6cd342..4c26eb8d 100644 --- a/simgear/magvar/CMakeLists.txt +++ b/simgear/magvar/CMakeLists.txt @@ -7,12 +7,6 @@ set(SOURCES magvar.cxx coremag.cxx) simgear_component(magvar magvar "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) -add_executable(test_magvar testmagvar.cxx ) - -if (SIMGEAR_SHARED) + add_executable(test_magvar testmagvar.cxx ) target_link_libraries(test_magvar SimGearCore) -else() - target_link_libraries(test_magvar sgmagvar) -endif() - endif(ENABLE_TESTS) diff --git a/simgear/math/CMakeLists.txt b/simgear/math/CMakeLists.txt index f66ec15a..e0d3e627 100644 --- a/simgear/math/CMakeLists.txt +++ b/simgear/math/CMakeLists.txt @@ -42,19 +42,11 @@ set(SOURCES simgear_component(math math "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - -if (SIMGEAR_SHARED) - set(TEST_LIBS SimGearCore) -else() - set(TEST_LIBS sgmath sgstructure sgdebug) -endif() - - add_executable(math_test SGMathTest.cxx) -target_link_libraries(math_test ${TEST_LIBS}) +target_link_libraries(math_test SimGearCore) add_test(math ${EXECUTABLE_OUTPUT_PATH}/math_test) add_executable(geometry_test SGGeometryTest.cxx) -target_link_libraries(geometry_test ${TEST_LIBS}) +target_link_libraries(geometry_test SimGearCore) add_test(geometry ${EXECUTABLE_OUTPUT_PATH}/geometry_test) endif(ENABLE_TESTS) diff --git a/simgear/misc/CMakeLists.txt b/simgear/misc/CMakeLists.txt index c4ae64df..d07b6718 100644 --- a/simgear/misc/CMakeLists.txt +++ b/simgear/misc/CMakeLists.txt @@ -31,22 +31,15 @@ set(SOURCES simgear_component(misc misc "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - -if (SIMGEAR_SHARED) - set(TEST_LIBS SimGearCore) -else() - set(TEST_LIBS sgmisc sgdebug) -endif() - 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}) +target_link_libraries(test_tabbed_values SimGearCore) add_executable(test_strings strutils_test.cxx ) add_test(test_strings ${EXECUTABLE_OUTPUT_PATH}/test_strings) -target_link_libraries(test_strings ${TEST_LIBS}) +target_link_libraries(test_strings SimGearCore) add_executable(test_path path_test.cxx ) add_test(test_path ${EXECUTABLE_OUTPUT_PATH}/test_path) -target_link_libraries(test_path ${TEST_LIBS}) +target_link_libraries(test_path SimGearCore) endif(ENABLE_TESTS) diff --git a/simgear/props/CMakeLists.txt b/simgear/props/CMakeLists.txt index a11e703e..7657b445 100644 --- a/simgear/props/CMakeLists.txt +++ b/simgear/props/CMakeLists.txt @@ -24,19 +24,11 @@ set(SOURCES simgear_component(props props "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - -if (SIMGEAR_SHARED) - set(TEST_LIBS SimGearCore) -else() - set(TEST_LIBS sgprops sgxml sgstructure sgmisc sgdebug) -endif() - - add_executable(test_props props_test.cxx) -target_link_libraries(test_props ${TEST_LIBS}) +target_link_libraries(test_props SimGearCore) add_test(test_props ${EXECUTABLE_OUTPUT_PATH}/test_props) add_executable(test_propertyObject propertyObject_test.cxx) -target_link_libraries(test_propertyObject ${TEST_LIBS}) +target_link_libraries(test_propertyObject SimGearCore) add_test(test_propertyObject ${EXECUTABLE_OUTPUT_PATH}/test_propertyObject) endif(ENABLE_TESTS) diff --git a/simgear/scene/tgdb/CMakeLists.txt b/simgear/scene/tgdb/CMakeLists.txt index ff9dd97f..caec45ac 100644 --- a/simgear/scene/tgdb/CMakeLists.txt +++ b/simgear/scene/tgdb/CMakeLists.txt @@ -41,16 +41,8 @@ set(SOURCES simgear_scene_component(tgdb scene/tgdb "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) - - if (SIMGEAR_SHARED) - set(TEST_LIBS SimGearCore) - else() - set(TEST_LIBS sgbucket sgmisc sgmath sgdebug) - endif() - - add_executable(BucketBoxTest BucketBoxTest.cxx) - target_link_libraries(BucketBoxTest ${TEST_LIBS}) + target_link_libraries(BucketBoxTest SimGearCore) add_test(BucketBoxTest ${EXECUTABLE_OUTPUT_PATH}/BucketBoxTest) endif(ENABLE_TESTS) diff --git a/simgear/scene/tsync/CMakeLists.txt b/simgear/scene/tsync/CMakeLists.txt index fceba2de..238e0b90 100644 --- a/simgear/scene/tsync/CMakeLists.txt +++ b/simgear/scene/tsync/CMakeLists.txt @@ -8,9 +8,4 @@ set(SOURCES terrasync.cxx ) -if(LIBSVN_FOUND) - add_definitions(${APR_CFLAGS}) - include_directories(${LIBSVN_INCLUDE_DIR}) -endif() - simgear_component(tsync scene/tsync "${SOURCES}" "${HEADERS}") diff --git a/simgear/sound/CMakeLists.txt b/simgear/sound/CMakeLists.txt index 6161b33b..51d365e3 100644 --- a/simgear/sound/CMakeLists.txt +++ b/simgear/sound/CMakeLists.txt @@ -26,7 +26,7 @@ if (SIMGEAR_SHARED) set(SOUND_TEST_LIBS SimGearScene) else() set(SOUND_TEST_LIBS - sgsound sgio sgmath sgstructure sgthreads sgtiming sgmisc sgdebug + SimGearScene SimGearCore ${CMAKE_THREAD_LIBS_INIT} ${RT_LIBRARY} ${OPENAL_LIBRARY} -- 2.39.5