From e68185e89bd9c09eaedce99b053e6e76e9b41604 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 22 Nov 2017 07:33:11 -0600 Subject: [PATCH] Make sure libopenmc.so gets installed (and has correct RPATH) --- CMakeLists.txt | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b0bef14e..dfd9221ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -281,10 +281,30 @@ target_link_libraries(pugixml_fortran pugixml) # RPATH information #=============================================================================== +# This block of code ensures that dynamic libraries can be found via the RPATH +# whether the executable is the original one from the build directory or the +# installed one in CMAKE_INSTALL_PREFIX. Ref: +# https://cmake.org/Wiki/CMake_RPATH_handling#Always_full_RPATH + +# use, i.e. don't skip the full RPATH for the build tree +set(CMAKE_SKIP_BUILD_RPATH FALSE) + +# when building, don't use the install RPATH already +# (but later on when installing) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +# the RPATH to be used when installing, but only if it's not a system directory +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) +if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +endif() + #=============================================================================== # Build faddeeva library #=============================================================================== @@ -435,7 +455,9 @@ add_custom_command(TARGET libopenmc POST_BUILD # Install executable, scripts, manpage, license #=============================================================================== -install(TARGETS ${program} RUNTIME DESTINATION bin) +install(TARGETS ${program} libopenmc + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib) install(DIRECTORY src/relaxng DESTINATION share/openmc) install(FILES man/man1/openmc.1 DESTINATION share/man/man1) install(FILES LICENSE DESTINATION "share/doc/${program}" RENAME copyright)