From 02c703720d5aab4cd74209170d5c76608c240de2 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Sun, 2 Jul 2023 21:10:15 -0400 Subject: [PATCH 1/2] Use GNUInstallDirs Fixes multilib installation paths (e.g. /usr/lib64 vs. /usr/lib) on some Linux distributions. --- src/CMakeLists.txt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 27d52f14..76a8975d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,8 @@ function(setLibProperties targetname outputname) MACOSX_RPATH "${CMAKE_INSTALL_PREFIX}/lib") endfunction(setLibProperties) +include(GNUInstallDirs) + include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}) set(sources @@ -204,15 +206,15 @@ target_link_libraries(example libsoplex) set_target_properties(soplex PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # install the header files of soplex -install(FILES ${headers} ${PROJECT_BINARY_DIR}/soplex/config.h DESTINATION include/soplex) -install(FILES soplex.h soplex.hpp soplex_interface.h DESTINATION include) +install(FILES ${headers} ${PROJECT_BINARY_DIR}/soplex/config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/soplex) +install(FILES soplex.h soplex.hpp soplex_interface.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) # install the binary and the library to appropriate lcoations and add them to an export group install(TARGETS soplex libsoplex libsoplex-pic libsoplexshared EXPORT soplex-targets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION include) + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) # Add library targets to the build-tree export set export(TARGETS libsoplex libsoplex-pic libsoplexshared @@ -238,7 +240,7 @@ configure_file(${PROJECT_SOURCE_DIR}/soplex-config.cmake.in # install the targets of the soplex export group and the config file so that other projects # can link easily against soplex -install(EXPORT soplex-targets FILE soplex-targets.cmake DESTINATION lib/cmake/soplex) +install(EXPORT soplex-targets FILE soplex-targets.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/soplex) install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/soplex-config.cmake" ${CMAKE_BINARY_DIR}/soplex-config-version.cmake - DESTINATION lib/cmake/soplex) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/soplex) From 5e6259b91ce58a13cfc91efdc7e71c0d922a023b Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Tue, 11 Jul 2023 13:29:19 -0400 Subject: [PATCH 2/2] Set rpaths with GNUInstallDirs, too --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 76a8975d..e35666fd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,7 +4,7 @@ function(setLibProperties targetname outputname) set_target_properties(${targetname} PROPERTIES OUTPUT_NAME ${outputname} - MACOSX_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + MACOSX_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") endfunction(setLibProperties) include(GNUInstallDirs) @@ -203,7 +203,7 @@ add_executable(example EXCLUDE_FROM_ALL example.cpp) target_link_libraries(example libsoplex) # set the install rpath to the installed destination -set_target_properties(soplex PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +set_target_properties(soplex PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") # install the header files of soplex install(FILES ${headers} ${PROJECT_BINARY_DIR}/soplex/config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/soplex)