diff --git a/CMakeLists.txt b/CMakeLists.txt index 4650207b89..3d787b5c5c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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" +) \ No newline at end of file diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in index bcf2437c75..96ae55b103 100644 --- a/cmake/cmake_uninstall.cmake.in +++ b/cmake/cmake_uninstall.cmake.in @@ -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) \ No newline at end of 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() diff --git a/cmake/osgearth-macros.cmake b/cmake/osgearth-macros.cmake index dfe7aadaeb..c5c8c811fa 100644 --- a/cmake/osgearth-macros.cmake +++ b/cmake/osgearth-macros.cmake @@ -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}) diff --git a/src/applications/osgearth_silverlining/CMakeLists.txt b/src/applications/osgearth_silverlining/CMakeLists.txt index e606c3ffe8..5797563c37 100644 --- a/src/applications/osgearth_silverlining/CMakeLists.txt +++ b/src/applications/osgearth_silverlining/CMakeLists.txt @@ -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) diff --git a/src/applications/osgearth_triton/CMakeLists.txt b/src/applications/osgearth_triton/CMakeLists.txt index e9b28adde7..04f913fca1 100644 --- a/src/applications/osgearth_triton/CMakeLists.txt +++ b/src/applications/osgearth_triton/CMakeLists.txt @@ -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) diff --git a/src/osgEarthSilverLining/CMakeLists.txt b/src/osgEarthSilverLining/CMakeLists.txt index 12610403a8..ccc6ed1862 100644 --- a/src/osgEarthSilverLining/CMakeLists.txt +++ b/src/osgEarthSilverLining/CMakeLists.txt @@ -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" ) diff --git a/src/osgEarthTriton/CMakeLists.txt b/src/osgEarthTriton/CMakeLists.txt index 4615450397..71c05a89d2 100644 --- a/src/osgEarthTriton/CMakeLists.txt +++ b/src/osgEarthTriton/CMakeLists.txt @@ -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" )