From c1f2d74de908e4efc13aca3b9bd20ef87ad54918 Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Wed, 11 Jun 2025 11:16:43 +0200 Subject: [PATCH] dependencies: Fix MACOSX_RPATH usage (#4674) 1. This is a boolean property which must be set to TRUE or FALSE If TRUE, the default, cmake will use @rpath as directory portion (aka prefix) of the install_name (otool LC_ID_DYLIB) note: CMP0042 set it to TRUE by default 2. To change this prefix you must use INSTALL_NAME_DIR 3. To change the INSTALL_RPATH (otool LC_RPATH) (e.g. to set it to @loader_path) you must use the INSTALL_RPATH property. ref: https://cmake.org/cmake/help/latest/variable/CMAKE_MACOSX_RPATH.html https://cmake.org/cmake/help/latest/prop_tgt/MACOSX_RPATH.html https://cmake.org/cmake/help/latest/prop_tgt/INSTALL_RPATH.html https://cmake.org/cmake/help/latest/policy/CMP0042.html --- cmake/dependencies/CMakeLists.txt | 2 + patches/highs-v1.11.0.patch | 276 ++++++++++++++++++++++++++++++ patches/scip-v922.patch | 42 ++++- patches/soplex-v7.1.3.patch | 28 ++- 4 files changed, 338 insertions(+), 10 deletions(-) create mode 100644 patches/highs-v1.11.0.patch diff --git a/cmake/dependencies/CMakeLists.txt b/cmake/dependencies/CMakeLists.txt index 2b461eacd3..926e51c047 100644 --- a/cmake/dependencies/CMakeLists.txt +++ b/cmake/dependencies/CMakeLists.txt @@ -287,6 +287,8 @@ if(BUILD_HIGHS) GIT_REPOSITORY "https://github.com/ERGO-Code/HiGHS.git" GIT_TAG "v1.11.0" GIT_SHALLOW TRUE + PATCH_COMMAND git apply --ignore-whitespace + "${CMAKE_CURRENT_LIST_DIR}/../../patches/highs-v1.11.0.patch" ) FetchContent_MakeAvailable(highs) list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/patches/highs-v1.11.0.patch b/patches/highs-v1.11.0.patch new file mode 100644 index 0000000000..ce02101076 --- /dev/null +++ b/patches/highs-v1.11.0.patch @@ -0,0 +1,276 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 661aa078..2606e08d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -57,7 +57,7 @@ endif() + # message("CMAKE_CXX_COMPILER_ID is ${CMAKE_CXX_COMPILER_ID}") + if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") + message(STATUS "Compiler is IntelLLVM") +- if (CMAKE_HOST_WIN32 AND CMAKE_VERSION VERSION_LESS "3.23.0") ++ if (CMAKE_HOST_WIN32 AND CMAKE_VERSION VERSION_LESS "3.23.0") + message(FATAL_ERROR "Need at least CMake 3.23 for IntelLLVM support of IntelDPCPP package on Windows") + elseif(CMAKE_VERSION VERSION_LESS "3.23.0") + message(FATAL_ERROR "CMake 3.20.5 is the minimum recommended for IntelLLVM on Linux") +@@ -121,9 +121,9 @@ endif() + + option(HIGHS_COVERAGE "Activate the code coverage compilation" OFF) + +-# Address | Thread | Leak ++# Address | Thread | Leak + # Linux atm +-# Only Debug is theted atm ++# Only Debug is theted atm + # See below for RelWithDeb info, todo test wip + set(DEBUG_MEMORY "Off" CACHE STRING "Sanitizers") + +@@ -137,7 +137,7 @@ message(STATUS "Build pdlp with GPU: ${CUPDLP_GPU}") + option(CUPDLP_FIND_CUDA "Build pdlp with GPU" OFF) + message(STATUS "Use FindCUDAConf: ${CUPDLP_FIND_CUDA}") + +-if(CUPDLP_GPU AND CMAKE_VERSION VERSION_LESS "3.25.0") ++if(CUPDLP_GPU AND CMAKE_VERSION VERSION_LESS "3.25.0") + message("CUPDLP FindCUDAConf requires CMake version minumum 3.24. Please use a higher version of CMake.") + endif() + +@@ -158,11 +158,11 @@ if (CUPDLP_GPU) + # With FindCUDAConf.cmake + # Need to have the CUDA_HOME environment variable set. + include(FindCUDAConf) +- else() ++ else() + # Without FindCUDAConf.cmake + enable_language(CUDA) + find_package(CUDAToolkit REQUIRED) +- ++ + set(CUDA_LIBRARY-NOTFOUND, OFF) + set(CUDA_LIBRARY CUDA::cudart CUDA::cublas CUDA::cusparse) + endif() +@@ -205,7 +205,7 @@ if (BUILD_CXX) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) +- # for multi-config build system (e.g. xcode) ++ # for multi-config build system (e.g. xcode) + foreach(OutputConfig IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${OutputConfig} OUTPUTCONFIG) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${OutputConfig}/${CMAKE_INSTALL_LIBDIR}) +@@ -244,14 +244,14 @@ if (BUILD_CXX) + option(STDCALL "Build highs with the __stdcall convention" OFF) + endif() + +- if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR +- CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR +- CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") ++ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR ++ CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR ++ CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +- # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") ++ # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # not recognised by cl +- # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11") +- endif() ++ # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11") ++ endif() + + # Basic type + include(CMakePushCheckState) +@@ -275,7 +275,7 @@ if (BUILD_CXX) + check_type_size("int *" SIZEOF_INT_P LANGUAGE CXX) + message(STATUS "Found int * size: ${SIZEOF_INT_P}") + cmake_pop_check_state() +- ++ + # Use current CMAKE_C_FLAGS and CMAKE_CXX_FLAGS when checking for IPO support, + # instead of defaults: https://cmake.org/cmake/help/latest/policy/CMP0138.html + if(MSVC AND BUILD_SHARED_LIBS) +@@ -293,7 +293,7 @@ if (BUILD_CXX) + set(ipo_supported NO) + message(STATUS "IPO / LTO not currently supported building HiGHS on MinGW") + else() +- if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") ++ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") + cmake_policy(SET CMP0138 NEW) + endif() + +@@ -371,19 +371,8 @@ else() + HIGHS_HAVE_BUILTIN_CLZ) + endif() + +-set(CMAKE_MACOSX_RPATH ON) +- +-if (BUILD_DOTNET) +- set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +-else() +- # 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_USE_LINK_PATH TRUE) +-endif() ++# set the correct rpath for OS X ++set(CMAKE_MACOSX_RPATH TRUE) + + if(NOT FAST_BUILD) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${HIGHS_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) +@@ -428,7 +417,7 @@ endif() + + # For debug of cuda locally + +-# does not work with older CMake ++# does not work with older CMake + # add_compile_options("$<$,$>:-G>") + + # add_compile_options("$<$:-G>") +@@ -453,7 +442,7 @@ if(MSVC) + add_compile_options("$<$:-D_CRT_SECURE_NO_WARNINGS>") + add_compile_options("$<$:/MP>") + +- # Try to split large pdb files into objects. ++ # Try to split large pdb files into objects. + # https://github.com/tensorflow/tensorflow/issues/31610 + # add_compile_options("/Z7") + # add_link_options("/DEBUG:FASTLINK") +@@ -611,11 +600,11 @@ if(FAST_BUILD AND HIGHS_COVERAGE) + message(STATUS "Building in coverage mode") + + # Enable coverage flags +- add_compile_options(-O0) +- add_compile_options(--coverage) +- add_compile_options(-fprofile-update=atomic) ++ add_compile_options(-O0) ++ add_compile_options(--coverage) ++ add_compile_options(-fprofile-update=atomic) + +- add_link_options(-O0) ++ add_link_options(-O0) + add_link_options(--coverage) # Ensure coverage data is linked correctly + + find_program(GCOV_PATH gcov) +diff --git a/highs/CMakeLists.txt b/highs/CMakeLists.txt +index 50301433..f7b982fb 100644 +--- a/highs/CMakeLists.txt ++++ b/highs/CMakeLists.txt +@@ -1,7 +1,7 @@ + if (NOT BUILD_CXX) + return() + endif() +- ++ + # Define library. + include(sources) + set(sources ${highs_sources} ${cupdlp_sources} ${ipx_sources} ${basiclu_sources}) +@@ -43,7 +43,7 @@ if(NOT FAST_BUILD) + set_target_properties(libhighs PROPERTIES + OUTPUT_NAME "highs" + PDB_NAME "libhighs" +- MACOSX_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") ++ ) + + if(ZLIB AND ZLIB_FOUND) + target_link_libraries(libhighs ZLIB::ZLIB) +@@ -51,8 +51,11 @@ if(NOT FAST_BUILD) + endif() + + # set the install rpath to the installed destination +- set_target_properties(libhighs PROPERTIES INSTALL_RPATH +- "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") ++ if(APPLE) ++ set_target_properties(libhighs PROPERTIES INSTALL_RPATH "@loader_path") ++ elseif (UNIX) ++ set_target_properties(libhighs PROPERTIES INSTALL_RPATH "$ORIGIN") ++ endif() + + # install the header files of highs + foreach(file ${headers}) +@@ -84,7 +87,7 @@ if(NOT FAST_BUILD) + # target_compile_options(libipx PRIVATE "-Wno-sign-compare") + # target_compile_options(libipx PRIVATE "-Wno-logical-op-parentheses") + endif() +- ++ + install(TARGETS libhighs EXPORT highs-targets + LIBRARY + ARCHIVE +@@ -150,8 +153,8 @@ else() + + + target_sources(highs PRIVATE ${sources} ${headers} ${win_version_file}) +- +- # Optional Cuda ++ ++ # Optional Cuda + if (CUPDLP_GPU) + + target_include_directories(highs PUBLIC "$") +@@ -164,7 +167,7 @@ else() + else() + target_link_libraries(highs cudalin ${CUDA_LIBRARY} m) + endif() +- ++ + set_target_properties(highs PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + + endif() +@@ -221,7 +224,7 @@ else() + ) + target_link_libraries(highs ZLIB::ZLIB) + endif() +- ++ + # install the header files of highs + foreach(file ${headers}) + get_filename_component(dir ${file} DIRECTORY) +@@ -236,9 +239,9 @@ else() + + # target_compile_options(highs PRIVATE "-Wall") + # target_compile_options(highs PRIVATE "-Wunused") +- ++ + if (UNIX) +- if ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") ++ if ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(highs PRIVATE "-Wall") + target_compile_options(highs PRIVATE "-Wreturn-type") + target_compile_options(highs PRIVATE "-Wmissing-declarations") +@@ -248,7 +251,7 @@ else() + target_compile_options(highs PRIVATE "-Wno-comment") + target_compile_options(highs PRIVATE "-Wno-unused-label") + +- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") ++ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(highs PRIVATE "-Wno-unused-lambda-capture") + endif() + +@@ -267,7 +270,7 @@ else() + endif() + + if (BUILD_DOTNET) +- ++ + # see: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog + if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)") + set(DOTNET_PLATFORM arm64) +@@ -298,8 +301,8 @@ else() + set(TARGET_FILE_NAME "highs.dll") + endif() + +- add_custom_command(TARGET highs POST_BUILD +- COMMAND "${CMAKE_COMMAND}" -E copy ++ add_custom_command(TARGET highs POST_BUILD ++ COMMAND "${CMAKE_COMMAND}" -E copy + "$" + ${DOTNET_PROJECT_DIR}/runtimes/${DOTNET_RID}/native/${TARGET_FILE_NAME} + COMMENT "Copying to output directory") +@@ -318,7 +321,7 @@ if(FORTRAN_FOUND) + target_link_libraries(FortranHighs PUBLIC highs) + endif() + +- install(TARGETS FortranHighs ++ install(TARGETS FortranHighs + LIBRARY + ARCHIVE + RUNTIME diff --git a/patches/scip-v922.patch b/patches/scip-v922.patch index 7a92254118..b1093c9e34 100644 --- a/patches/scip-v922.patch +++ b/patches/scip-v922.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 8492dc75..4c12a9bf 100644 +index 38ac7845..9b0d4fcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,9 +38,11 @@ set(CPACK_PACKAGE_VENDOR "Zuse Institute Berlin") @@ -17,6 +17,15 @@ index 8492dc75..4c12a9bf 100644 if(SCIPOptSuite_BINARY_DIR) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SCIPOptSuite_BINARY_DIR}/bin) +@@ -239,7 +241,7 @@ if(DEBUGSOL) + endif() + + #set the correct rpath for OS X +-set(CMAKE_MACOSX_RPATH ON) ++set(CMAKE_MACOSX_RPATH TRUE) + + #set defines for Windows + if(WIN32) @@ -412,22 +414,11 @@ endif() #search the selected LP solver library message(STATUS "Finding Solver \"${LPS}\"") @@ -96,10 +105,35 @@ index 559552f9..682ac40a 100644 set(SCIP_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@") set(SCIP_FOUND TRUE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index e6fda2d5..2d04b845 100644 +index d6dd3acf..a146ddec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt -@@ -1149,17 +1149,8 @@ install(TARGETS scip libscip EXPORT scip-targets +@@ -5,8 +5,8 @@ include(GNUInstallDirs) + + function(setLibProperties targetname outputname) + set_target_properties(${targetname} PROPERTIES +- OUTPUT_NAME ${outputname} +- MACOSX_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") ++ OUTPUT_NAME ${outputname} ++ ) + endfunction(setLibProperties) + + set(CMAKE_C_STANDARD 99) +@@ -1112,6 +1112,13 @@ target_link_libraries(scip + add_dependencies(libscip scip_update_githash) + add_dependencies(scip scip_update_githash) + ++if(APPLE) ++ set_target_properties(libscip PROPERTIES ++ INSTALL_RPATH "@loader_path") ++elseif(UNIX) ++ set_target_properties(libscip PROPERTIES ++ INSTALL_RPATH "$ORIGIN") ++endif() + set_target_properties(libscip PROPERTIES + VERSION ${SCIP_VERSION_MAJOR}.${SCIP_VERSION_MINOR}.${SCIP_VERSION_PATCH}.${SCIP_VERSION_SUB} + SOVERSION ${SCIP_VERSION_MAJOR}.${SCIP_VERSION_MINOR} +@@ -1150,17 +1157,8 @@ install(TARGETS scip libscip EXPORT scip-targets INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) # Add all targets to the build-tree export set @@ -119,7 +153,7 @@ index e6fda2d5..2d04b845 100644 # configure the config file for the build tree set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}") -@@ -1175,18 +1166,16 @@ ${PROJECT_BINARY_DIR}/scip-config-version.cmake +@@ -1176,18 +1174,16 @@ ${PROJECT_BINARY_DIR}/scip-config-version.cmake #configure the config file for the install set(CONF_INCLUDE_DIRS "\${CMAKE_CURRENT_LIST_DIR}/../../../include") diff --git a/patches/soplex-v7.1.3.patch b/patches/soplex-v7.1.3.patch index 06b629ec98..2df6a36841 100644 --- a/patches/soplex-v7.1.3.patch +++ b/patches/soplex-v7.1.3.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 0b21f5a..ddf1536 100644 +index 0b21f5a..6f08341 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,10 @@ set(CPACK_PACKAGE_VERSION_PATCH "${SOPLEX_VERSION_PATCH}") @@ -34,7 +34,12 @@ index 0b21f5a..ddf1536 100644 # for colorized output if(NOT WIN32) -@@ -69,6 +79,8 @@ set(CMAKE_MACOSX_RPATH ON) +@@ -65,10 +75,12 @@ if(NOT CMAKE_BUILD_TYPE) + endif() + + # set the correct rpath for OS X +-set(CMAKE_MACOSX_RPATH ON) ++set(CMAKE_MACOSX_RPATH TRUE) # use C++14 standard set(CMAKE_CXX_STANDARD 14) @@ -131,9 +136,20 @@ index 0b21f5a..ddf1536 100644 + add_subdirectory(check) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 84ec5a5..6f5d4ef 100644 +index 84ec5a5..4552300 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt +@@ -3,8 +3,8 @@ + # + function(setLibProperties targetname outputname) + set_target_properties(${targetname} PROPERTIES +- OUTPUT_NAME ${outputname} +- MACOSX_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") ++ OUTPUT_NAME ${outputname} ++ ) + endfunction(setLibProperties) + + include(GNUInstallDirs) @@ -193,24 +193,28 @@ target_link_libraries(libsoplexshared libsoplex ${libs}) set_target_properties(libsoplexshared PROPERTIES CXX_VISIBILITY_PRESET default) @@ -143,11 +159,11 @@ index 84ec5a5..6f5d4ef 100644 +if(SOPLEX_SOPLEX) + add_executable(soplex EXCLUDE_FROM_ALL soplexmain.cpp) + target_link_libraries(soplex PRIVATE libsoplex ${Boost_LIBRARIES}) - --if(EMSCRIPTEN AND EMSCRIPTEN_HTML) ++ + # set the install rpath to the installed destination + set_target_properties(soplex PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") -+ + +-if(EMSCRIPTEN AND EMSCRIPTEN_HTML) + if(EMSCRIPTEN AND EMSCRIPTEN_HTML) set_target_properties(soplex PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/soplex_webdemo_shell.html) set(CMAKE_EXECUTABLE_SUFFIX ".html")