cmake: Rework FindSCIP.cmake

note: currently scip do not provide alias targets when installing scip.
This commit is contained in:
Corentin Le Molgat
2025-07-10 11:00:45 +02:00
parent 9141d05483
commit 9d3350dcbc
2 changed files with 15 additions and 7 deletions

View File

@@ -20,7 +20,7 @@ This module determines the SCIP library of the system.
IMPORTED Targets
^^^^^^^^^^^^^^^^
This module defines :prop_tgt:`IMPORTED` target ``SCIP::SCIP``, if
This module defines :prop_tgt:`IMPORTED` target ``SCIP::libscip``, if
SCIP has been found.
Result Variables
@@ -45,6 +45,10 @@ find_package(SCIP QUIET NO_MODULE)
# if we found the SCIP cmake package then we are done.
if(SCIP_FOUND)
find_package_handle_standard_args(SCIP CONFIG_MODE)
if(NOT TARGET SCIP::libscip)
message(WARNING "SCIP::libscip not provided")
add_library(SCIP::libscip ALIAS libscip)
endif()
return()
endif()
@@ -69,15 +73,15 @@ else()
set(SCIP_FOUND TRUE)
endif()
if(SCIP_FOUND AND NOT TARGET SCIP::SCIP)
add_library(SCIP::SCIP UNKNOWN IMPORTED)
if(SCIP_FOUND AND NOT TARGET SCIP::libscip)
add_library(SCIP::libscip UNKNOWN IMPORTED)
set_target_properties(SCIP::SCIP PROPERTIES
set_target_properties(SCIP::libscip PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SCIP_ROOT}/include")
if(APPLE)
set(SCIP_ARCH darwin.x86_64.gnu.opt)
set_property(TARGET SCIP::SCIP PROPERTY IMPORTED_LOCATION
set_property(TARGET SCIP::libscip PROPERTY IMPORTED_LOCATION
-force_load
${SCIP_ROOT}/lib/libscip.a
${SCIP_ROOT}/lib/libscipopt.a
@@ -86,14 +90,14 @@ if(SCIP_FOUND AND NOT TARGET SCIP::SCIP)
)
elseif(UNIX)
set(SCIP_ARCH linux.x86_64.gnu.opt)
set_property(TARGET SCIP::SCIP PROPERTY IMPORTED_LOCATION
set_property(TARGET SCIP::libscip PROPERTY IMPORTED_LOCATION
${SCIP_ROOT}/lib/libscip.a
${SCIP_ROOT}/lib/libscipopt.a
${SCIP_ROOT}/lib/libsoplex.a
${SCIP_ROOT}/lib/libsoplex.${SCIP_ARCH}.a
)
elseif(MSVC)
set_property(TARGET SCIP::SCIP PROPERTY IMPORTED_LOCATION
set_property(TARGET SCIP::libscip PROPERTY IMPORTED_LOCATION
${SCIP_ROOT}/lib/scip.lib
${SCIP_ROOT}/lib/soplex.lib
ignore:4006

View File

@@ -96,6 +96,10 @@ endif()
if(USE_SCIP)
if(NOT BUILD_SCIP AND NOT TARGET SCIP::libscip)
find_package(SCIP REQUIRED)
if(TARGET libscip AND NOT TARGET SCIP::libscip)
message(WARNING "SCIP::libscip not provided")
add_library(SCIP::libscip ALIAS libscip)
endif()
endif()
endif()