From a5a8090d52fafff6f0cd5b09bcec4f92cdd2ed19 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 8 Sep 2011 13:59:40 +0100 Subject: [PATCH] Cmake: Split simgear libraries into core and scene (only scene uses OSG). Fix linkage issues, and make helper binaries (yasim, terrasync) link against less stuff. --- CMakeLists.txt | 6 ++++++ CMakeModules/FindSimGear.cmake | 35 +++++++++++++++++++--------------- src/FDM/YASim/CMakeLists.txt | 2 +- src/Input/CMakeLists.txt | 4 ++-- utils/GPSsmooth/CMakeLists.txt | 24 +++-------------------- utils/TerraSync/CMakeLists.txt | 2 +- utils/fgpanel/CMakeLists.txt | 2 +- 7 files changed, 34 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 581cb638f..54977bc47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,12 @@ file(READ version versionFile) string(STRIP ${versionFile} FLIGHTGEAR_VERSION) #packaging + +# 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 ${FLIGHTGEAR_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}) SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING") SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README") diff --git a/CMakeModules/FindSimGear.cmake b/CMakeModules/FindSimGear.cmake index c7dc1b3e2..f568d4b01 100644 --- a/CMakeModules/FindSimGear.cmake +++ b/CMakeModules/FindSimGear.cmake @@ -105,29 +105,19 @@ endmacro() if(${SIMGEAR_LIBRARIES} STREQUAL "SIMGEAR_LIBRARIES-NOTFOUND") set(SIMGEAR_LIBRARIES "") # clear value - - if(NOT MSVC) - # Olaf indicates that linking the threads libs causes failures - # on MSVC builds - set(thread_lib threads) - endif(NOT MSVC) - + set(SIMGEAR_CORE_LIBRARIES "") # clear value + # note the order here affects the order Simgear libraries are # linked in, and hence ability to link when using a traditional # linker such as GNU ld on Linux set(comps - ephem tsync environment nasal - sky - material - tgdb - model - screen bucket bvh - util route + util + route timing io serial @@ -136,14 +126,29 @@ if(${SIMGEAR_LIBRARIES} STREQUAL "SIMGEAR_LIBRARIES-NOTFOUND") props xml misc - ${thread_lib} + threads debug magvar math) + set(scene_comps + ephem + sky + material + tgdb + model + screen) + foreach(component ${comps}) + find_sg_component(${component} SIMGEAR_CORE_LIBRARIES) + endforeach() + + foreach(component ${scene_comps}) find_sg_component(${component} SIMGEAR_LIBRARIES) endforeach() + + # again link order matters - scene libraires depend on core ones + list(APPEND SIMGEAR_LIBRARIES ${SIMGEAR_CORE_LIBRARIES}) endif() # now we've found SimGear, check its version diff --git a/src/FDM/YASim/CMakeLists.txt b/src/FDM/YASim/CMakeLists.txt index 2118993a5..1f91a8ed7 100644 --- a/src/FDM/YASim/CMakeLists.txt +++ b/src/FDM/YASim/CMakeLists.txt @@ -37,7 +37,7 @@ add_executable(yasim yasim-test.cpp) target_link_libraries(yasim fgYASim - ${SIMGEAR_LIBRARIES} + ${SIMGEAR_CORE_LIBRARIES} ${ZLIB_LIBRARIES}) install(TARGETS yasim RUNTIME DESTINATION bin) diff --git a/src/Input/CMakeLists.txt b/src/Input/CMakeLists.txt index 1a2df52d2..27634bc4e 100644 --- a/src/Input/CMakeLists.txt +++ b/src/Input/CMakeLists.txt @@ -36,15 +36,15 @@ if(WIN32) endif(WIN32) target_link_libraries(fgjs + ${SIMGEAR_CORE_LIBRARIES} ${SOCKETS_LIBRARY} - ${SIMGEAR_LIBRARIES} ${PLIB_LIBRARIES} ${ZLIB_LIBRARY}) add_executable(js_demo js_demo.cxx) target_link_libraries(js_demo - ${SIMGEAR_LIBRARIES} + ${SIMGEAR_CORE_LIBRARIES} ${PLIB_LIBRARIES} ${ZLIB_LIBRARY}) diff --git a/utils/GPSsmooth/CMakeLists.txt b/utils/GPSsmooth/CMakeLists.txt index 5a586d0c4..5e90617c6 100644 --- a/utils/GPSsmooth/CMakeLists.txt +++ b/utils/GPSsmooth/CMakeLists.txt @@ -4,12 +4,7 @@ add_executable(MIDGsmooth MIDG-II.cxx MIDG_main.cxx) add_executable(UGsmooth UGear.cxx UGear_command.cxx UGear_main.cxx UGear_telnet.cxx) target_link_libraries(GPSsmooth - ${SIMGEAR_IO_LIBRARY} - ${SIMGEAR_MISC_LIBRARY} - ${SIMGEAR_STRUCTURE_LIBRARY} - ${SIMGEAR_THREADS_LIBRARY} - ${SIMGEAR_TIMING_LIBRARY} - ${SIMGEAR_DEBUG_LIBRARY} + ${SIMGEAR_CORE_LIBRARIES} ${PLIB_SG_LIBRARY} ${PLIB_UL_LIBRARY} ${ZLIB_LIBRARIES} @@ -20,13 +15,7 @@ target_link_libraries(GPSsmooth ) target_link_libraries(MIDGsmooth - ${SIMGEAR_IO_LIBRARY} - ${SIMGEAR_MATH_LIBRARY} - ${SIMGEAR_SERIAL_LIBRARY} - ${SIMGEAR_STRUCTURE_LIBRARY} - ${SIMGEAR_THREADS_LIBRARY} - ${SIMGEAR_TIMING_LIBRARY} - ${SIMGEAR_DEBUG_LIBRARY} + ${SIMGEAR_CORE_LIBRARIES} ${PLIB_SG_LIBRARY} ${PLIB_UL_LIBRARY} ${WINMM_LIBRARY} @@ -35,14 +24,7 @@ target_link_libraries(MIDGsmooth ) target_link_libraries(UGsmooth - ${SIMGEAR_DEBUG_LIBRARY} - ${SIMGEAR_IO_LIBRARY} - ${SIMGEAR_MATH_LIBRARY} - ${SIMGEAR_MISC_LIBRARY} - ${SIMGEAR_SERIAL_LIBRARY} - ${SIMGEAR_STRUCTURE_LIBRARY} - ${SIMGEAR_THREADS_LIBRARY} - ${SIMGEAR_TIMING_LIBRARY} + ${SIMGEAR_CORE_LIBRARIES} ${PLIB_SG_LIBRARY} ${PLIB_UL_LIBRARY} ${WINMM_LIBRARY} diff --git a/utils/TerraSync/CMakeLists.txt b/utils/TerraSync/CMakeLists.txt index 0fc13133e..6c81e0f24 100644 --- a/utils/TerraSync/CMakeLists.txt +++ b/utils/TerraSync/CMakeLists.txt @@ -3,7 +3,7 @@ add_executable(terrasync terrasync.cxx) target_link_libraries(terrasync - ${SIMGEAR_LIBRARIES} + ${SIMGEAR_CORE_LIBRARIES} ${ZLIB_LIBRARIES} ${WINSOCK_LIBRARY} ${RT_LIBRARY}) diff --git a/utils/fgpanel/CMakeLists.txt b/utils/fgpanel/CMakeLists.txt index 9feca02e6..3307beb77 100644 --- a/utils/fgpanel/CMakeLists.txt +++ b/utils/fgpanel/CMakeLists.txt @@ -18,7 +18,7 @@ if(GLUT_FOUND) target_link_libraries(fgpanel ${PNG_LIBRARIES} ${GLUT_LIBRARIES} - ${SIMGEAR_LIBRARIES} + ${SIMGEAR_CORE_LIBRARIES} ${OPENGL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLIB_LIBRARIES}