Skip to content

Commit

Permalink
Adapt lib/bin destinations for linux; add back the soversion postfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed May 17, 2024
1 parent 1626923 commit 08e5e56
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 24 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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})



Expand Down
16 changes: 12 additions & 4 deletions cmake/oe_unix.cmake
Original file line number Diff line number Diff line change
@@ -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)
40 changes: 21 additions & 19 deletions cmake/osgearth-macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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} )
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit 08e5e56

Please sign in to comment.