Build system tweaks to support SIMGEAR_SHARED building two libraries. Work in progress, does not link yet.

This commit is contained in:
James Turner 2011-11-28 22:43:57 +00:00
parent 7a52c2fa71
commit 4b02335637
12 changed files with 76 additions and 37 deletions

View File

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

View File

@ -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}
target_link_libraries(SimGear ${ZLIB_LIBRARY})
install(TARGETS SimGear LIBRARY DESTINATION lib${LIB_SUFFIX}
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 SimGear LIBRARY DESTINATION lib${LIB_SUFFIX}
PUBLIC_HEADER DESTINATION include/simgear)
install(TARGETS SimGearScene LIBRARY DESTINATION lib${LIB_SUFFIX})
endif()
endif(SIMGEAR_SHARED)

View File

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

View File

@ -36,4 +36,4 @@ set(SOURCES
BVHTransform.cxx
)
simgear_component(bvh scene/bvh "${SOURCES}" "${HEADERS}")
simgear_scene_component(bvh scene/bvh "${SOURCES}" "${HEADERS}")

View File

@ -31,5 +31,5 @@ set(SOURCES
mipmap.cxx
)
simgear_component(material scene/material "${SOURCES}" "${HEADERS}")
simgear_scene_component(material scene/material "${SOURCES}" "${HEADERS}")

View File

@ -44,4 +44,4 @@ set(SOURCES
shadanim.cxx
)
simgear_component(model scene/model "${SOURCES}" "${HEADERS}")
simgear_scene_component(model scene/model "${SOURCES}" "${HEADERS}")

View File

@ -26,4 +26,4 @@ set(SOURCES
stars.cxx
)
simgear_component(sky scene/sky "${SOURCES}" "${HEADERS}")
simgear_scene_component(sky scene/sky "${SOURCES}" "${HEADERS}")

View File

@ -38,4 +38,4 @@ set(SOURCES
userdata.cxx
)
simgear_component(tgdb scene/tgdb "${SOURCES}" "${HEADERS}")
simgear_scene_component(tgdb scene/tgdb "${SOURCES}" "${HEADERS}")

View File

@ -19,4 +19,4 @@ if(LIBSVN_FOUND)
endif()
simgear_component(tsync scene/tsync "${SOURCES}" "${HEADERS}")
simgear_scene_component(tsync scene/tsync "${SOURCES}" "${HEADERS}")

View File

@ -37,4 +37,4 @@ set(SOURCES
UpdateOnceCallback.cxx
)
simgear_component(util scene/util "${SOURCES}" "${HEADERS}")
simgear_scene_component(util scene/util "${SOURCES}" "${HEADERS}")

View File

@ -20,4 +20,4 @@ if(JPEG_FACTORY)
endif()
simgear_component(screen screen "${SOURCES}" "${HEADERS}")
simgear_scene_component(screen screen "${SOURCES}" "${HEADERS}")

View File

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