Skip to content

Commit

Permalink
[issue1122] Specify using shared CPLEX libraries in Windows.
Browse files Browse the repository at this point in the history
The previous fix to find CPLEX libraries in the absence of dynamic ones caused
Windows to not find CPLEX anymore. We fix this by distinguishing the type of
imported library depending on the operating system.
  • Loading branch information
ClemensBuechner authored Oct 19, 2023
1 parent a063111 commit 300e66d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/search/cmake/FindCplex.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@
set(IMPORTED_CONFIGURATIONS "Debug" "Release")
set(HINT_PATHS ${cplex_DIR} $ENV{cplex_DIR})

add_library(cplex::cplex IMPORTED UNKNOWN)
if(WIN32)
# On Windows we have to declare the library as SHARED to correctly
# communicate the location of the dll and impllib files.
add_library(cplex::cplex IMPORTED SHARED)
else()
# On Linux, the CPLEX installer sometimes does not provide dynamic
# libraries. If they are absent, we fall back to static ones further down,
# hence we mark the type unknown here.
add_library(cplex::cplex IMPORTED UNKNOWN)
endif()
set_target_properties(cplex::cplex PROPERTIES
IMPORTED_CONFIGURATIONS "${IMPORTED_CONFIGURATIONS}"
)
Expand Down

0 comments on commit 300e66d

Please sign in to comment.