diff --git a/CMakeModules/SimGearComponent.cmake b/CMakeModules/SimGearComponent.cmake index c05d3241..5628e5a1 100644 --- a/CMakeModules/SimGearComponent.cmake +++ b/CMakeModules/SimGearComponent.cmake @@ -1,10 +1,10 @@ -macro(simgear_component name includePath sources headers) - +macro(simgear_component_common name includePath sourcesList sources headers) if (SIMGEAR_SHARED) + foreach(s ${sources}) set_property(GLOBAL - APPEND PROPERTY ALL_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/${s}") + APPEND PROPERTY ${sourcesList} "${CMAKE_CURRENT_SOURCE_DIR}/${s}") endforeach() foreach(h ${headers}) @@ -16,8 +16,15 @@ macro(simgear_component name includePath sources headers) set(libName "sg${name}") add_library(${libName} STATIC ${sources} ${headers}) - install (TARGETS ${libName} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install (TARGETS ${libName} ARCHIVE DESTINATION lib${LIB_SUFFIX}) install (FILES ${headers} DESTINATION include/simgear/${includePath}) endif() - endmacro() + +function(simgear_component name includePath sources headers) + simgear_component_common(${name} ${includePath} CORE_SOURCES "${sources}" "${headers}") +endfunction() + +function(simgear_scene_component name includePath sources headers) + simgear_component_common(${name} ${includePath} SCENE_SOURCES "${sources}" "${headers}") +endfunction() diff --git a/simgear/CMakeLists.txt b/simgear/CMakeLists.txt index e3ff31ef..4f1de810 100644 --- a/simgear/CMakeLists.txt +++ b/simgear/CMakeLists.txt @@ -41,21 +41,43 @@ install (FILES ${HEADERS} DESTINATION include/simgear/) if(SIMGEAR_SHARED) message(STATUS "building shared library") - get_property(allSources GLOBAL PROPERTY ALL_SOURCES) + get_property(coreSources GLOBAL PROPERTY CORE_SOURCES) + get_property(sceneSources GLOBAL PROPERTY SCENE_SOURCES) get_property(publicHeaders GLOBAL PROPERTY PUBLIC_HEADERS) - add_library(SimGear SHARED ${allSources}) - set_property(TARGET SimGear PROPERTY FRAMEWORK 1) - message(STATUS "public header: ${publicHeaders}") + add_library(SimGear SHARED ${coreSources}) + # set_property(TARGET SimGear PROPERTY FRAMEWORK 1) + # message(STATUS "public header: ${publicHeaders}") set_property(TARGET SimGear PROPERTY PUBLIC_HEADER "${publicHeaders}") set_property(TARGET SimGear PROPERTY LINKER_LANGUAGE CXX) - - target_link_libraries(SimGear ${ZLIB_LIBRARY} - ${OPENSCENEGRAPH_LIBRARIES} - ${OPENAL_LIBRARY} ${ALUT_LIBRARY} - ${OPENGL_LIBRARY}) - + + target_link_libraries(SimGear ${ZLIB_LIBRARY}) install(TARGETS SimGear LIBRARY DESTINATION lib${LIB_SUFFIX} - PUBLIC_HEADER DESTINATION include/simgear) + PUBLIC_HEADER DESTINATION include/simgear) + + if(NOT SIMGEAR_HEADLESS) + if(LIBSVN_FOUND) + add_definitions(${APR_CFLAGS}) + + IF(APPLE) + set_property(SOURCE scene/tsync/terrasync.cxx PROPERTY COMPILE_FLAGS "-iwithsysroot ${LIBSVN_INCLUDE_DIR}") + ELSE() + include_directories(${LIBSVN_INCLUDE_DIR}) + ENDIF(APPLE) + endif(LIBSVN_FOUND) + + add_library(SimGearScene SHARED ${sceneSources}) + # set_property(TARGET SimGearScene PROPERTY FRAMEWORK 1) + # set_property(TARGET SimGearScene PROPERTY PUBLIC_HEADER "${publicHeaders}") + set_property(TARGET SimGearScene PROPERTY LINKER_LANGUAGE CXX) + + target_link_libraries(SimGearScene ${ZLIB_LIBRARY} + ${OPENSCENEGRAPH_LIBRARIES} + ${OPENAL_LIBRARY} ${ALUT_LIBRARY} + ${OPENGL_LIBRARY}) + + install(TARGETS SimGearScene LIBRARY DESTINATION lib${LIB_SUFFIX}) + endif() + endif(SIMGEAR_SHARED) diff --git a/simgear/environment/CMakeLists.txt b/simgear/environment/CMakeLists.txt index ae641d18..8718f9a3 100644 --- a/simgear/environment/CMakeLists.txt +++ b/simgear/environment/CMakeLists.txt @@ -4,15 +4,20 @@ include (SimGearComponent) set(HEADERS metar.hxx precipitation.hxx) set(SOURCES metar.cxx precipitation.cxx) -simgear_component(environment environment "${SOURCES}" "${HEADERS}") +simgear_scene_component(environment environment "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) add_executable(test_metar test_metar.cxx) -target_link_libraries(test_metar - sgenvironment sgstructure sgmisc sgdebug - ${CMAKE_THREAD_LIBS_INIT} - ${ZLIB_LIBRARY} - ${RT_LIBRARY}) - + +if (SIMGEAR_SHARED) + target_link_libraries(test_metar SimGearScene) +else() + target_link_libraries(test_metar + sgenvironment sgstructure sgmisc sgdebug + ${CMAKE_THREAD_LIBS_INIT} + ${ZLIB_LIBRARY} + ${RT_LIBRARY}) +endif() + add_test(metar ${EXECUTABLE_OUTPUT_PATH}/test_metar) endif(ENABLE_TESTS) diff --git a/simgear/scene/bvh/CMakeLists.txt b/simgear/scene/bvh/CMakeLists.txt index ba0cfd73..230a6bc6 100644 --- a/simgear/scene/bvh/CMakeLists.txt +++ b/simgear/scene/bvh/CMakeLists.txt @@ -36,4 +36,4 @@ set(SOURCES BVHTransform.cxx ) -simgear_component(bvh scene/bvh "${SOURCES}" "${HEADERS}") +simgear_scene_component(bvh scene/bvh "${SOURCES}" "${HEADERS}") diff --git a/simgear/scene/material/CMakeLists.txt b/simgear/scene/material/CMakeLists.txt index 787202a5..3527a142 100644 --- a/simgear/scene/material/CMakeLists.txt +++ b/simgear/scene/material/CMakeLists.txt @@ -31,5 +31,5 @@ set(SOURCES mipmap.cxx ) -simgear_component(material scene/material "${SOURCES}" "${HEADERS}") +simgear_scene_component(material scene/material "${SOURCES}" "${HEADERS}") diff --git a/simgear/scene/model/CMakeLists.txt b/simgear/scene/model/CMakeLists.txt index 8977a7f9..333f7f46 100644 --- a/simgear/scene/model/CMakeLists.txt +++ b/simgear/scene/model/CMakeLists.txt @@ -44,4 +44,4 @@ set(SOURCES shadanim.cxx ) -simgear_component(model scene/model "${SOURCES}" "${HEADERS}") +simgear_scene_component(model scene/model "${SOURCES}" "${HEADERS}") diff --git a/simgear/scene/sky/CMakeLists.txt b/simgear/scene/sky/CMakeLists.txt index 7ed001d1..b71c5cba 100644 --- a/simgear/scene/sky/CMakeLists.txt +++ b/simgear/scene/sky/CMakeLists.txt @@ -26,4 +26,4 @@ set(SOURCES stars.cxx ) -simgear_component(sky scene/sky "${SOURCES}" "${HEADERS}") +simgear_scene_component(sky scene/sky "${SOURCES}" "${HEADERS}") diff --git a/simgear/scene/tgdb/CMakeLists.txt b/simgear/scene/tgdb/CMakeLists.txt index 635eb954..59d096ce 100644 --- a/simgear/scene/tgdb/CMakeLists.txt +++ b/simgear/scene/tgdb/CMakeLists.txt @@ -38,4 +38,4 @@ set(SOURCES userdata.cxx ) -simgear_component(tgdb scene/tgdb "${SOURCES}" "${HEADERS}") +simgear_scene_component(tgdb scene/tgdb "${SOURCES}" "${HEADERS}") diff --git a/simgear/scene/tsync/CMakeLists.txt b/simgear/scene/tsync/CMakeLists.txt index 5c0be429..bc6b62a5 100644 --- a/simgear/scene/tsync/CMakeLists.txt +++ b/simgear/scene/tsync/CMakeLists.txt @@ -19,4 +19,4 @@ if(LIBSVN_FOUND) endif() -simgear_component(tsync scene/tsync "${SOURCES}" "${HEADERS}") +simgear_scene_component(tsync scene/tsync "${SOURCES}" "${HEADERS}") diff --git a/simgear/scene/util/CMakeLists.txt b/simgear/scene/util/CMakeLists.txt index 6f9193a5..d312dfae 100644 --- a/simgear/scene/util/CMakeLists.txt +++ b/simgear/scene/util/CMakeLists.txt @@ -37,4 +37,4 @@ set(SOURCES UpdateOnceCallback.cxx ) -simgear_component(util scene/util "${SOURCES}" "${HEADERS}") +simgear_scene_component(util scene/util "${SOURCES}" "${HEADERS}") diff --git a/simgear/screen/CMakeLists.txt b/simgear/screen/CMakeLists.txt index 17780af7..029fcf3b 100644 --- a/simgear/screen/CMakeLists.txt +++ b/simgear/screen/CMakeLists.txt @@ -20,4 +20,4 @@ if(JPEG_FACTORY) endif() -simgear_component(screen screen "${SOURCES}" "${HEADERS}") \ No newline at end of file +simgear_scene_component(screen screen "${SOURCES}" "${HEADERS}") \ No newline at end of file diff --git a/simgear/sound/CMakeLists.txt b/simgear/sound/CMakeLists.txt index 69e1acd2..6290f60f 100644 --- a/simgear/sound/CMakeLists.txt +++ b/simgear/sound/CMakeLists.txt @@ -16,14 +16,19 @@ set(SOURCES xmlsound.cxx ) -simgear_component(sound sound "${SOURCES}" "${HEADERS}") +simgear_scene_component(sound sound "${SOURCES}" "${HEADERS}") if(ENABLE_TESTS) -set(SOUND_TEST_LIBS - sgsound sgio sgmath sgstructure sgthreads sgtiming sgmisc sgdebug - ${CMAKE_THREAD_LIBS_INIT} - ${RT_LIBRARY} - ${ALUT_LIBRARY} ${OPENAL_LIBRARY}) + +if (SIMGEAR_SHARED) + set(SOUND_TEST_LIBS SimGearScene) +else() + set(SOUND_TEST_LIBS + sgsound sgio sgmath sgstructure sgthreads sgtiming sgmisc sgdebug + ${CMAKE_THREAD_LIBS_INIT} + ${RT_LIBRARY} + ${ALUT_LIBRARY} ${OPENAL_LIBRARY}) +endif() function(create_test TEST_NAME) add_executable(${TEST_NAME} ${TEST_NAME}.cxx)