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:
committed by
Mizux Seiha
parent
befa5f7a4f
commit
da058cd01b
@@ -74,7 +74,7 @@ if(UNIX)
|
|||||||
endforeach()
|
endforeach()
|
||||||
else()
|
else()
|
||||||
# Currently Only support static build for windows
|
# Currently Only support static build for windows
|
||||||
option(BUILD_SHARED_LIBS "Build shared libraries (.dll)." OFF)
|
option(BUILD_SHARED_LIBS "Build shared libraries (.dll)." ON)
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
|
||||||
|
|||||||
@@ -45,9 +45,13 @@ set(OR_TOOLS_COMPILE_DEFINITIONS)
|
|||||||
set(OR_TOOLS_COMPILE_OPTIONS)
|
set(OR_TOOLS_COMPILE_OPTIONS)
|
||||||
set(OR_TOOLS_LINK_OPTIONS)
|
set(OR_TOOLS_LINK_OPTIONS)
|
||||||
|
|
||||||
if(BUILD_SHARED_LIBS)
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "OR_TOOLS_AS_DYNAMIC_LIB")
|
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "OR_BUILD_DLL")
|
||||||
|
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "OR_PROTO_DLL=__declspec(dllimport)")
|
||||||
|
else()
|
||||||
|
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "OR_PROTO_DLL=")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Optional built-in components
|
# Optional built-in components
|
||||||
if(BUILD_LP_PARSER)
|
if(BUILD_LP_PARSER)
|
||||||
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_LP_PARSER")
|
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_LP_PARSER")
|
||||||
@@ -356,7 +360,7 @@ function(generate_proto_library)
|
|||||||
COMMAND ${PROTOC_PRG}
|
COMMAND ${PROTOC_PRG}
|
||||||
"--proto_path=${PROJECT_SOURCE_DIR}"
|
"--proto_path=${PROJECT_SOURCE_DIR}"
|
||||||
${PROTO_DIRS}
|
${PROTO_DIRS}
|
||||||
"--cpp_out=${PROJECT_BINARY_DIR}"
|
"--cpp_out=dllexport_decl=OR_PROTO_DLL:${PROJECT_BINARY_DIR}"
|
||||||
${PROTO_FILE}
|
${PROTO_FILE}
|
||||||
DEPENDS ${PROTO_FILE} ${PROTOC_PRG}
|
DEPENDS ${PROTO_FILE} ${PROTOC_PRG}
|
||||||
COMMENT "Generate C++ protocol buffer for ${PROTO_FILE}"
|
COMMENT "Generate C++ protocol buffer for ${PROTO_FILE}"
|
||||||
@@ -383,6 +387,12 @@ function(generate_proto_library)
|
|||||||
#$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
|
#$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
|
||||||
)
|
)
|
||||||
target_compile_definitions(${PROTO_NAME}_proto PUBLIC ${OR_TOOLS_COMPILE_DEFINITIONS})
|
target_compile_definitions(${PROTO_NAME}_proto PUBLIC ${OR_TOOLS_COMPILE_DEFINITIONS})
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(${PROTO_NAME}_proto INTERFACE "OR_PROTO_DLL=__declspec(dllimport)")
|
||||||
|
target_compile_definitions(${PROTO_NAME}_proto PRIVATE "OR_PROTO_DLL=__declspec(dllexport)")
|
||||||
|
else()
|
||||||
|
target_compile_definitions(${PROTO_NAME}_proto PUBLIC "OR_PROTO_DLL=")
|
||||||
|
endif()
|
||||||
target_compile_options(${PROTO_NAME}_proto PUBLIC ${OR_TOOLS_COMPILE_OPTIONS})
|
target_compile_options(${PROTO_NAME}_proto PUBLIC ${OR_TOOLS_COMPILE_OPTIONS})
|
||||||
target_link_libraries(${PROTO_NAME}_proto PUBLIC protobuf::libprotobuf ${PROTO_LINK_LIBRARIES})
|
target_link_libraries(${PROTO_NAME}_proto PUBLIC protobuf::libprotobuf ${PROTO_LINK_LIBRARIES})
|
||||||
add_library(${PROJECT_NAMESPACE}::${PROTO_NAME}_proto ALIAS ${PROTO_NAME}_proto)
|
add_library(${PROJECT_NAMESPACE}::${PROTO_NAME}_proto ALIAS ${PROTO_NAME}_proto)
|
||||||
@@ -447,6 +457,9 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
|
|||||||
target_compile_features(${PROJECT_NAME} PUBLIC
|
target_compile_features(${PROJECT_NAME} PUBLIC
|
||||||
$<IF:$<CXX_COMPILER_ID:MSVC>,cxx_std_20,cxx_std_17>)
|
$<IF:$<CXX_COMPILER_ID:MSVC>,cxx_std_20,cxx_std_17>)
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC ${OR_TOOLS_COMPILE_DEFINITIONS})
|
target_compile_definitions(${PROJECT_NAME} PUBLIC ${OR_TOOLS_COMPILE_DEFINITIONS})
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE OR_EXPORT)
|
||||||
|
endif()
|
||||||
target_compile_options(${PROJECT_NAME} PUBLIC ${OR_TOOLS_COMPILE_OPTIONS})
|
target_compile_options(${PROJECT_NAME} PUBLIC ${OR_TOOLS_COMPILE_OPTIONS})
|
||||||
target_link_options(${PROJECT_NAME} INTERFACE ${OR_TOOLS_LINK_OPTIONS})
|
target_link_options(${PROJECT_NAME} INTERFACE ${OR_TOOLS_LINK_OPTIONS})
|
||||||
# Properties
|
# Properties
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ include(UseSWIG)
|
|||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE64")
|
list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE64")
|
||||||
endif()
|
endif()
|
||||||
|
list(APPEND CMAKE_SWIG_FLAGS "-DOR_DLL=")
|
||||||
|
|
||||||
# Find dotnet cli
|
# Find dotnet cli
|
||||||
find_program(DOTNET_EXECUTABLE NAMES dotnet)
|
find_program(DOTNET_EXECUTABLE NAMES dotnet)
|
||||||
@@ -395,6 +396,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(need_windows_highs_lib "$<AND:${is_windows},$<BOOL:${BUILD_HIGHS}>>")
|
||||||
|
|
||||||
set(is_ortools_shared "$<STREQUAL:$<TARGET_PROPERTY:ortools,TYPE>,SHARED_LIBRARY>")
|
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}>")
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
${PROJECT_SOURCE_DIR}/ortools/dotnet/${DOTNET_PACKAGE}.runtime.csproj.in
|
${PROJECT_SOURCE_DIR}/ortools/dotnet/${DOTNET_PACKAGE}.runtime.csproj.in
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ endif()
|
|||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE64")
|
list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE64")
|
||||||
endif()
|
endif()
|
||||||
|
list(APPEND CMAKE_SWIG_FLAGS "-DOR_DLL=")
|
||||||
|
|
||||||
# Find Java and JNI
|
# Find Java and JNI
|
||||||
find_package(Java 1.8 COMPONENTS Development REQUIRED)
|
find_package(Java 1.8 COMPONENTS Development REQUIRED)
|
||||||
@@ -298,14 +299,13 @@ set(need_unix_highs_lib "$<AND:${is_not_windows},$<BOOL:${BUILD_HIGHS}>>")
|
|||||||
set(need_windows_highs_lib "$<AND:${is_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(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(
|
add_custom_command(
|
||||||
OUTPUT ${JAVA_NATIVE_PROJECT_DIR}/timestamp
|
OUTPUT ${JAVA_NATIVE_PROJECT_DIR}/timestamp
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove -f timestamp
|
COMMAND ${CMAKE_COMMAND} -E remove -f timestamp
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${JAVA_RESSOURCES_PATH}/${JAVA_NATIVE_PROJECT}
|
||||||
$<TARGET_FILE:jni${JAVA_ARTIFACT}>
|
|
||||||
$<${is_ortools_shared}:$<TARGET_SONAME_FILE:ortools>>
|
|
||||||
${JAVA_RESSOURCES_PATH}/${JAVA_NATIVE_PROJECT}/
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E
|
COMMAND ${CMAKE_COMMAND} -E
|
||||||
$<IF:$<BOOL:${BUILD_ZLIB}>,copy,true>
|
$<IF:$<BOOL:${BUILD_ZLIB}>,copy,true>
|
||||||
$<${need_unix_zlib_lib}:$<TARGET_SONAME_FILE:ZLIB::ZLIB>>
|
$<${need_unix_zlib_lib}:$<TARGET_SONAME_FILE:ZLIB::ZLIB>>
|
||||||
@@ -445,6 +445,16 @@ add_custom_command(
|
|||||||
$<${need_windows_highs_lib}:$<TARGET_FILE:highs>>
|
$<${need_windows_highs_lib}:$<TARGET_FILE:highs>>
|
||||||
${JAVA_RESSOURCES_PATH}/${JAVA_NATIVE_PROJECT}/
|
${JAVA_RESSOURCES_PATH}/${JAVA_NATIVE_PROJECT}/
|
||||||
|
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E
|
||||||
|
$<IF:${is_ortools_shared},copy,true>
|
||||||
|
$<${need_unix_ortools_lib}:$<TARGET_SONAME_FILE:${PROJECT_NAMESPACE}::ortools>>
|
||||||
|
$<${need_windows_ortools_lib}:$<TARGET_FILE:${PROJECT_NAMESPACE}::ortools>>
|
||||||
|
${JAVA_RESSOURCES_PATH}/${JAVA_NATIVE_PROJECT}/
|
||||||
|
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
$<TARGET_FILE:jni${JAVA_ARTIFACT}>
|
||||||
|
${JAVA_RESSOURCES_PATH}/${JAVA_NATIVE_PROJECT}/
|
||||||
|
|
||||||
COMMAND ${MAVEN_EXECUTABLE} compile -B
|
COMMAND ${MAVEN_EXECUTABLE} compile -B
|
||||||
COMMAND ${MAVEN_EXECUTABLE} package -B $<$<BOOL:${BUILD_FAT_JAR}>:-Dfatjar=true>
|
COMMAND ${MAVEN_EXECUTABLE} package -B $<$<BOOL:${BUILD_FAT_JAR}>:-Dfatjar=true>
|
||||||
COMMAND ${MAVEN_EXECUTABLE} install -B $<$<BOOL:${SKIP_GPG}>:-Dgpg.skip=true>
|
COMMAND ${MAVEN_EXECUTABLE} install -B $<$<BOOL:${SKIP_GPG}>:-Dgpg.skip=true>
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ if(UNIX AND NOT APPLE AND NOT (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD"))
|
|||||||
list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE32")
|
list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE32")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
list(APPEND CMAKE_SWIG_FLAGS "-DOR_DLL=")
|
||||||
|
|
||||||
# Find Python 3
|
# Find Python 3
|
||||||
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
|
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(need_windows_highs_lib "$<AND:${is_windows},$<BOOL:${BUILD_HIGHS}>>")
|
||||||
|
|
||||||
set(is_ortools_shared "$<STREQUAL:$<TARGET_PROPERTY:ortools,TYPE>,SHARED_LIBRARY>")
|
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(
|
add_custom_command(
|
||||||
OUTPUT python/ortools_timestamp
|
OUTPUT python/ortools_timestamp
|
||||||
@@ -596,7 +599,8 @@ add_custom_command(
|
|||||||
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E
|
COMMAND ${CMAKE_COMMAND} -E
|
||||||
$<IF:${is_ortools_shared},copy,true>
|
$<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
|
${PYTHON_PROJECT}/.libs
|
||||||
COMMAND ${CMAKE_COMMAND} -E touch ${PROJECT_BINARY_DIR}/python/ortools_timestamp
|
COMMAND ${CMAKE_COMMAND} -E touch ${PROJECT_BINARY_DIR}/python/ortools_timestamp
|
||||||
MAIN_DEPENDENCY
|
MAIN_DEPENDENCY
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ ABSL_FLAG(
|
|||||||
int, size, 0,
|
int, size, 0,
|
||||||
"Size of the problem. If equal to 0, will test several increasing sizes.");
|
"Size of the problem. If equal to 0, will test several increasing sizes.");
|
||||||
ABSL_FLAG(bool, use_symmetry, false, "Use Symmetry Breaking methods");
|
ABSL_FLAG(bool, use_symmetry, false, "Use Symmetry Breaking methods");
|
||||||
ABSL_DECLARE_FLAG(bool, cp_disable_solve);
|
|
||||||
|
|
||||||
static const int kNumSolutions[] = {
|
static const int kNumSolutions[] = {
|
||||||
1, 0, 0, 2, 10, 4, 40, 92, 352, 724, 2680, 14200, 73712, 365596, 2279184};
|
1, 0, 0, 2, 10, 4, 40, 92, 352, 724, 2680, 14200, 73712, 365596, 2279184};
|
||||||
|
|||||||
@@ -379,9 +379,17 @@ cc_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "base_export",
|
||||||
|
hdrs = ["base_export.h"],
|
||||||
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "macros",
|
name = "macros",
|
||||||
hdrs = ["macros.h"],
|
hdrs = ["macros.h"],
|
||||||
|
deps = [
|
||||||
|
":base_export",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ target_compile_definitions(${NAME} PRIVATE
|
|||||||
-DOR_TOOLS_MAJOR=${PROJECT_VERSION_MAJOR}
|
-DOR_TOOLS_MAJOR=${PROJECT_VERSION_MAJOR}
|
||||||
-DOR_TOOLS_MINOR=${PROJECT_VERSION_MINOR}
|
-DOR_TOOLS_MINOR=${PROJECT_VERSION_MINOR}
|
||||||
-DOR_TOOLS_PATCH=${PROJECT_VERSION_PATCH})
|
-DOR_TOOLS_PATCH=${PROJECT_VERSION_PATCH})
|
||||||
if(MSVC)
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
target_compile_definitions(${NAME} PRIVATE -DOR_TOOLS_EXPORTS)
|
target_compile_definitions(${NAME} PUBLIC "OR_BUILD_DLL")
|
||||||
|
target_compile_definitions(${NAME} PRIVATE "OR_EXPORT")
|
||||||
endif()
|
endif()
|
||||||
target_include_directories(${NAME} PRIVATE
|
target_include_directories(${NAME} PRIVATE
|
||||||
${PROJECT_SOURCE_DIR}
|
${PROJECT_SOURCE_DIR}
|
||||||
|
|||||||
@@ -14,17 +14,17 @@
|
|||||||
#ifndef OR_TOOLS_BASE_BASE_EXPORT_H_
|
#ifndef OR_TOOLS_BASE_BASE_EXPORT_H_
|
||||||
#define OR_TOOLS_BASE_BASE_EXPORT_H_
|
#define OR_TOOLS_BASE_BASE_EXPORT_H_
|
||||||
|
|
||||||
#if defined(_MSC_VER) && defined(OR_TOOLS_AS_DYNAMIC_LIB)
|
#if defined(_MSC_VER) && defined(OR_BUILD_DLL)
|
||||||
// Annoying stuff for windows -- makes sure clients can import these functions
|
// Annoying stuff for windows -- makes sure clients can import these functions
|
||||||
#if defined(OR_TOOLS_EXPORTS)
|
#if defined(OR_EXPORT)
|
||||||
#define BASE_EXPORT __declspec(dllexport)
|
#define OR_DLL __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define BASE_EXPORT __declspec(dllimport)
|
#define OR_DLL __declspec(dllimport)
|
||||||
#endif // defined(OR_TOOLS_EXPORT)
|
#endif // defined(OR_EXPORT)
|
||||||
#endif // _MSC_VER && OR_TOOLS_AS_DYNAMIC_LIB
|
#endif // _MSC_VER && OR_BUILD_DLL
|
||||||
|
|
||||||
#ifndef BASE_EXPORT
|
#ifndef OR_DLL
|
||||||
#define BASE_EXPORT
|
#define OR_DLL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // OR_TOOLS_BASE_BASE_EXPORT_H_
|
#endif // OR_TOOLS_BASE_BASE_EXPORT_H_
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include <cstdlib> // for size_t.
|
#include <cstdlib> // for size_t.
|
||||||
|
|
||||||
|
#include "ortools/base/base_export.h" // for OR_DLL
|
||||||
|
|
||||||
#define COMPILE_ASSERT(x, msg)
|
#define COMPILE_ASSERT(x, msg)
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ add_library(${NAME} OBJECT ${_SRCS})
|
|||||||
set_target_properties(${NAME} PROPERTIES
|
set_target_properties(${NAME} PROPERTIES
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
)
|
)
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(${NAME} PUBLIC "OR_BUILD_DLL")
|
||||||
|
target_compile_definitions(${NAME} PRIVATE "OR_EXPORT")
|
||||||
|
endif()
|
||||||
target_include_directories(${NAME} PRIVATE
|
target_include_directories(${NAME} PRIVATE
|
||||||
${PROJECT_SOURCE_DIR}
|
${PROJECT_SOURCE_DIR}
|
||||||
${PROJECT_BINARY_DIR})
|
${PROJECT_BINARY_DIR})
|
||||||
|
|||||||
@@ -104,7 +104,8 @@
|
|||||||
#include "ortools/util/tuple_set.h"
|
#include "ortools/util/tuple_set.h"
|
||||||
|
|
||||||
#if !defined(SWIG)
|
#if !defined(SWIG)
|
||||||
ABSL_DECLARE_FLAG(int64_t, cp_random_seed);
|
OR_DLL ABSL_DECLARE_FLAG(int64_t, cp_random_seed);
|
||||||
|
OR_DLL ABSL_DECLARE_FLAG(bool, cp_disable_solve);
|
||||||
#endif // !defined(SWIG)
|
#endif // !defined(SWIG)
|
||||||
|
|
||||||
class File;
|
class File;
|
||||||
@@ -3606,7 +3607,7 @@ class Demon : public BaseObject {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Model visitor.
|
/// Model visitor.
|
||||||
class ModelVisitor : public BaseObject {
|
class OR_DLL ModelVisitor : public BaseObject {
|
||||||
public:
|
public:
|
||||||
/// Constraint and Expression types.
|
/// Constraint and Expression types.
|
||||||
static const char kAbs[];
|
static const char kAbs[];
|
||||||
@@ -4822,7 +4823,7 @@ class ImprovementSearchLimit : public SearchLimit {
|
|||||||
/// cannot be accessed any more. An interval var is automatically marked
|
/// cannot be accessed any more. An interval var is automatically marked
|
||||||
/// as unperformed when it is not consistent anymore (start greater
|
/// as unperformed when it is not consistent anymore (start greater
|
||||||
/// than end, duration < 0...)
|
/// than end, duration < 0...)
|
||||||
class IntervalVar : public PropagationBaseObject {
|
class OR_DLL IntervalVar : public PropagationBaseObject {
|
||||||
public:
|
public:
|
||||||
/// The smallest acceptable value to be returned by StartMin()
|
/// The smallest acceptable value to be returned by StartMin()
|
||||||
static const int64_t kMinValidValue;
|
static const int64_t kMinValidValue;
|
||||||
|
|||||||
@@ -2291,7 +2291,7 @@ class LocalSearchFilterManager : public BaseObject {
|
|||||||
int64_t accepted_value_;
|
int64_t accepted_value_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IntVarLocalSearchFilter : public LocalSearchFilter {
|
class OR_DLL IntVarLocalSearchFilter : public LocalSearchFilter {
|
||||||
public:
|
public:
|
||||||
explicit IntVarLocalSearchFilter(const std::vector<IntVar*>& vars);
|
explicit IntVarLocalSearchFilter(const std::vector<IntVar*>& vars);
|
||||||
~IntVarLocalSearchFilter() override;
|
~IntVarLocalSearchFilter() override;
|
||||||
@@ -2421,7 +2421,7 @@ class LocalSearchMonitor : public SearchMonitor {
|
|||||||
void Install() override;
|
void Install() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BooleanVar : public IntVar {
|
class OR_DLL BooleanVar : public IntVar {
|
||||||
public:
|
public:
|
||||||
static const int kUnboundBooleanVarValue;
|
static const int kUnboundBooleanVarValue;
|
||||||
|
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ class PathsMetadata {
|
|||||||
std::vector<int64_t> path_of_node_;
|
std::vector<int64_t> path_of_node_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RoutingModel {
|
class OR_DLL RoutingModel {
|
||||||
public:
|
public:
|
||||||
/// Types of precedence policy applied to pickup and delivery pairs.
|
/// Types of precedence policy applied to pickup and delivery pairs.
|
||||||
enum PickupAndDeliveryPolicy {
|
enum PickupAndDeliveryPolicy {
|
||||||
@@ -2837,7 +2837,7 @@ class RoutingModel {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Routing model visitor.
|
/// Routing model visitor.
|
||||||
class RoutingModelVisitor : public BaseObject {
|
class OR_DLL RoutingModelVisitor : public BaseObject {
|
||||||
public:
|
public:
|
||||||
/// Constraint types.
|
/// Constraint types.
|
||||||
static const char kLightElement[];
|
static const char kLightElement[];
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace operations_research {
|
|||||||
/// indices range between 0 and n-1, where n = number of vehicles * 2 (for start
|
/// indices range between 0 and n-1, where n = number of vehicles * 2 (for start
|
||||||
/// and end nodes) + number of non-start or end nodes.
|
/// and end nodes) + number of non-start or end nodes.
|
||||||
///
|
///
|
||||||
class RoutingIndexManager {
|
class OR_DLL RoutingIndexManager {
|
||||||
public:
|
public:
|
||||||
typedef RoutingNodeIndex NodeIndex;
|
typedef RoutingNodeIndex NodeIndex;
|
||||||
static const int64_t kUnassigned;
|
static const int64_t kUnassigned;
|
||||||
|
|||||||
@@ -26,8 +26,6 @@
|
|||||||
<!-- If ortools is built as a STATIC_LIBRARY (e.g. Windows) then we don't have to include it -->
|
<!-- If ortools is built as a STATIC_LIBRARY (e.g. Windows) then we don't have to include it -->
|
||||||
<Content Include="
|
<Content Include="
|
||||||
$<TARGET_FILE:google-ortools-native>
|
$<TARGET_FILE:google-ortools-native>
|
||||||
$<@is_ortools_shared@:;$<TARGET_SONAME_FILE:ortools>>
|
|
||||||
|
|
||||||
$<@need_unix_zlib_lib@:;$<TARGET_SONAME_FILE:ZLIB::ZLIB>>
|
$<@need_unix_zlib_lib@:;$<TARGET_SONAME_FILE:ZLIB::ZLIB>>
|
||||||
$<@need_windows_zlib_lib@:;$<TARGET_FILE:ZLIB::ZLIB>>
|
$<@need_windows_zlib_lib@:;$<TARGET_FILE:ZLIB::ZLIB>>
|
||||||
|
|
||||||
@@ -133,6 +131,9 @@
|
|||||||
|
|
||||||
$<@need_unix_highs_lib@:;$<TARGET_SONAME_FILE:highs>>
|
$<@need_unix_highs_lib@:;$<TARGET_SONAME_FILE:highs>>
|
||||||
$<@need_windows_highs_lib@:;$<TARGET_FILE:highs>>
|
$<@need_windows_highs_lib@:;$<TARGET_FILE:highs>>
|
||||||
|
|
||||||
|
$<@need_unix_ortools_lib@:;$<TARGET_SONAME_FILE:ortools>>
|
||||||
|
$<@need_windows_ortools_lib@:;$<TARGET_FILE:ortools>>
|
||||||
">
|
">
|
||||||
<PackagePath>runtimes/@DOTNET_RID@/native/%(Filename)%(Extension)</PackagePath>
|
<PackagePath>runtimes/@DOTNET_RID@/native/%(Filename)%(Extension)</PackagePath>
|
||||||
<Pack>true</Pack>
|
<Pack>true</Pack>
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ add_library(${NAME} OBJECT ${_SRCS})
|
|||||||
set_target_properties(${NAME} PROPERTIES
|
set_target_properties(${NAME} PROPERTIES
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
)
|
)
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(${NAME} PUBLIC "OR_BUILD_DLL")
|
||||||
|
target_compile_definitions(${NAME} PRIVATE "OR_EXPORT")
|
||||||
|
endif()
|
||||||
target_include_directories(${NAME} PRIVATE
|
target_include_directories(${NAME} PRIVATE
|
||||||
${PROJECT_SOURCE_DIR}
|
${PROJECT_SOURCE_DIR}
|
||||||
${PROJECT_BINARY_DIR})
|
${PROJECT_BINARY_DIR})
|
||||||
|
|||||||
@@ -214,9 +214,9 @@
|
|||||||
#include "ortools/util/zvector.h"
|
#include "ortools/util/zvector.h"
|
||||||
|
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
ABSL_DECLARE_FLAG(int64_t, assignment_alpha);
|
OR_DLL ABSL_DECLARE_FLAG(int64_t, assignment_alpha);
|
||||||
ABSL_DECLARE_FLAG(int, assignment_progress_logging_period);
|
OR_DLL ABSL_DECLARE_FLAG(int, assignment_progress_logging_period);
|
||||||
ABSL_DECLARE_FLAG(bool, assignment_stack_order);
|
OR_DLL ABSL_DECLARE_FLAG(bool, assignment_stack_order);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace operations_research {
|
namespace operations_research {
|
||||||
|
|||||||
@@ -29,8 +29,6 @@
|
|||||||
#include "ortools/base/gmock.h"
|
#include "ortools/base/gmock.h"
|
||||||
#include "ortools/graph/graph.h"
|
#include "ortools/graph/graph.h"
|
||||||
|
|
||||||
ABSL_DECLARE_FLAG(bool, assignment_stack_order);
|
|
||||||
|
|
||||||
namespace operations_research {
|
namespace operations_research {
|
||||||
|
|
||||||
using ::testing::Eq;
|
using ::testing::Eq;
|
||||||
|
|||||||
@@ -16,10 +16,12 @@ package(default_visibility = ["//visibility:public"])
|
|||||||
cc_library(
|
cc_library(
|
||||||
name = "init",
|
name = "init",
|
||||||
hdrs = ["init.h"],
|
hdrs = ["init.h"],
|
||||||
|
srcs = ["init.cc"],
|
||||||
deps = [
|
deps = [
|
||||||
"//ortools/base",
|
"//ortools/base",
|
||||||
"//ortools/gurobi:environment",
|
"//ortools/gurobi:environment",
|
||||||
"//ortools/sat:cp_model_solver",
|
"//ortools/sat:cp_model_solver",
|
||||||
|
"//ortools/sat:cp_model_solver_helpers",
|
||||||
"@com_google_absl//absl/flags:flag",
|
"@com_google_absl//absl/flags:flag",
|
||||||
"@com_google_absl//absl/log",
|
"@com_google_absl//absl/log",
|
||||||
"@com_google_absl//absl/log:globals",
|
"@com_google_absl//absl/log:globals",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
file(GLOB _SRCS "*.h")
|
file(GLOB _SRCS "*.h" "*.cc")
|
||||||
set(NAME ${PROJECT_NAME}_init)
|
set(NAME ${PROJECT_NAME}_init)
|
||||||
|
|
||||||
# Will be merge in libortools.so
|
# Will be merge in libortools.so
|
||||||
@@ -21,6 +21,10 @@ set_target_properties(${NAME} PROPERTIES
|
|||||||
LINKER_LANGUAGE CXX
|
LINKER_LANGUAGE CXX
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
)
|
)
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(${NAME} PUBLIC "OR_BUILD_DLL")
|
||||||
|
target_compile_definitions(${NAME} PRIVATE "OR_EXPORT")
|
||||||
|
endif()
|
||||||
target_include_directories(${NAME} PRIVATE
|
target_include_directories(${NAME} PRIVATE
|
||||||
${PROJECT_SOURCE_DIR}
|
${PROJECT_SOURCE_DIR}
|
||||||
${PROJECT_BINARY_DIR})
|
${PROJECT_BINARY_DIR})
|
||||||
|
|||||||
46
ortools/init/init.cc
Normal file
46
ortools/init/init.cc
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
// Copyright 2010-2025 Google LLC
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "ortools/init/init.h"
|
||||||
|
|
||||||
|
#include "absl/flags/flag.h"
|
||||||
|
#include "absl/flags/usage.h"
|
||||||
|
#include "absl/log/globals.h"
|
||||||
|
#include "absl/log/initialize.h"
|
||||||
|
#include "ortools/gurobi/environment.h"
|
||||||
|
#include "ortools/sat/cp_model_solver.h"
|
||||||
|
#include "ortools/sat/cp_model_solver_helpers.h"
|
||||||
|
|
||||||
|
namespace operations_research {
|
||||||
|
void CppBridge::InitLogging(const std::string& usage) {
|
||||||
|
absl::SetProgramUsageMessage(usage);
|
||||||
|
absl::InitializeLog();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CppBridge::SetFlags(const CppFlags& flags) {
|
||||||
|
absl::SetFlag(&FLAGS_stderrthreshold, flags.stderrthreshold);
|
||||||
|
absl::EnableLogPrefix(flags.log_prefix);
|
||||||
|
if (!flags.cp_model_dump_prefix.empty()) {
|
||||||
|
absl::SetFlag(&FLAGS_cp_model_dump_prefix, flags.cp_model_dump_prefix);
|
||||||
|
}
|
||||||
|
absl::SetFlag(&FLAGS_cp_model_dump_models, flags.cp_model_dump_models);
|
||||||
|
absl::SetFlag(&FLAGS_cp_model_dump_submodels,
|
||||||
|
flags.cp_model_dump_submodels);
|
||||||
|
absl::SetFlag(&FLAGS_cp_model_dump_response, flags.cp_model_dump_response);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CppBridge::LoadGurobiSharedLibrary(const std::string& full_library_path) {
|
||||||
|
return LoadGurobiDynamicLibrary({full_library_path}).ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace operations_research
|
||||||
@@ -18,20 +18,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/flags/flag.h"
|
|
||||||
#include "absl/flags/usage.h"
|
|
||||||
#include "absl/log/globals.h"
|
|
||||||
#include "absl/log/initialize.h"
|
|
||||||
#include "ortools/base/logging.h"
|
#include "ortools/base/logging.h"
|
||||||
#include "ortools/base/version.h"
|
#include "ortools/base/version.h"
|
||||||
#include "ortools/gurobi/environment.h"
|
#include "ortools/sat/cp_model_solver_helpers.h"
|
||||||
#include "ortools/sat/cp_model_solver.h"
|
|
||||||
|
|
||||||
ABSL_DECLARE_FLAG(std::string, cp_model_dump_prefix);
|
|
||||||
ABSL_DECLARE_FLAG(bool, cp_model_dump_models);
|
|
||||||
ABSL_DECLARE_FLAG(bool, cp_model_dump_submodels);
|
|
||||||
ABSL_DECLARE_FLAG(bool, cp_model_dump_response);
|
|
||||||
ABSL_DECLARE_FLAG(int, stderrthreshold);
|
|
||||||
|
|
||||||
namespace operations_research {
|
namespace operations_research {
|
||||||
|
|
||||||
@@ -97,10 +86,7 @@ class CppBridge {
|
|||||||
*
|
*
|
||||||
* This must be called once before any other library from OR-Tools are used.
|
* This must be called once before any other library from OR-Tools are used.
|
||||||
*/
|
*/
|
||||||
static void InitLogging(const std::string& usage) {
|
static void InitLogging(const std::string& usage);
|
||||||
absl::SetProgramUsageMessage(usage);
|
|
||||||
absl::InitializeLog();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown the C++ logging layer.
|
* Shutdown the C++ logging layer.
|
||||||
@@ -115,17 +101,7 @@ class CppBridge {
|
|||||||
/**
|
/**
|
||||||
* Sets all the C++ flags contained in the CppFlags structure.
|
* Sets all the C++ flags contained in the CppFlags structure.
|
||||||
*/
|
*/
|
||||||
static void SetFlags(const CppFlags& flags) {
|
static void SetFlags(const CppFlags& flags);
|
||||||
absl::SetFlag(&FLAGS_stderrthreshold, flags.stderrthreshold);
|
|
||||||
absl::EnableLogPrefix(flags.log_prefix);
|
|
||||||
if (!flags.cp_model_dump_prefix.empty()) {
|
|
||||||
absl::SetFlag(&FLAGS_cp_model_dump_prefix, flags.cp_model_dump_prefix);
|
|
||||||
}
|
|
||||||
absl::SetFlag(&FLAGS_cp_model_dump_models, flags.cp_model_dump_models);
|
|
||||||
absl::SetFlag(&FLAGS_cp_model_dump_submodels,
|
|
||||||
flags.cp_model_dump_submodels);
|
|
||||||
absl::SetFlag(&FLAGS_cp_model_dump_response, flags.cp_model_dump_response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the gurobi shared library.
|
* Load the gurobi shared library.
|
||||||
@@ -135,9 +111,7 @@ class CppBridge {
|
|||||||
* You need to pass the full path, including the shared library file.
|
* You need to pass the full path, including the shared library file.
|
||||||
* It returns true if the library was found and correctly loaded.
|
* It returns true if the library was found and correctly loaded.
|
||||||
*/
|
*/
|
||||||
static bool LoadGurobiSharedLibrary(const std::string& full_library_path) {
|
static bool LoadGurobiSharedLibrary(const std::string& full_library_path);
|
||||||
return LoadGurobiDynamicLibrary({full_library_path}).ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a temporary C++ byte array.
|
* Delete a temporary C++ byte array.
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class Loader {
|
|||||||
Path tempPath = unpackNativeResources(resourceURI);
|
Path tempPath = unpackNativeResources(resourceURI);
|
||||||
// libraries order does matter !
|
// libraries order does matter !
|
||||||
List<String> dlls = Arrays.asList(
|
List<String> dlls = Arrays.asList(
|
||||||
"zlib1", "abseil_dll", "re2", "utf8_validity", "libprotobuf", "highs", "jniortools");
|
"zlib1", "abseil_dll", "re2", "utf8_validity", "libprotobuf", "highs", "ortools", "jniortools");
|
||||||
for (String dll : dlls) {
|
for (String dll : dlls) {
|
||||||
try {
|
try {
|
||||||
// System.out.println("System.load(" + dll + ")");
|
// System.out.println("System.load(" + dll + ")");
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ add_library(${NAME} OBJECT ${_SRCS})
|
|||||||
set_target_properties(${NAME} PROPERTIES
|
set_target_properties(${NAME} PROPERTIES
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
)
|
)
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(${NAME} PUBLIC "OR_BUILD_DLL")
|
||||||
|
target_compile_definitions(${NAME} PRIVATE "OR_EXPORT")
|
||||||
|
endif()
|
||||||
target_include_directories(${NAME} PUBLIC
|
target_include_directories(${NAME} PUBLIC
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
||||||
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>)
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>)
|
||||||
|
|||||||
@@ -165,9 +165,9 @@
|
|||||||
#include "ortools/port/proto_utils.h"
|
#include "ortools/port/proto_utils.h"
|
||||||
#include "ortools/util/lazy_mutable_copy.h"
|
#include "ortools/util/lazy_mutable_copy.h"
|
||||||
|
|
||||||
ABSL_DECLARE_FLAG(bool, linear_solver_enable_verbose_output);
|
OR_DLL ABSL_DECLARE_FLAG(bool, linear_solver_enable_verbose_output);
|
||||||
ABSL_DECLARE_FLAG(bool, log_verification_errors);
|
OR_DLL ABSL_DECLARE_FLAG(bool, log_verification_errors);
|
||||||
ABSL_DECLARE_FLAG(bool, verify_solution);
|
OR_DLL ABSL_DECLARE_FLAG(bool, verify_solution);
|
||||||
|
|
||||||
namespace operations_research {
|
namespace operations_research {
|
||||||
|
|
||||||
@@ -1469,7 +1469,7 @@ class MPConstraint {
|
|||||||
* instead. We need to figure out how to deal with the subtleties of
|
* instead. We need to figure out how to deal with the subtleties of
|
||||||
* the default values.
|
* the default values.
|
||||||
*/
|
*/
|
||||||
class MPSolverParameters {
|
class OR_DLL MPSolverParameters {
|
||||||
public:
|
public:
|
||||||
/// Enumeration of parameters that take continuous values.
|
/// Enumeration of parameters that take continuous values.
|
||||||
enum DoubleParam {
|
enum DoubleParam {
|
||||||
|
|||||||
@@ -120,13 +120,6 @@ ABSL_FLAG(std::string, sol_file, "",
|
|||||||
ABSL_FLAG(std::string, dump_mps, "",
|
ABSL_FLAG(std::string, dump_mps, "",
|
||||||
"If non-empty, dumps the model in mps format there.");
|
"If non-empty, dumps the model in mps format there.");
|
||||||
|
|
||||||
ABSL_DECLARE_FLAG(bool, verify_solution); // Defined in ./linear_solver.cc
|
|
||||||
ABSL_DECLARE_FLAG(bool,
|
|
||||||
log_verification_errors); // Defined in ./linear_solver.cc
|
|
||||||
ABSL_DECLARE_FLAG(
|
|
||||||
bool,
|
|
||||||
linear_solver_enable_verbose_output); // Defined in ./linear_solver.cc
|
|
||||||
|
|
||||||
static const char kUsageStr[] =
|
static const char kUsageStr[] =
|
||||||
"Run MPSolver on the given input file. Many formats are supported: \n"
|
"Run MPSolver on the given input file. Many formats are supported: \n"
|
||||||
" - a .mps or .mps.gz file,\n"
|
" - a .mps or .mps.gz file,\n"
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ cc_library(
|
|||||||
name = "solver_debug",
|
name = "solver_debug",
|
||||||
srcs = ["solver_debug.cc"],
|
srcs = ["solver_debug.cc"],
|
||||||
hdrs = ["solver_debug.h"],
|
hdrs = ["solver_debug.h"],
|
||||||
|
deps = ["//ortools/base:base_export"],
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ list(FILTER _SRCS EXCLUDE REGEX "/[^/]*_test\\.cc$")
|
|||||||
set(NAME ${PROJECT_NAME}_math_opt_core)
|
set(NAME ${PROJECT_NAME}_math_opt_core)
|
||||||
add_library(${NAME} OBJECT ${_SRCS})
|
add_library(${NAME} OBJECT ${_SRCS})
|
||||||
set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(${NAME} PUBLIC "OR_BUILD_DLL")
|
||||||
|
target_compile_definitions(${NAME} PRIVATE "OR_EXPORT")
|
||||||
|
endif()
|
||||||
target_include_directories(${NAME} PUBLIC
|
target_include_directories(${NAME} PUBLIC
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
||||||
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>)
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>)
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "ortools/base/base_export.h"
|
||||||
|
|
||||||
namespace operations_research {
|
namespace operations_research {
|
||||||
namespace math_opt {
|
namespace math_opt {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@@ -26,7 +28,7 @@ namespace internal {
|
|||||||
// This variable is intended to be used by MathOpt unit tests in other languages
|
// This variable is intended to be used by MathOpt unit tests in other languages
|
||||||
// to test the proper garbage collection. It should never be used in any other
|
// to test the proper garbage collection. It should never be used in any other
|
||||||
// context.
|
// context.
|
||||||
extern std::atomic<int64_t> debug_num_solver;
|
OR_DLL extern std::atomic<int64_t> debug_num_solver;
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace math_opt
|
} // namespace math_opt
|
||||||
|
|||||||
@@ -55,11 +55,11 @@ def _load_ortools_libs():
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
for dll in ["zlib1.dll", "abseil_dll.dll", "utf8_validity.dll", "re2.dll", "libprotobuf.dll", "highs.dll"]:
|
for dll in ["zlib1.dll", "abseil_dll.dll", "utf8_validity.dll", "re2.dll", "libprotobuf.dll", "highs.dll", "ortools.dll"]:
|
||||||
dll_path = os.path.join(basedir, ".libs", dll)
|
dll_path = os.path.join(basedir, ".libs", dll)
|
||||||
if os.path.exists(dll_path):
|
if os.path.exists(dll_path):
|
||||||
print(f"load {dll_path}...")
|
print(f"load {dll_path}...")
|
||||||
WinDLL(dll_path)
|
WinDLL(dll_path)
|
||||||
|
|
||||||
|
|
||||||
_load_ortools_libs()
|
_load_ortools_libs()
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#include "ortools/sat/model.h"
|
#include "ortools/sat/model.h"
|
||||||
#include "ortools/sat/sat_parameters.pb.h"
|
#include "ortools/sat/sat_parameters.pb.h"
|
||||||
|
|
||||||
|
ABSL_DECLARE_FLAG(bool, cp_model_dump_response);
|
||||||
|
|
||||||
namespace operations_research {
|
namespace operations_research {
|
||||||
namespace sat {
|
namespace sat {
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ add_library(${NAME} OBJECT ${_SRCS})
|
|||||||
set_target_properties(${NAME} PROPERTIES
|
set_target_properties(${NAME} PROPERTIES
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
)
|
)
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(${NAME} PUBLIC "OR_BUILD_DLL")
|
||||||
|
target_compile_definitions(${NAME} PRIVATE "OR_EXPORT")
|
||||||
|
endif()
|
||||||
target_include_directories(${NAME} PRIVATE
|
target_include_directories(${NAME} PRIVATE
|
||||||
${PROJECT_SOURCE_DIR}
|
${PROJECT_SOURCE_DIR}
|
||||||
${PROJECT_BINARY_DIR})
|
${PROJECT_BINARY_DIR})
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
* Enables changing the behavior of the TimeLimit class to use -b usertime
|
* Enables changing the behavior of the TimeLimit class to use -b usertime
|
||||||
* instead of \b walltime. This is mainly useful for benchmarks.
|
* instead of \b walltime. This is mainly useful for benchmarks.
|
||||||
*/
|
*/
|
||||||
ABSL_DECLARE_FLAG(bool, time_limit_use_usertime);
|
OR_DLL ABSL_DECLARE_FLAG(bool, time_limit_use_usertime);
|
||||||
|
|
||||||
namespace operations_research {
|
namespace operations_research {
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ namespace operations_research {
|
|||||||
*/
|
*/
|
||||||
// TODO(user): The expression "deterministic time" should be replaced with
|
// TODO(user): The expression "deterministic time" should be replaced with
|
||||||
// "number of operations" to avoid confusion with "real" time.
|
// "number of operations" to avoid confusion with "real" time.
|
||||||
class TimeLimit {
|
class OR_DLL TimeLimit {
|
||||||
public:
|
public:
|
||||||
static const double kSafetyBufferSeconds; // See the .cc for the value.
|
static const double kSafetyBufferSeconds; // See the .cc for the value.
|
||||||
static const int kHistorySize;
|
static const int kHistorySize;
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ set_target_properties(${NAME} PROPERTIES
|
|||||||
CXX_EXTENSIONS OFF
|
CXX_EXTENSIONS OFF
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
)
|
)
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(${NAME} PUBLIC "OR_BUILD_DLL")
|
||||||
|
target_compile_definitions(${NAME} PRIVATE "OR_EXPORT")
|
||||||
|
endif()
|
||||||
target_include_directories(${NAME} PRIVATE
|
target_include_directories(${NAME} PRIVATE
|
||||||
${PROJECT_SOURCE_DIR}
|
${PROJECT_SOURCE_DIR}
|
||||||
${PROJECT_BINARY_DIR})
|
${PROJECT_BINARY_DIR})
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
|
#include "ortools/base/macros.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
typedef struct xo_prob_struct* XPRSprob;
|
typedef struct xo_prob_struct* XPRSprob;
|
||||||
@@ -487,21 +488,21 @@ extern std::function<int(XPRSprob prob, int control, int value)> XPRSsetintcontr
|
|||||||
extern std::function<int(XPRSprob prob, int control, XPRSint64 value)> XPRSsetintcontrol64;
|
extern std::function<int(XPRSprob prob, int control, XPRSint64 value)> XPRSsetintcontrol64;
|
||||||
extern std::function<int(XPRSprob prob, int control, double value)> XPRSsetdblcontrol;
|
extern std::function<int(XPRSprob prob, int control, double value)> XPRSsetdblcontrol;
|
||||||
extern std::function<int(XPRSprob prob, int control, const char* value)> XPRSsetstrcontrol;
|
extern std::function<int(XPRSprob prob, int control, const char* value)> XPRSsetstrcontrol;
|
||||||
extern std::function<int(XPRSprob prob, int control, int* p_value)> XPRSgetintcontrol;
|
OR_DLL extern std::function<int(XPRSprob prob, int control, int* p_value)> XPRSgetintcontrol;
|
||||||
extern std::function<int(XPRSprob prob, int control, XPRSint64* p_value)> XPRSgetintcontrol64;
|
OR_DLL extern std::function<int(XPRSprob prob, int control, XPRSint64* p_value)> XPRSgetintcontrol64;
|
||||||
extern std::function<int(XPRSprob prob, int control, double* p_value)> XPRSgetdblcontrol;
|
OR_DLL extern std::function<int(XPRSprob prob, int control, double* p_value)> XPRSgetdblcontrol;
|
||||||
extern std::function<int(XPRSprob prob, int control, char* value, int maxbytes, int* p_nbytes)> XPRSgetstringcontrol;
|
OR_DLL extern std::function<int(XPRSprob prob, int control, char* value, int maxbytes, int* p_nbytes)> XPRSgetstringcontrol;
|
||||||
extern std::function<int(XPRSprob prob, int attrib, int* p_value)> XPRSgetintattrib;
|
OR_DLL extern std::function<int(XPRSprob prob, int attrib, int* p_value)> XPRSgetintattrib;
|
||||||
extern std::function<int(XPRSprob prob, int attrib, double* p_value)> XPRSgetdblattrib;
|
OR_DLL extern std::function<int(XPRSprob prob, int attrib, double* p_value)> XPRSgetdblattrib;
|
||||||
extern std::function<int(XPRSprob prob, const char* name, int* p_id, int* p_type)> XPRSgetcontrolinfo;
|
extern std::function<int(XPRSprob prob, const char* name, int* p_id, int* p_type)> XPRSgetcontrolinfo;
|
||||||
extern std::function<int(XPRSprob prob, const char* probname, int ncols, int nrows, const char rowtype[], const double rhs[], const double rng[], const double objcoef[], const int start[], const int collen[], const int rowind[], const double rowcoef[], const double lb[], const double ub[])> XPRSloadlp;
|
extern std::function<int(XPRSprob prob, const char* probname, int ncols, int nrows, const char rowtype[], const double rhs[], const double rng[], const double objcoef[], const int start[], const int collen[], const int rowind[], const double rowcoef[], const double lb[], const double ub[])> XPRSloadlp;
|
||||||
extern std::function<int(XPRSprob prob, const char* probname, int ncols, int nrows, const char rowtype[], const double rhs[], const double rng[], const double objcoef[], const XPRSint64 start[], const int collen[], const int rowind[], const double rowcoef[], const double lb[], const double ub[])> XPRSloadlp64;
|
extern std::function<int(XPRSprob prob, const char* probname, int ncols, int nrows, const char rowtype[], const double rhs[], const double rng[], const double objcoef[], const XPRSint64 start[], const int collen[], const int rowind[], const double rowcoef[], const double lb[], const double ub[])> XPRSloadlp64;
|
||||||
extern std::function<int(XPRSprob prob, double objcoef[], int first, int last)> XPRSgetobj;
|
OR_DLL extern std::function<int(XPRSprob prob, double objcoef[], int first, int last)> XPRSgetobj;
|
||||||
extern std::function<int(XPRSprob prob, double rhs[], int first, int last)> XPRSgetrhs;
|
OR_DLL extern std::function<int(XPRSprob prob, double rhs[], int first, int last)> XPRSgetrhs;
|
||||||
extern std::function<int(XPRSprob prob, double rng[], int first, int last)> XPRSgetrhsrange;
|
OR_DLL extern std::function<int(XPRSprob prob, double rng[], int first, int last)> XPRSgetrhsrange;
|
||||||
extern std::function<int(XPRSprob prob, double lb[], int first, int last)> XPRSgetlb;
|
OR_DLL extern std::function<int(XPRSprob prob, double lb[], int first, int last)> XPRSgetlb;
|
||||||
extern std::function<int(XPRSprob prob, double ub[], int first, int last)> XPRSgetub;
|
OR_DLL extern std::function<int(XPRSprob prob, double ub[], int first, int last)> XPRSgetub;
|
||||||
extern std::function<int(XPRSprob prob, int row, int col, double* p_coef)> XPRSgetcoef;
|
OR_DLL extern std::function<int(XPRSprob prob, int row, int col, double* p_coef)> XPRSgetcoef;
|
||||||
extern std::function<int(XPRSprob prob, int* status, double duals[], int first, int last)> XPRSgetduals;
|
extern std::function<int(XPRSprob prob, int* status, double duals[], int first, int last)> XPRSgetduals;
|
||||||
extern std::function<int(XPRSprob prob, int* status, double djs[], int first, int last)> XPRSgetredcosts;
|
extern std::function<int(XPRSprob prob, int* status, double djs[], int first, int last)> XPRSgetredcosts;
|
||||||
extern std::function<int(XPRSprob prob, int nrows, int ncoefs, const char rowtype[], const double rhs[], const double rng[], const int start[], const int colind[], const double rowcoef[])> XPRSaddrows;
|
extern std::function<int(XPRSprob prob, int nrows, int ncoefs, const char rowtype[], const double rhs[], const double rng[], const int start[], const int colind[], const double rowcoef[])> XPRSaddrows;
|
||||||
@@ -517,8 +518,8 @@ extern std::function<int(XPRSprob prob, int objsense)> XPRSchgobjsense;
|
|||||||
extern std::function<int(XPRSprob prob, char* errmsg)> XPRSgetlasterror;
|
extern std::function<int(XPRSprob prob, char* errmsg)> XPRSgetlasterror;
|
||||||
extern std::function<int(XPRSprob prob, int rowstat[], int colstat[])> XPRSgetbasis;
|
extern std::function<int(XPRSprob prob, int rowstat[], int colstat[])> XPRSgetbasis;
|
||||||
extern std::function<int(XPRSprob prob, const char* filename, const char* flags)> XPRSwriteprob;
|
extern std::function<int(XPRSprob prob, const char* filename, const char* flags)> XPRSwriteprob;
|
||||||
extern std::function<int(XPRSprob prob, char rowtype[], int first, int last)> XPRSgetrowtype;
|
OR_DLL extern std::function<int(XPRSprob prob, char rowtype[], int first, int last)> XPRSgetrowtype;
|
||||||
extern std::function<int(XPRSprob prob, char coltype[], int first, int last)> XPRSgetcoltype;
|
OR_DLL extern std::function<int(XPRSprob prob, char coltype[], int first, int last)> XPRSgetcoltype;
|
||||||
extern std::function<int(XPRSprob prob, int nbounds, const int colind[], const char bndtype[], const double bndval[])> XPRSchgbounds;
|
extern std::function<int(XPRSprob prob, int nbounds, const int colind[], const char bndtype[], const double bndval[])> XPRSchgbounds;
|
||||||
extern std::function<int(XPRSprob prob, int length, const double solval[], const int colind[], const char* name)> XPRSaddmipsol;
|
extern std::function<int(XPRSprob prob, int length, const double solval[], const int colind[], const char* name)> XPRSaddmipsol;
|
||||||
extern std::function<int(XPRSprob prob, double x[], double slack[], double duals[], double djs[])> XPRSgetlpsol;
|
extern std::function<int(XPRSprob prob, double x[], double slack[], double duals[], double djs[])> XPRSgetlpsol;
|
||||||
|
|||||||
Reference in New Issue
Block a user