cmake: Fix and enabled shared lib support with MSVC

* Add decldll to proto
* rework init to make it working for MSVC
* fix test_xprs_interface build
dotnet: Fix MSVC shared libs support
  * Fix csproj to include libortools.dll
java: Fix MSVC shared_libs support
  * Fix runtime jar to include libortools.dll
python: Fix MSVC shared_libs support
  * fix __init__.py.in loading for MSVC
This commit is contained in:
Corentin Le Molgat
2025-01-27 02:01:03 -08:00
committed by Mizux Seiha
parent befa5f7a4f
commit da058cd01b
36 changed files with 189 additions and 100 deletions

View File

@@ -38,6 +38,7 @@ if(UNIX AND NOT APPLE AND NOT (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD"))
list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE32")
endif()
endif()
list(APPEND CMAKE_SWIG_FLAGS "-DOR_DLL=")
# Find Python 3
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
@@ -450,6 +451,8 @@ set(need_unix_highs_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_HIGHS}>>")
set(need_windows_highs_lib "$<AND:${is_windows},$<BOOL:${BUILD_HIGHS}>>")
set(is_ortools_shared "$<STREQUAL:$<TARGET_PROPERTY:ortools,TYPE>,SHARED_LIBRARY>")
set(need_unix_ortools_lib "$<AND:${is_not_windows},${is_ortools_shared}>")
set(need_windows_ortools_lib "$<AND:${is_windows},${is_ortools_shared}>")
add_custom_command(
OUTPUT python/ortools_timestamp
@@ -596,7 +599,8 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E
$<IF:${is_ortools_shared},copy,true>
$<${is_ortools_shared}:$<TARGET_SONAME_FILE:ortools>>
$<${need_unix_ortools_lib}:$<TARGET_SONAME_FILE:${PROJECT_NAMESPACE}::ortools>>
$<${need_windows_ortools_lib}:$<TARGET_FILE:${PROJECT_NAMESPACE}::ortools>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E touch ${PROJECT_BINARY_DIR}/python/ortools_timestamp
MAIN_DEPENDENCY