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.
This commit is contained in:
James Turner 2012-09-16 16:04:08 +01:00
parent e4dacaf0d2
commit 47d88bcfa7
12 changed files with 42 additions and 87 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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)

View File

@ -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})

View File

@ -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}

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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}")

View File

@ -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}