cmake: Fix windows python.cmake runtime issue

note: libprotobuf.dll depends on utf8_validity.dll
when tested it seems WinDLL() will load it so we may only
manually load highs.dll and libprotobuf.dll
which should implicitly load the three others:
abseil_dll.dll, zlib1.dll and utf8_validity.dll
This commit is contained in:
Mizux Seiha
2024-10-30 13:09:07 +01:00
parent 7053436950
commit 53fa48120f
3 changed files with 153 additions and 120 deletions

View File

@@ -430,23 +430,29 @@ configure_file(
${PROJECT_BINARY_DIR}/python/LICENSE
COPYONLY)
set(is_windows "$<PLATFORM_ID:Windows>")
set(is_not_windows "$<NOT:$<PLATFORM_ID:Windows>>")
set(need_zlib_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_ZLIB}>>")
set(need_unix_zlib_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_ZLIB}>>")
set(need_windows_zlib_lib "$<AND:${is_windows},$<BOOL:${BUILD_ZLIB}>>")
set(need_absl_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_absl}>>")
set(need_unix_absl_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_absl}>>")
set(need_windows_absl_lib "$<AND:${is_windows},$<BOOL:${BUILD_absl}>>")
set(need_re2_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_re2}>>")
set(need_unix_re2_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_re2}>>")
set(need_windows_re2_lib "$<AND:${is_windows},$<BOOL:${BUILD_re2}>>")
set(need_protobuf_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_Protobuf}>>")
set(need_unix_protobuf_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_Protobuf}>>")
set(need_windows_protobuf_lib "$<AND:${is_windows},$<BOOL:${BUILD_Protobuf}>>")
set(need_coinutils_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_CoinUtils}>>")
set(need_osi_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_Osi}>>")
set(need_clp_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_Clp}>>")
set(need_cgl_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_Cgl}>>")
set(need_cbc_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_Cbc}>>")
set(need_unix_coinutils_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_CoinUtils}>>")
set(need_unix_osi_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_Osi}>>")
set(need_unix_clp_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_Clp}>>")
set(need_unix_cgl_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_Cgl}>>")
set(need_unix_cbc_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_Cbc}>>")
set(need_highs_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_HIGHS}>>")
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>")
@@ -454,138 +460,142 @@ add_custom_command(
OUTPUT python/ortools_timestamp
COMMAND ${CMAKE_COMMAND} -E remove -f ortools_timestamp
COMMAND ${CMAKE_COMMAND} -E make_directory ${PYTHON_PROJECT}/.libs
# Don't need to copy static lib on Windows.
COMMAND ${CMAKE_COMMAND} -E
$<IF:${need_zlib_lib},copy,true>
$<${need_zlib_lib}:$<TARGET_SONAME_FILE:ZLIB::ZLIB>>
$<IF:$<BOOL:${BUILD_ZLIB}>,copy,true>
$<${need_unix_zlib_lib}:$<TARGET_SONAME_FILE:ZLIB::ZLIB>>
$<${need_windows_zlib_lib}:$<TARGET_FILE:ZLIB::ZLIB>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E
$<IF:${need_absl_lib},copy,true>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::base>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::bad_any_cast_impl>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::bad_optional_access>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::bad_variant_access>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::city>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::civil_time>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::cord>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::cord_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::cordz_functions>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::cordz_handle>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::cordz_info>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::crc32c>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::crc_cord_state>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::crc_cpu_detect>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::crc_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::debugging_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::decode_rust_punycode>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::demangle_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::demangle_rust>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::die_if_null>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::examine_stack>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::exponential_biased>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_commandlineflag>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_commandlineflag_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_config>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_marshalling>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_parse>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_private_handle_accessor>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_program_name>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_reflection>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_usage>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_usage_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::graphcycles_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::hash>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::hashtablez_sampler>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::int128>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::kernel_timeout_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::leak_check>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_entry>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_flags>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_globals>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_initialize>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_check_op>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_conditions>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_fnmatch>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_format>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_globals>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_log_sink_set>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_message>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_nullguard>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_proto>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_severity>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::log_sink>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::low_level_hash>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::malloc_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::random_distributions>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_platform>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_pool_urbg>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_randen>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_randen_hwaes>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_randen_hwaes_impl>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_randen_slow>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_seed_material>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::random_seed_gen_exception>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::random_seed_sequences>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::raw_hash_set>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::raw_logging_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::spinlock_wait>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::stacktrace>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::status>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::statusor>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::str_format_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::strerror>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::string_view>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::strings>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::strings_internal>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::symbolize>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::synchronization>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::throw_delegate>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::time>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::time_zone>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::utf8_for_code_point>>
$<${need_absl_lib}:$<TARGET_SONAME_FILE:absl::vlog_config_internal>>
$<IF:$<BOOL:${BUILD_absl}>,copy,true>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::base>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::bad_any_cast_impl>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::bad_optional_access>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::bad_variant_access>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::city>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::civil_time>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::cord>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::cord_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::cordz_functions>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::cordz_handle>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::cordz_info>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::crc32c>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::crc_cord_state>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::crc_cpu_detect>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::crc_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::debugging_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::decode_rust_punycode>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::demangle_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::demangle_rust>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::die_if_null>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::examine_stack>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::exponential_biased>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_commandlineflag>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_commandlineflag_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_config>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_marshalling>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_parse>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_private_handle_accessor>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_program_name>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_reflection>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_usage>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::flags_usage_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::graphcycles_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::hash>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::hashtablez_sampler>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::int128>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::kernel_timeout_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::leak_check>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_entry>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_flags>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_globals>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_initialize>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_check_op>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_conditions>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_fnmatch>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_format>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_globals>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_log_sink_set>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_message>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_nullguard>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_internal_proto>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_severity>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::log_sink>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::low_level_hash>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::malloc_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::random_distributions>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_platform>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_pool_urbg>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_randen>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_randen_hwaes>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_randen_hwaes_impl>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_randen_slow>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::random_internal_seed_material>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::random_seed_gen_exception>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::random_seed_sequences>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::raw_hash_set>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::raw_logging_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::spinlock_wait>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::stacktrace>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::status>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::statusor>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::str_format_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::strerror>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::string_view>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::strings>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::strings_internal>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::symbolize>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::synchronization>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::throw_delegate>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::time>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::time_zone>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::utf8_for_code_point>>
$<${need_unix_absl_lib}:$<TARGET_SONAME_FILE:absl::vlog_config_internal>>
$<${need_windows_absl_lib}:$<TARGET_FILE:absl::abseil_dll>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E
$<IF:${need_re2_lib},copy,true>
$<${need_re2_lib}:$<TARGET_SONAME_FILE:re2::re2>>
$<IF:${need_unix_re2_lib},copy,true>
$<${need_unix_re2_lib}:$<TARGET_SONAME_FILE:re2::re2>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E
$<IF:${need_protobuf_lib},copy,true>
$<${need_protobuf_lib}:$<TARGET_SONAME_FILE:protobuf::libprotobuf>>
$<${need_protobuf_lib}:$<TARGET_SONAME_FILE:utf8_validity>>
$<IF:$<BOOL:${BUILD_Protobuf}>,copy,true>
$<${need_unix_protobuf_lib}:$<TARGET_SONAME_FILE:protobuf::libprotobuf>>
$<${need_unix_protobuf_lib}:$<TARGET_SONAME_FILE:utf8_validity>>
$<${need_windows_protobuf_lib}:$<TARGET_FILE:protobuf::libprotobuf>>
$<${need_windows_protobuf_lib}:$<TARGET_FILE:utf8_validity>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E
$<IF:${need_coinutils_lib},copy,true>
$<${need_coinutils_lib}:$<TARGET_SONAME_FILE:Coin::CoinUtils>>
$<IF:${need_unix_coinutils_lib},copy,true>
$<${need_unix_coinutils_lib}:$<TARGET_SONAME_FILE:Coin::CoinUtils>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E
$<IF:${need_osi_lib},copy,true>
$<${need_osi_lib}:$<TARGET_SONAME_FILE:Coin::Osi>>
$<IF:${need_unix_osi_lib},copy,true>
$<${need_unix_osi_lib}:$<TARGET_SONAME_FILE:Coin::Osi>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E
$<IF:${need_clp_lib},copy,true>
$<${need_clp_lib}:$<TARGET_SONAME_FILE:Coin::Clp>>
$<${need_clp_lib}:$<TARGET_SONAME_FILE:Coin::OsiClp>>
$<${need_clp_lib}:$<TARGET_SONAME_FILE:Coin::ClpSolver>>
$<IF:${need_unix_clp_lib},copy,true>
$<${need_unix_clp_lib}:$<TARGET_SONAME_FILE:Coin::Clp>>
$<${need_unix_clp_lib}:$<TARGET_SONAME_FILE:Coin::OsiClp>>
$<${need_unix_clp_lib}:$<TARGET_SONAME_FILE:Coin::ClpSolver>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E
$<IF:${need_cgl_lib},copy,true>
$<${need_cgl_lib}:$<TARGET_SONAME_FILE:Coin::Cgl>>
$<IF:${need_unix_cgl_lib},copy,true>
$<${need_unix_cgl_lib}:$<TARGET_SONAME_FILE:Coin::Cgl>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E
$<IF:${need_cbc_lib},copy,true>
$<${need_cbc_lib}:$<TARGET_SONAME_FILE:Coin::Cbc>>
$<${need_cbc_lib}:$<TARGET_SONAME_FILE:Coin::OsiCbc>>
$<${need_cbc_lib}:$<TARGET_SONAME_FILE:Coin::CbcSolver>>
$<IF:${need_unix_cbc_lib},copy,true>
$<${need_unix_cbc_lib}:$<TARGET_SONAME_FILE:Coin::Cbc>>
$<${need_unix_cbc_lib}:$<TARGET_SONAME_FILE:Coin::OsiCbc>>
$<${need_unix_cbc_lib}:$<TARGET_SONAME_FILE:Coin::CbcSolver>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E
$<IF:${need_highs_lib},copy,true>
$<${need_highs_lib}:$<TARGET_SONAME_FILE:highs>>
$<IF:$<BOOL:${BUILD_HIGHS}>,copy,true>
$<${need_unix_highs_lib}:$<TARGET_SONAME_FILE:highs>>
$<${need_windows_highs_lib}:$<TARGET_FILE:highs>>
${PYTHON_PROJECT}/.libs
COMMAND ${CMAKE_COMMAND} -E

View File

@@ -43,3 +43,23 @@ This repository contains several component:
__docformat__ = "markdown" # explicitly disable rST processing above.
__version__ = "@PROJECT_VERSION@"
import os
def _load_ortools_libs():
"""Load shared libraries on Windows"""
if os.name == "nt":
try:
from ctypes import WinDLL
basedir = os.path.dirname(__file__)
except:
pass
else:
for dll in ["zlib1.dll", "abseil_dll.dll", "utf8_validity.dll", "libprotobuf.dll", "highs.dll"]:
dll_path = os.path.join(basedir, ".libs", dll)
if os.path.exists(dll_path):
print(f"load {dll_path}...")
WinDLL(dll_path)
_load_ortools_libs()

View File

@@ -50,7 +50,10 @@ setup(
'immutabledict >= 3.0.0',
],
package_data={
'@PYTHON_PROJECT@':[$<$<STREQUAL:$<TARGET_PROPERTY:@PROJECT_NAME@,TYPE>,SHARED_LIBRARY>:'.libs/*','../$<TARGET_SONAME_FILE_NAME:@PROJECT_NAME@>'>],
'@PYTHON_PROJECT@':[
'.libs/*',
$<$<STREQUAL:$<TARGET_PROPERTY:@PROJECT_NAME@,TYPE>,SHARED_LIBRARY>:'../$<TARGET_SONAME_FILE_NAME:@PROJECT_NAME@>'>
],
'@PYTHON_PROJECT@.init.python':[
'$<TARGET_FILE_NAME:init_pybind11>',
'*.pyi'