cmake: rework deps management

This commit is contained in:
Corentin Le Molgat
2024-10-11 14:08:00 +02:00
parent 001c515dde
commit bbf7fbd36a
2 changed files with 30 additions and 6 deletions

View File

@@ -79,12 +79,36 @@ if(USE_COINOR)
set(COINOR_DEPS Coin::CbcSolver Coin::OsiCbc Coin::ClpSolver Coin::OsiClp)
endif()
if(USE_CPLEX)
if(NOT TARGET CPLEX::CPLEX)
message(FATAL_ERROR "Target CPLEX::CPLEX not available.")
endif()
set(CPLEX_DEPS CPLEX::CPLEX)
endif()
if(USE_GLPK)
if(NOT TARGET GLPK::GLPK)
message(FATAL_ERROR "Target GLPK::GLPK not available.")
endif()
set(GLPK_DEPS GLPK::GLPK)
endif()
if(USE_HIGHS)
if(NOT TARGET highs::highs)
message(FATAL_ERROR "Target highs::highs not available.")
endif()
set(HIGHS_DEPS highs::highs)
endif()
if(USE_PDLP AND BUILD_PDLP)
set(PDLP_DEPS Eigen3::Eigen)
endif()
if(USE_SCIP AND NOT TARGET libscip)
message(FATAL_ERROR "Target libscip not available.")
if(USE_SCIP)
if(NOT TARGET libscip)
message(FATAL_ERROR "Target libscip not available.")
endif()
set(SCIP_DEPS libscip)
endif()
# Check optional Dependencies

View File

@@ -558,11 +558,11 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
protobuf::libprotobuf
${RE2_DEPS}
${COINOR_DEPS}
$<$<BOOL:${USE_CPLEX}>:CPLEX::CPLEX>
$<$<BOOL:${USE_GLPK}>:GLPK::GLPK>
$<$<BOOL:${USE_HIGHS}>:highs::highs>
${CPLEX_DEPS}
${GLPK_DEPS}
${HIGHS_DEPS}
${PDLP_DEPS}
$<$<BOOL:${USE_SCIP}>:libscip>
${SCIP_DEPS}
Threads::Threads)
if(WIN32)
target_link_libraries(${PROJECT_NAME} PUBLIC psapi.lib ws2_32.lib)