From 08e5e56b364b72c39ae6832d2ba1db1965e2d648 Mon Sep 17 00:00:00 2001 From: Glenn Waldron Date: Fri, 17 May 2024 10:05:00 -0400 Subject: [PATCH] Adapt lib/bin destinations for linux; add back the soversion postfixes --- CMakeLists.txt | 12 ++++++++++- cmake/oe_unix.cmake | 16 +++++++++++---- cmake/osgearth-macros.cmake | 40 +++++++++++++++++++------------------ 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23e205ee32..4650207b89 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,13 @@ set(OSGEARTH_EMBEDDED_THIRD_PARTY_DIR ${PROJECT_SOURCE_DIR}/src/third_party) # Platform-specific settings ............................................ +# Default installation folders. The platform-specific includes will +# override these values as necessary. +set(INSTALL_RUNTIME_FOLDER "bin") # executables +set(INSTALL_LIBRARY_FOLDER "bin") # .dll/.so +set(INSTALL_ARCHIVE_FOLDER "lib") # .lib/.a +set(INSTALL_PLUGINS_FOLDER "bin") # parent folder of OSG plugins folder + include(oe_ios) include(oe_osx) include(oe_unix) @@ -156,6 +163,9 @@ else() endif() +# Whether to append SOVERSIONs to libraries (unix) +option(OSGEARTH_SONAMES "ON to append so-version numbers to libraries" ON) + # Source code ............................................................ add_subdirectory(src) @@ -173,7 +183,7 @@ osgearth_install_package_config_files( osgEarth ${OSGEARTH_VERSION} ${CMAKE_INSTALL_PREFIX}/include - ${CMAKE_INSTALL_PREFIX}/lib) + ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBRARY_FOLDER}) diff --git a/cmake/oe_unix.cmake b/cmake/oe_unix.cmake index 2acbca2525..72d64a1926 100644 --- a/cmake/oe_unix.cmake +++ b/cmake/oe_unix.cmake @@ -1,11 +1,19 @@ # UNIX-only stuff -IF(UNIX AND NOT ANDROID) +if(UNIX AND NOT ANDROID) + # Not sure what this will do on Cygwin and Msys # Also, remember OS X X11 is a user installed option so it may not exist. - FIND_PACKAGE(X11) + find_package(X11) + # Some Unicies need explicit linkage to the Math library or the build fails. - FIND_LIBRARY(MATH_LIBRARY m) + find_library(MATH_LIBRARY m) + # for ptheads in linux find_package(Threads REQUIRED) -ENDIF(UNIX AND NOT ANDROID) + + # add 64 to the lib prefix. + set(INSTALL_LIBRARY_FOLDER "lib64") + set(INSTALL_PLUGINS_FOLDER "lib64") + +endif(UNIX AND NOT ANDROID) diff --git a/cmake/osgearth-macros.cmake b/cmake/osgearth-macros.cmake index 8ca36f87bd..dfe7aadaeb 100644 --- a/cmake/osgearth-macros.cmake +++ b/cmake/osgearth-macros.cmake @@ -120,6 +120,11 @@ macro(add_osgearth_plugin) else() message(FATAL_ERROR "add_library_as_plugin: name '${MY_TARGET}' must begin with 'osgdb_' or 'osgdb_osgearth_'") endif() + + # soversions - append SO version to shared object files on unix (e.g., osgearth.so.123) + if (OSGEARTH_SONAMES) + set_target_properties(${MY_TARGET} PROPERTIES VERSION ${OSGEARTH_VERSION} SOVERSION ${OSGEARTH_SOVERSION}) + endif() # install the shader source files, if requested: if(OSGEARTH_INSTALL_SHADERS) @@ -133,9 +138,9 @@ macro(add_osgearth_plugin) # install the dynamic libraries. install(TARGETS ${MY_TARGET} - RUNTIME DESTINATION bin - ARCHIVE DESTINATION lib/${OSG_PLUGINS} - LIBRARY DESTINATION bin/${OSG_PLUGINS}) + # RUNTIME DESTINATION ${INSTALL_RUNTIME_FOLDER} + # ARCHIVE DESTINATION ${INSTALL_ARCHIVE_FOLDER}/${OSG_PLUGINS} + LIBRARY DESTINATION ${INSTALL_PLUGINS_FOLDER}/${OSG_PLUGINS}) # organize the files in the IDE source_group( "Header Files" FILES ${ALL_HEADERS} ) @@ -239,7 +244,9 @@ macro(add_osgearth_app) set_target_properties(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE ${IPHONE_ENABLE_BITCODE}) endif() - install(TARGETS ${MY_TARGET} RUNTIME DESTINATION bin) + install( + TARGETS ${MY_TARGET} + RUNTIME DESTINATION ${INSTALL_RUNTIME_FOLDER}) if(NOT MY_FOLDER) set(MY_FOLDER "Ungrouped") @@ -277,17 +284,7 @@ macro(add_osgearth_library) set(multiValueArgs SOURCES HEADERS PUBLIC_HEADERS IMGUI_HEADERS SHADERS TEMPLATES LIBRARIES INCLUDE_DIRECTORIES) cmake_parse_arguments(MY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - set(INSTALL_INCDIR include/${MY_TARGET}) - - # apply postfixes for non-windows...? - set(INSTALL_BINDIR bin) - if(WIN32) - set(INSTALL_LIBDIR bin) - set(INSTALL_ARCHIVEDIR lib) - else() - set(INSTALL_LIBDIR lib${LIB_POSTFIX}) - set(INSTALL_ARCHIVEDIR lib${LIB_POSTFIX}) - endif() + set(INSTALL_INCLUDE_FOLDER include/${MY_TARGET}) set(ALL_HEADERS ${MY_HEADERS} ${MY_IMGUI_HEADERS} ${MY_PUBLIC_HEADERS}) include_directories(${MY_INCLUDE_DIRECTORIES}) @@ -315,14 +312,19 @@ macro(add_osgearth_library) else() target_link_libraries(${MY_TARGET} PRIVATE ${OPENSCENEGRAPH_LIBRARIES} ${MY_LIBRARIES}) endif() + + # soversions - append SO version to shared object files on unix (e.g., osgearth.so.123) + if (OSGEARTH_SONAMES) + set_target_properties(${MY_TARGET} PROPERTIES VERSION ${OSGEARTH_VERSION} SOVERSION ${OSGEARTH_SOVERSION}) + endif() # library install and target exports for the cmake config packaging. install( TARGETS ${MY_TARGET} EXPORT ${MY_TARGET}Targets - RUNTIME DESTINATION ${INSTALL_BINDIR} - LIBRARY DESTINATION ${INSTALL_LIBDIR} - ARCHIVE DESTINATION ${INSTALL_ARCHIVEDIR} + RUNTIME DESTINATION ${INSTALL_RUNTIME_FOLDER} + LIBRARY DESTINATION ${INSTALL_LIBRARY_FOLDER} + ARCHIVE DESTINATION ${INSTALL_ARCHIVE_FOLDER} ) # deploy the shaders for this library, if requested. @@ -338,7 +340,7 @@ macro(add_osgearth_library) # normal path to install the public header files: install( FILES ${MY_PUBLIC_HEADERS} - DESTINATION ${INSTALL_INCDIR}) + DESTINATION ${INSTALL_INCLUDE_FOLDER}) else() # macos-specific if(OSG_BUILD_PLATFORM_IPHONE)