Skip to content

Commit

Permalink
CMAKE: add an uninstall target, remove the prefix on linux plugin lib…
Browse files Browse the repository at this point in the history
…rary files, and more the GL dependency on Triton and Silverlining into the nodekits themselves.
  • Loading branch information
gwaldron committed May 17, 2024
1 parent 1f800cc commit 2e67670
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 22 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,16 @@ osgearth_install_package_config_files(

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake Targets")


# Uninstall target .......................................................

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
IMMEDIATE @ONLY
)

add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
)
37 changes: 19 additions & 18 deletions cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
# https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake

FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
STRING(REGEX REPLACE "\n" ";" files "${files}")
FOREACH(file ${files})
MESSAGE(STATUS "Uninstalling \"${file}\"")
IF(EXISTS "${file}")
EXEC_PROGRAM(
"@CMAKE_COMMAND@" ARGS "-E remove \"${file}\""
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
endif()

file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF("${rm_retval}" STREQUAL 0)
ELSE("${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"")
ENDIF("${rm_retval}" STREQUAL 0)
ELSE(EXISTS "${file}")
MESSAGE(STATUS "File \"${file}\" does not exist.")
ENDIF(EXISTS "${file}")
ENDFOREACH(file)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif()
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif()
endforeach()
4 changes: 4 additions & 0 deletions cmake/osgearth-macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ macro(add_osgearth_plugin)
message(FATAL_ERROR "add_library_as_plugin: name '${MY_TARGET}' must begin with 'osgdb_' or 'osgdb_osgearth_'")
endif()

# no prefixes on plugin library files, please.
# without this, plugins will have names like "libosgdb_osgearth.so" and OSG doesn't want the "lib"
set_target_properties(${MY_TARGET} PROPERTIES PREFIX "")

# 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})
Expand Down
2 changes: 1 addition & 1 deletion src/applications/osgearth_silverlining/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ add_osgearth_app(
SOURCES osgearth_silverlining.cpp
FOLDER Tests )

target_link_libraries(osgearth_silverlining PRIVATE osgEarthSilverLining ${OPENGL_LIBRARIES})
target_link_libraries(osgearth_silverlining PRIVATE osgEarthSilverLining)
2 changes: 1 addition & 1 deletion src/applications/osgearth_triton/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ add_osgearth_app(
SOURCES osgearth_triton.cpp
FOLDER Tests )

target_link_libraries(osgearth_triton PRIVATE osgEarthTriton ${OPENGL_LIBRARIES})
target_link_libraries(osgearth_triton PRIVATE osgEarthTriton)
2 changes: 1 addition & 1 deletion src/osgEarthSilverLining/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ include_directories(
${SILVERLINING_INCLUDE_DIR})

target_link_libraries(${LIB_NAME}
PUBLIC osgEarth ${OPENSCENEGRAPH_LIBRARIES} ${SILVERLINING_LIBRARY})
PUBLIC osgEarth ${OPENSCENEGRAPH_LIBRARIES} ${OPENGL_LIBRARIES} ${SILVERLINING_LIBRARY})

# Add this project to the NodeKits solution folder
set_property( TARGET ${LIB_NAME} PROPERTY FOLDER "NodeKits" )
2 changes: 1 addition & 1 deletion src/osgEarthTriton/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ include_directories(
)

target_link_libraries(${LIB_NAME}
PUBLIC osgEarth ${OPENSCENEGRAPH_LIBRARIES} ${TRITON_LIBRARY})
PUBLIC osgEarth ${OPENSCENEGRAPH_LIBRARIES} ${OPENGL_LIBRARIES} ${TRITON_LIBRARY})

# Add this project to the NodeKits solution folder
set_property( TARGET ${LIB_NAME} PROPERTY FOLDER "NodeKits" )

0 comments on commit 2e67670

Please sign in to comment.