From 75cd4712543050f7b772867bb5b90862bfd29b4f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 28 Jan 2009 09:42:21 +0000 Subject: [PATCH] From Mattias Helsing, "this is a semi-submission based on what you and others have been talking about in the LIB_POSTFIX thread. It is a bit verbose perhaps and the message I emit during the make install step flashes by and gets burried under all "installing..." and/or "up-to-date..." messages. I have posted on the cmake mail list on ways to do this better. The submission adds: * message to user during configuration that s/he's eventually going o install to ${CMAKE_INSTALL_PREFIX}lib${LIB_POSTFIX} * if system has /etc/ld.so.conf.d and it is a dir generates packaging/ld.so.conf.d/openscenegraph.conf and creates a custom target for installing it (target must be run explicitly of course). User is notified of this during configuration (may not be necessary) * emit a message during installation that libraries are put in . This message unfortunately gets emitted to soon for the user to see it * I added "COMPONENT libopenscenegraph-dev" to the pkgconfig.pc's install command * Moved the section with OSG_CONFIG_HAS_BEEN_RUN_BEFORE as close to the end of CMakeLists.txt as I dared. This is the intent of this construct I think." --- CMakeLists.txt | 45 ++++++++++++++++--- packaging/ld.so.conf.d/openscenegraph.conf.in | 2 + 2 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 packaging/ld.so.conf.d/openscenegraph.conf.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 06d6102e8..16afd2cbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -736,12 +736,6 @@ IF(BUILD_DASHBOARD_REPORTS) INCLUDE(Dart) ENDIF(BUILD_DASHBOARD_REPORTS) -# This needs to be run very last so other parts of the scripts can take -# advantage of this. -IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE) - SET(OSG_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before") -ENDIF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE) - # present the packaging option only if we have the cpack command defined (effectively >= 2.6.0) IF(CMAKE_CPACK_COMMAND) OPTION(BUILD_OSG_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF) @@ -757,7 +751,44 @@ CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/pkgconfig/openscenegraph.pc.in @ONLY ) -INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/pkgconfig/openscenegraph.pc DESTINATION lib${LIB_POSTFIX}/pkgconfig) +INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/pkgconfig/openscenegraph.pc DESTINATION lib${LIB_POSTFIX}/pkgconfig COMPONENT libopenscenegraph-dev) + +# Run this as late as possible so users can easier spot the message +IF(LIB_POSTFIX) + MESSAGE("You will be installing libraries to ${CMAKE_INSTALL_PREFIX}lib${LIB_POSTFIX}\n" + "Your loader may not be able to find your installed libraries unless you:\n" + " set your LD_LIBRARY_PATH (user specific)\n" + " update your ld.so configuration (system wide)") + IF(IS_DIRECTORY /etc/ld.so.conf.d) + MESSAGE("You have an ld.so.conf.d directory on your system.\n" + "You can install a openscenegraph specific ld.so configuration with:\n" + " sudo make install_ld_conf") + CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/packaging/ld.so.conf.d/openscenegraph.conf.in + ${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf + ) + ADD_CUSTOM_TARGET(install_ld_conf ${CMAKE_COMMAND} -E copy_if_different + ${PROJECT_BINARY_DIR}/packaging/ld.so.conf.d/openscenegraph.conf + /etc/ld.so.conf.d/openscenegraph.conf + COMMAND ldconfig + COMMENT "Copying openscenegraph.conf to /etc/ld.so.conf.d and running ldconfig" + ) + ELSE(IS_DIRECTORY /etc/ld.so.conf.d) + IF(EXIST /etc/ld.so.conf) + MESSAGE("You have an ld.so.conf file in /etc\n" + "You may need to add ${CMAKE_INSTALL_PREFIX}lib${LIB_POSTFIX} to it.") + ENDIF(EXIST /etc/ld.so.conf) + ENDIF(IS_DIRECTORY /etc/ld.so.conf.d) + + # emit a message during installation. + INSTALL(CODE "MESSAGE(\"Libraries were installed to ${CMAKE_INSTALL_PREFIX}lib${LIB_POSTFIX}.\\nYou may need to update your ld.so configuration. \")") +ENDIF(LIB_POSTFIX) + + +# This needs to be run very last so other parts of the scripts can take +# advantage of this. +IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE) + SET(OSG_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before") +ENDIF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE) #----------------------------------------------------------------------------- ### uninstall target diff --git a/packaging/ld.so.conf.d/openscenegraph.conf.in b/packaging/ld.so.conf.d/openscenegraph.conf.in new file mode 100644 index 000000000..78c3b6914 --- /dev/null +++ b/packaging/ld.so.conf.d/openscenegraph.conf.in @@ -0,0 +1,2 @@ +# openscenegraph library configuration +${CMAKE_INSTALL_PREFIX}lib${LIB_POSTFIX}