diff --git a/cmake/cpp.cmake b/cmake/cpp.cmake index 4beffa28be..4d8478c95a 100644 --- a/cmake/cpp.cmake +++ b/cmake/cpp.cmake @@ -15,24 +15,22 @@ if(NOT BUILD_CXX) return() endif() -# Main Target -add_library(${PROJECT_NAME} "") -# Xcode fails to build if library doesn't contains at least one source file. -if(XCODE) - file(GENERATE - OUTPUT ${PROJECT_BINARY_DIR}/${PROJECT_NAME}/version.cpp - CONTENT "namespace {char* version = \"${PROJECT_VERSION}\";}") - target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}/version.cpp) -endif() +############# +## FLAGS ## +############# +set(OR_TOOLS_COMPILE_DEFINITIONS) +set(OR_TOOLS_COMPILE_OPTIONS) +set(OR_TOOLS_LINK_OPTIONS) if(BUILD_SHARED_LIBS) list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "OR_TOOLS_AS_DYNAMIC_LIB") endif() +# Mandatory built-in components list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_BOP" # enable BOP support "USE_GLOP" # enable GLOP support ) -# Optional Components +# Optional built-in components if(BUILD_LP_PARSER) list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_LP_PARSER") endif() @@ -40,7 +38,6 @@ if(BUILD_MATH_OPT) list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_MATH_OPT") set(MATH_OPT_DIR math_opt) endif() - # Optional solvers if(USE_COINOR) list(APPEND OR_TOOLS_COMPILE_DEFINITIONS @@ -81,6 +78,8 @@ endif() if(WIN32) list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "__WIN32__") endif() + +# Compiler options if(MSVC) list(APPEND OR_TOOLS_COMPILE_OPTIONS "/bigobj" # Allow big object @@ -120,76 +119,103 @@ else() list(APPEND OR_TOOLS_COMPILE_OPTIONS "-fwrapv") endif() -# Includes -target_include_directories(${PROJECT_NAME} INTERFACE - $ - $ - $ +# Link option +if(MSVC) + list(APPEND OR_TOOLS_LINK_OPTIONS + "/WHOLEARCHIVE:${PROJECT_NAME}" + ) +endif() + +################## +## PROTO FILE ## +################## +# Get Protobuf include dir +set(PROTO_DIRS) +get_target_property(protobuf_dirs protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES) +foreach(dir IN LISTS protobuf_dirs) + if (NOT "${dir}" MATCHES "INSTALL_INTERFACE|-NOTFOUND") + #message(STATUS "Adding proto path: ${dir}") + list(APPEND PROTO_DIRS "--proto_path=${dir}") + endif() +endforeach() + +# Generate C++ OBJECT library from proto files, +# e.g +# generate_proto_library( +# NAME +# ortools_proto +# FILES +# ortools/foo/foo.proto +# ortools/bar/bar.proto +# NO_ALIAS +# ) +function(generate_proto_library) + set(options NO_ALIAS) + set(oneValueArgs NAME) + set(multiValueArgs FILES LINK_LIBRARIES) + cmake_parse_arguments(PROTO + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} ) -# Compile options -if(MSVC) - set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD 20) -else() - set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD 17) -endif() -set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD_REQUIRED ON - CXX_EXTENSIONS OFF - ) -target_compile_features(${PROJECT_NAME} PUBLIC - $,cxx_std_20,cxx_std_17>) -target_compile_definitions(${PROJECT_NAME} PUBLIC ${OR_TOOLS_COMPILE_DEFINITIONS}) -target_compile_options(${PROJECT_NAME} PUBLIC ${OR_TOOLS_COMPILE_OPTIONS}) -if(MSVC) - target_link_options(${PROJECT_NAME} INTERFACE "/WHOLEARCHIVE:${PROJECT_NAME}") -endif() + if(NOT PROTOC_PRG) + message(FATAL_ERROR "protoc binary not found.") + endif() -# Properties -if(NOT APPLE) - set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION}) -else() - # Clang don't support version x.y.z with z > 255 - set_target_properties(${PROJECT_NAME} PROPERTIES - INSTALL_RPATH "@loader_path" - VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) -endif() -set_target_properties(${PROJECT_NAME} PROPERTIES - SOVERSION ${PROJECT_VERSION_MAJOR} - POSITION_INDEPENDENT_CODE ON - INTERFACE_POSITION_INDEPENDENT_CODE ON -) -set_target_properties(${PROJECT_NAME} PROPERTIES INTERFACE_${PROJECT_NAME}_MAJOR_VERSION ${PROJECT_VERSION_MAJOR}) -set_target_properties(${PROJECT_NAME} PROPERTIES COMPATIBLE_INTERFACE_STRING ${PROJECT_NAME}_MAJOR_VERSION) + # Generate proto C++ files. + set(PROTO_HDRS) + set(PROTO_SRCS) + foreach(PROTO_FILE IN LISTS PROTO_FILES) + #message(STATUS "protoc proto(cc): ${PROTO_FILE}") + get_filename_component(PROTO_DIR ${PROTO_FILE} DIRECTORY) + get_filename_component(PROTO_NAME_WE ${PROTO_FILE} NAME_WE) + set(PROTO_HDR ${PROJECT_BINARY_DIR}/${PROTO_DIR}/${PROTO_NAME_WE}.pb.h) + set(PROTO_SRC ${PROJECT_BINARY_DIR}/${PROTO_DIR}/${PROTO_NAME_WE}.pb.cc) + #message(STATUS "protoc hdr: ${PROTO_HDR}") + #message(STATUS "protoc src: ${PROTO_SRC}") + add_custom_command( + OUTPUT ${PROTO_SRC} ${PROTO_HDR} + COMMAND ${PROTOC_PRG} + "--proto_path=${PROJECT_SOURCE_DIR}" + ${PROTO_DIRS} + "--cpp_out=${PROJECT_BINARY_DIR}" + ${PROTO_FILE} + DEPENDS ${PROTO_FILE} ${PROTOC_PRG} + COMMENT "Generate C++ protocol buffer for ${PROTO_FILE}" + VERBATIM) + list(APPEND PROTO_HDRS ${PROTO_HDR}) + list(APPEND PROTO_SRCS ${PROTO_SRC}) + endforeach() -# Dependencies -target_link_libraries(${PROJECT_NAME} PUBLIC - ${CMAKE_DL_LIBS} - ZLIB::ZLIB - ${ABSL_DEPS} - protobuf::libprotobuf - ${RE2_DEPS} - ${COINOR_DEPS} - $<$:CPLEX::CPLEX> - $<$:GLPK::GLPK> - $<$:HIGHS::HIGHS> - ${PDLP_DEPS} - $<$:libscip> - $<$:XPRESS::XPRESS> - Threads::Threads) -if(WIN32) - target_link_libraries(${PROJECT_NAME} PUBLIC psapi.lib ws2_32.lib) -endif() - -# ALIAS -add_library(${PROJECT_NAMESPACE}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + # Create library + add_library(${PROTO_NAME}_proto OBJECT ${PROTO_SRCS} ${PROTO_HDRS}) + target_compile_features(${PROTO_NAME}_proto PUBLIC $,cxx_std_20,cxx_std_17>) + if(MSVC) + set_target_properties(${PROTO_NAME}_proto PROPERTIES CXX_STANDARD 20) + else() + set_target_properties(${PROTO_NAME}_proto PROPERTIES CXX_STANDARD 17) + endif() + set_target_properties(${PROTO_NAME}_proto PROPERTIES + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF + POSITION_INDEPENDENT_CODE ON) + target_include_directories(${PROTO_NAME}_proto PRIVATE + ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} + #$ + ) + target_compile_definitions(${PROTO_NAME}_proto PUBLIC ${OR_TOOLS_COMPILE_DEFINITIONS}) + target_compile_options(${PROTO_NAME}_proto PUBLIC ${OR_TOOLS_COMPILE_OPTIONS}) + target_link_libraries(${PROTO_NAME}_proto PUBLIC protobuf::libprotobuf ${PROTO_LINK_LIBRARIES}) + add_library(${PROJECT_NAMESPACE}::${PROTO_NAME}_proto ALIAS ${PROTO_NAME}_proto) + #message(FATAL_ERROR "Proto target alias: ${PROJECT_NAMESPACE}::${PROTO_NAME}_proto") +endfunction() # Generate Protobuf cpp sources -set(PROTO_HDRS) -set(PROTO_SRCS) -file(GLOB_RECURSE proto_files RELATIVE ${PROJECT_SOURCE_DIR} +set(OR_TOOLS_PROTO_FILES) +file(GLOB_RECURSE OR_TOOLS_PROTO_FILES RELATIVE ${PROJECT_SOURCE_DIR} "ortools/bop/*.proto" "ortools/constraint_solver/*.proto" "ortools/glop/*.proto" @@ -201,79 +227,86 @@ file(GLOB_RECURSE proto_files RELATIVE ${PROJECT_SOURCE_DIR} "ortools/scheduling/*.proto" "ortools/util/*.proto" ) +if(USE_PDLP OR BUILD_MATH_OPT) + file(GLOB_RECURSE PDLP_PROTO_FILES RELATIVE ${PROJECT_SOURCE_DIR} "ortools/pdlp/*.proto") + list(APPEND OR_TOOLS_PROTO_FILES ${PDLP_PROTO_FILES}) +endif() +if(USE_SCIP OR BUILD_MATH_OPT) + file(GLOB_RECURSE GSCIP_PROTO_FILES RELATIVE ${PROJECT_SOURCE_DIR} "ortools/gscip/*.proto") + list(APPEND OR_TOOLS_PROTO_FILES ${GSCIP_PROTO_FILES}) +endif() + +generate_proto_library( + NAME ${PROJECT_NAME} + FILES ${OR_TOOLS_PROTO_FILES}) + if(BUILD_MATH_OPT) - file(GLOB_RECURSE math_opt_proto_files RELATIVE ${PROJECT_SOURCE_DIR} + file(GLOB_RECURSE MATH_OPT_PROTO_FILES RELATIVE ${PROJECT_SOURCE_DIR} "ortools/math_opt/*.proto" "ortools/math_opt/solvers/*.proto" ) - list(APPEND proto_files ${math_opt_proto_files}) -endif() -if(USE_PDLP OR BUILD_MATH_OPT) - file(GLOB_RECURSE pdlp_proto_files RELATIVE ${PROJECT_SOURCE_DIR} "ortools/pdlp/*.proto") - list(APPEND proto_files ${pdlp_proto_files}) -endif() -if(USE_SCIP OR BUILD_MATH_OPT) - file(GLOB_RECURSE gscip_proto_files RELATIVE ${PROJECT_SOURCE_DIR} "ortools/gscip/*.proto") - list(APPEND proto_files ${gscip_proto_files}) + generate_proto_library( + NAME math_opt + FILES ${MATH_OPT_PROTO_FILES} + LINK_LIBRARIES ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) endif() -## Get Protobuf include dir -get_target_property(protobuf_dirs protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES) -foreach(dir IN LISTS protobuf_dirs) - if (NOT "${dir}" MATCHES "INSTALL_INTERFACE|-NOTFOUND") - message(STATUS "Adding proto path: ${dir}") - list(APPEND PROTO_DIRS "--proto_path=${dir}") - endif() -endforeach() - -foreach(PROTO_FILE IN LISTS proto_files) - #message(STATUS "protoc proto(cc): ${PROTO_FILE}") - get_filename_component(PROTO_DIR ${PROTO_FILE} DIRECTORY) - get_filename_component(PROTO_NAME ${PROTO_FILE} NAME_WE) - set(PROTO_HDR ${PROJECT_BINARY_DIR}/${PROTO_DIR}/${PROTO_NAME}.pb.h) - set(PROTO_SRC ${PROJECT_BINARY_DIR}/${PROTO_DIR}/${PROTO_NAME}.pb.cc) - #message(STATUS "protoc hdr: ${PROTO_HDR}") - #message(STATUS "protoc src: ${PROTO_SRC}") - add_custom_command( - OUTPUT ${PROTO_SRC} ${PROTO_HDR} - COMMAND ${PROTOC_PRG} - "--proto_path=${PROJECT_SOURCE_DIR}" - ${PROTO_DIRS} - "--cpp_out=${PROJECT_BINARY_DIR}" - ${PROTO_FILE} - DEPENDS ${PROTO_FILE} ${PROTOC_PRG} - COMMENT "Generate C++ protocol buffer for ${PROTO_FILE}" - VERBATIM) - list(APPEND PROTO_HDRS ${PROTO_HDR}) - list(APPEND PROTO_SRCS ${PROTO_SRC}) -endforeach() - +############### +## ORTOOLS ## +############### +# Main Target +add_library(${PROJECT_NAME} "") +# Compile options if(MSVC) - set(CMAKE_CXX_STANDARD 20) + set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20) else() - set(CMAKE_CXX_STANDARD 17) + set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17) endif() -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) +set_target_properties(${PROJECT_NAME} PROPERTIES + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF) +target_compile_features(${PROJECT_NAME} PUBLIC + $,cxx_std_20,cxx_std_17>) +target_compile_definitions(${PROJECT_NAME} PUBLIC ${OR_TOOLS_COMPILE_DEFINITIONS}) +target_compile_options(${PROJECT_NAME} PUBLIC ${OR_TOOLS_COMPILE_OPTIONS}) +target_link_options(${PROJECT_NAME} INTERFACE ${OR_TOOLS_LINK_OPTIONS}) +# Properties +if(NOT APPLE) + set_target_properties(${PROJECT_NAME} PROPERTIES + VERSION ${PROJECT_VERSION}) +else() + # Clang don't support version x.y.z with z > 255 + set_target_properties(${PROJECT_NAME} PROPERTIES + INSTALL_RPATH "@loader_path" + VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) +endif() +set_target_properties(${PROJECT_NAME} PROPERTIES + SOVERSION ${PROJECT_VERSION_MAJOR} + POSITION_INDEPENDENT_CODE ON + INTERFACE_POSITION_INDEPENDENT_CODE ON + INTERFACE_${PROJECT_NAME}_MAJOR_VERSION ${PROJECT_VERSION_MAJOR} + COMPATIBLE_INTERFACE_STRING ${PROJECT_NAME}_MAJOR_VERSION +) -#add_library(${PROJECT_NAME}_proto STATIC ${PROTO_SRCS} ${PROTO_HDRS}) -add_library(${PROJECT_NAME}_proto OBJECT ${PROTO_SRCS} ${PROTO_HDRS}) -set_target_properties(${PROJECT_NAME}_proto PROPERTIES - POSITION_INDEPENDENT_CODE ON) -target_include_directories(${PROJECT_NAME}_proto PRIVATE - ${PROJECT_SOURCE_DIR} - ${PROJECT_BINARY_DIR} - $ - ) -target_compile_definitions(${PROJECT_NAME}_proto PUBLIC ${OR_TOOLS_COMPILE_DEFINITIONS}) -target_compile_options(${PROJECT_NAME}_proto PUBLIC ${OR_TOOLS_COMPILE_OPTIONS}) -#target_link_libraries(${PROJECT_NAME}_proto PRIVATE protobuf::libprotobuf) -add_dependencies(${PROJECT_NAME}_proto protobuf::libprotobuf) -add_library(${PROJECT_NAMESPACE}::proto ALIAS ${PROJECT_NAME}_proto) -# Add ${PROJECT_NAMESPACE}::proto to libortools +# Includes +target_include_directories(${PROJECT_NAME} INTERFACE + $ + $ + $ +) +# Xcode fails to build if library doesn't contains at least one source file. +if(XCODE) + file(GENERATE + OUTPUT ${PROJECT_BINARY_DIR}/${PROJECT_NAME}/version.cpp + CONTENT "namespace {char* version = \"${PROJECT_VERSION}\";}") + target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}/version.cpp) +endif() + +# Add ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto to libortools #target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAMESPACE}::proto) -target_sources(${PROJECT_NAME} PRIVATE $) -add_dependencies(${PROJECT_NAME} ${PROJECT_NAMESPACE}::proto) +target_sources(${PROJECT_NAME} PRIVATE + $) +add_dependencies(${PROJECT_NAME} ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) foreach(SUBPROJECT IN ITEMS algorithms @@ -281,7 +314,6 @@ foreach(SUBPROJECT IN ITEMS bop constraint_solver ${GLPK_DIR} - ${MATH_OPT_DIR} ${PDLP_DIR} ${GSCIP_DIR} glop @@ -301,6 +333,16 @@ foreach(SUBPROJECT IN ITEMS add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_${SUBPROJECT}) endforeach() +if(BUILD_MATH_OPT) + #target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAMESPACE}::math_opt_proto) + target_sources(${PROJECT_NAME} PRIVATE + $) + add_dependencies(${PROJECT_NAME} ${PROJECT_NAMESPACE}::math_opt_proto) + + add_subdirectory(ortools/${MATH_OPT_DIR}) + target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}_math_opt) +endif() + add_subdirectory(ortools/linear_solver/wrappers) target_sources(${PROJECT_NAME} PRIVATE $) add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_linear_solver_wrappers) @@ -309,6 +351,27 @@ add_subdirectory(ortools/linear_solver/proto_solver) target_sources(${PROJECT_NAME} PRIVATE $) add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_linear_solver_proto_solver) +# Dependencies +target_link_libraries(${PROJECT_NAME} PUBLIC + ${CMAKE_DL_LIBS} + ZLIB::ZLIB + ${ABSL_DEPS} + protobuf::libprotobuf + ${RE2_DEPS} + ${COINOR_DEPS} + $<$:CPLEX::CPLEX> + $<$:GLPK::GLPK> + $<$:HIGHS::HIGHS> + ${PDLP_DEPS} + $<$:libscip> + $<$:XPRESS::XPRESS> + Threads::Threads) +if(WIN32) + target_link_libraries(${PROJECT_NAME} PUBLIC psapi.lib ws2_32.lib) +endif() +# ALIAS +add_library(${PROJECT_NAMESPACE}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + ############### ## Doc rules ## ############### diff --git a/ortools/algorithms/CMakeLists.txt b/ortools/algorithms/CMakeLists.txt index ba029a8986..5b441b2a87 100644 --- a/ortools/algorithms/CMakeLists.txt +++ b/ortools/algorithms/CMakeLists.txt @@ -29,5 +29,5 @@ target_link_libraries(${NAME} PRIVATE absl::memory absl::str_format protobuf::libprotobuf - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::algorithms ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::algorithms ALIAS ${NAME}) diff --git a/ortools/base/CMakeLists.txt b/ortools/base/CMakeLists.txt index 676883bac9..8917829d77 100644 --- a/ortools/base/CMakeLists.txt +++ b/ortools/base/CMakeLists.txt @@ -37,5 +37,5 @@ target_link_libraries(${NAME} PRIVATE absl::strings absl::str_format protobuf::libprotobuf - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::base ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::base ALIAS ${NAME}) diff --git a/ortools/bop/CMakeLists.txt b/ortools/bop/CMakeLists.txt index eabc249d54..488fbb5ce5 100644 --- a/ortools/bop/CMakeLists.txt +++ b/ortools/bop/CMakeLists.txt @@ -28,5 +28,5 @@ target_link_libraries(${NAME} PRIVATE absl::synchronization absl::str_format protobuf::libprotobuf - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::bop ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::bop ALIAS ${NAME}) diff --git a/ortools/constraint_solver/CMakeLists.txt b/ortools/constraint_solver/CMakeLists.txt index 55b6460c51..46c1d6d031 100644 --- a/ortools/constraint_solver/CMakeLists.txt +++ b/ortools/constraint_solver/CMakeLists.txt @@ -30,5 +30,5 @@ target_link_libraries(${NAME} PRIVATE absl::strings absl::str_format protobuf::libprotobuf - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::constraint_solver ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::constraint_solver ALIAS ${NAME}) diff --git a/ortools/glop/CMakeLists.txt b/ortools/glop/CMakeLists.txt index b78bdbc73a..37b7c7fc6e 100644 --- a/ortools/glop/CMakeLists.txt +++ b/ortools/glop/CMakeLists.txt @@ -28,5 +28,5 @@ target_link_libraries(${NAME} PRIVATE absl::strings absl::str_format protobuf::libprotobuf - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::glop ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::glop ALIAS ${NAME}) diff --git a/ortools/glpk/CMakeLists.txt b/ortools/glpk/CMakeLists.txt index dcc7cee82b..ffc4773460 100644 --- a/ortools/glpk/CMakeLists.txt +++ b/ortools/glpk/CMakeLists.txt @@ -32,4 +32,4 @@ target_link_libraries(${NAME} PRIVATE absl::strings absl::str_format $<$:GLPK::GLPK>) -#add_library(${PROJECT_NAME}::glpk ALIAS ${NAME}) +#add_library(${PROJECT_NAMESPACE}::glpk ALIAS ${NAME}) diff --git a/ortools/graph/CMakeLists.txt b/ortools/graph/CMakeLists.txt index 08b38608fc..118f103f4f 100644 --- a/ortools/graph/CMakeLists.txt +++ b/ortools/graph/CMakeLists.txt @@ -43,6 +43,6 @@ target_link_libraries(${NAME} PRIVATE absl::strings absl::str_format protobuf::libprotobuf - ${PROJECT_NAME}::proto + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto $<$:Coin::Cbc>) -#add_library(${PROJECT_NAME}::graph ALIAS ${NAME}) +#add_library(${PROJECT_NAMESPACE}::graph ALIAS ${NAME}) diff --git a/ortools/gscip/CMakeLists.txt b/ortools/gscip/CMakeLists.txt index 45b3b5ade2..5a9bfeec91 100644 --- a/ortools/gscip/CMakeLists.txt +++ b/ortools/gscip/CMakeLists.txt @@ -34,5 +34,5 @@ target_link_libraries(${NAME} PRIVATE absl::str_format protobuf::libprotobuf $<$:libscip> - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::gscip ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::gscip ALIAS ${NAME}) diff --git a/ortools/gurobi/CMakeLists.txt b/ortools/gurobi/CMakeLists.txt index 351431b462..3f696ac2fb 100644 --- a/ortools/gurobi/CMakeLists.txt +++ b/ortools/gurobi/CMakeLists.txt @@ -30,6 +30,6 @@ target_link_libraries(${NAME} PRIVATE absl::strings absl::str_format protobuf::libprotobuf - ${PROJECT_NAME}::proto + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto $<$:Coin::Cbc>) -#add_library(${PROJECT_NAME}::gurobi ALIAS ${NAME}) +#add_library(${PROJECT_NAMESPACE}::gurobi ALIAS ${NAME}) diff --git a/ortools/init/CMakeLists.txt b/ortools/init/CMakeLists.txt index 7bca3ba614..94539c0115 100644 --- a/ortools/init/CMakeLists.txt +++ b/ortools/init/CMakeLists.txt @@ -28,5 +28,5 @@ target_link_libraries(${NAME} PRIVATE absl::flags absl::strings protobuf::libprotobuf - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::init ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::init ALIAS ${NAME}) diff --git a/ortools/linear_solver/CMakeLists.txt b/ortools/linear_solver/CMakeLists.txt index 12406be166..bdea358e66 100644 --- a/ortools/linear_solver/CMakeLists.txt +++ b/ortools/linear_solver/CMakeLists.txt @@ -45,8 +45,8 @@ target_link_libraries(${NAME} PRIVATE $<$:Eigen3::Eigen> $<$:libscip> $<$:XPRESS::XPRESS> - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::linear_solver ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::linear_solver ALIAS ${NAME}) # solve add_executable(solve) diff --git a/ortools/linear_solver/proto_solver/CMakeLists.txt b/ortools/linear_solver/proto_solver/CMakeLists.txt index 2cf0e4e17b..9a18f1278d 100644 --- a/ortools/linear_solver/proto_solver/CMakeLists.txt +++ b/ortools/linear_solver/proto_solver/CMakeLists.txt @@ -45,8 +45,7 @@ target_link_libraries(${NAME} PRIVATE absl::strings absl::status absl::str_format - protobuf::libprotobuf $<$:Eigen3::Eigen> $<$:libscip> - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::linear_solver ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::linear_solver_proto_solver ALIAS ${NAME}) diff --git a/ortools/linear_solver/wrappers/CMakeLists.txt b/ortools/linear_solver/wrappers/CMakeLists.txt index b6f537d6fa..91b7405c39 100644 --- a/ortools/linear_solver/wrappers/CMakeLists.txt +++ b/ortools/linear_solver/wrappers/CMakeLists.txt @@ -25,7 +25,6 @@ target_include_directories(${NAME} PRIVATE ${PROJECT_BINARY_DIR}) target_link_libraries(${NAME} PRIVATE absl::status - protobuf::libprotobuf $<$:libscip> - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::_linear_solver_wrappers ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::linear_solver_wrappers ALIAS ${NAME}) diff --git a/ortools/lp_data/CMakeLists.txt b/ortools/lp_data/CMakeLists.txt index 255e0f2eab..3e36dee39d 100644 --- a/ortools/lp_data/CMakeLists.txt +++ b/ortools/lp_data/CMakeLists.txt @@ -29,5 +29,5 @@ target_link_libraries(${NAME} PRIVATE absl::str_format protobuf::libprotobuf ${RE2_DEPS} - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::lp_data ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::lp_data ALIAS ${NAME}) diff --git a/ortools/math_opt/CMakeLists.txt b/ortools/math_opt/CMakeLists.txt index b061e48cf7..9962dd558e 100644 --- a/ortools/math_opt/CMakeLists.txt +++ b/ortools/math_opt/CMakeLists.txt @@ -15,39 +15,27 @@ if(NOT BUILD_MATH_OPT) return() endif() -file(GLOB_RECURSE _SRCS "*.h" "*.cc") -list(FILTER _SRCS EXCLUDE REGEX "/[^/]*_test\\.cc$") -list(FILTER _SRCS EXCLUDE REGEX "/c_api/.*example") -list(FILTER _SRCS EXCLUDE REGEX "/tools/") -list(FILTER _SRCS EXCLUDE REGEX "/samples/") - -if(NOT USE_GLPK) - list(FILTER _SRCS EXCLUDE REGEX "/glpk/") - list(FILTER _SRCS EXCLUDE REGEX "/glpk_.*.h$") - list(FILTER _SRCS EXCLUDE REGEX "/glpk_.*.cc$") -endif() - -if(NOT USE_SCIP) - list(FILTER _SRCS EXCLUDE REGEX "/gscip/") - list(FILTER _SRCS EXCLUDE REGEX "/gscip_.*.h$") - list(FILTER _SRCS EXCLUDE REGEX "/gscip_.*.cc$") -endif() +add_subdirectory(core) +add_subdirectory(constraints) +add_subdirectory(cpp) +add_subdirectory(io) +add_subdirectory(labs) +add_subdirectory(solvers) +add_subdirectory(storage) +add_subdirectory(validators) set(NAME ${PROJECT_NAME}_math_opt) - -# Will be merge in libortools.so -#add_library(${NAME} STATIC ${_SRCS}) -add_library(${NAME} OBJECT ${_SRCS}) -set_target_properties(${NAME} PROPERTIES - POSITION_INDEPENDENT_CODE ON - ) -target_include_directories(${NAME} PUBLIC - $ - $) -target_link_libraries(${NAME} PRIVATE - absl::strings - protobuf::libprotobuf - $<$:GLPK::GLPK> - $<$:libscip> - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::math_opt ALIAS ${NAME}) +add_library(${NAME} OBJECT) +target_sources(${NAME} PUBLIC + $ + $ + $ + $ + $ + $ + $ +) +target_link_libraries(${NAME} INTERFACE + ${NAME}_constraints +) +install(TARGETS ${PROJECT_NAME}_math_opt EXPORT ${PROJECT_NAME}Targets) diff --git a/ortools/math_opt/constraints/CMakeLists.txt b/ortools/math_opt/constraints/CMakeLists.txt new file mode 100644 index 0000000000..b7111c866c --- /dev/null +++ b/ortools/math_opt/constraints/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright 2010-2022 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. + +add_subdirectory(indicator) +add_subdirectory(quadratic) +add_subdirectory(second_order_cone) +add_subdirectory(sos) +add_subdirectory(util) + +set(NAME ${PROJECT_NAME}_math_opt_constraints) +add_library(${NAME} OBJECT) +target_sources(${NAME} PUBLIC + $ + $ + $ + $ + $ +) +install(TARGETS ${PROJECT_NAME}_math_opt_constraints EXPORT ${PROJECT_NAME}Targets) diff --git a/ortools/math_opt/constraints/indicator/CMakeLists.txt b/ortools/math_opt/constraints/indicator/CMakeLists.txt new file mode 100644 index 0000000000..5ad80723de --- /dev/null +++ b/ortools/math_opt/constraints/indicator/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_constraints_indicator) +add_library(${NAME} OBJECT) + +file(GLOB _SRCS "*.h" "*.cc") +target_sources(${NAME} PRIVATE ${_SRCS}) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) +#install(TARGETS ${PROJECT_NAME}_math_opt_constraints_indicator EXPORT ${PROJECT_NAME}Targets) diff --git a/ortools/math_opt/constraints/quadratic/CMakeLists.txt b/ortools/math_opt/constraints/quadratic/CMakeLists.txt new file mode 100644 index 0000000000..4a365103c9 --- /dev/null +++ b/ortools/math_opt/constraints/quadratic/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_constraints_quadratic) +add_library(${NAME} OBJECT) + +file(GLOB _SRCS "*.h" "*.cc") +target_sources(${NAME} PRIVATE ${_SRCS}) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/math_opt/constraints/second_order_cone/CMakeLists.txt b/ortools/math_opt/constraints/second_order_cone/CMakeLists.txt new file mode 100644 index 0000000000..d57d3d7930 --- /dev/null +++ b/ortools/math_opt/constraints/second_order_cone/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_constraints_second_order_cone) +add_library(${NAME} OBJECT) + +file(GLOB _SRCS "*.h" "*.cc") +target_sources(${NAME} PRIVATE ${_SRCS}) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/math_opt/constraints/sos/CMakeLists.txt b/ortools/math_opt/constraints/sos/CMakeLists.txt new file mode 100644 index 0000000000..cf3214b56b --- /dev/null +++ b/ortools/math_opt/constraints/sos/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_constraints_sos) +add_library(${NAME} OBJECT) + +file(GLOB _SRCS "*.h" "*.cc") +target_sources(${NAME} PRIVATE ${_SRCS}) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/math_opt/constraints/util/CMakeLists.txt b/ortools/math_opt/constraints/util/CMakeLists.txt new file mode 100644 index 0000000000..379e615b45 --- /dev/null +++ b/ortools/math_opt/constraints/util/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_constraints_util) +add_library(${NAME} OBJECT) + +file(GLOB _SRCS "*.h" "*.cc") +target_sources(${NAME} PRIVATE ${_SRCS}) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/math_opt/core/CMakeLists.txt b/ortools/math_opt/core/CMakeLists.txt new file mode 100644 index 0000000000..f155fcff2c --- /dev/null +++ b/ortools/math_opt/core/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright 2010-2022 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. + +add_subdirectory(c_api) + +file(GLOB _SRCS "*.h" "*.cc") +list(FILTER _SRCS EXCLUDE REGEX "/[^/]*_test\\.cc$") + +set(NAME ${PROJECT_NAME}_math_opt_core) +add_library(${NAME} OBJECT ${_SRCS}) +target_sources(${NAME} PRIVATE $) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/math_opt/core/c_api/CMakeLists.txt b/ortools/math_opt/core/c_api/CMakeLists.txt new file mode 100644 index 0000000000..b943ca12e7 --- /dev/null +++ b/ortools/math_opt/core/c_api/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_core_c_api) +add_library(${NAME} OBJECT) + +target_sources(${NAME} PRIVATE solver.h solver.cc) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/math_opt/cpp/CMakeLists.txt b/ortools/math_opt/cpp/CMakeLists.txt new file mode 100644 index 0000000000..51085ee76c --- /dev/null +++ b/ortools/math_opt/cpp/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_cpp) +add_library(${NAME} OBJECT) + +file(GLOB _SRCS "*.h" "*.cc") +target_sources(${NAME} PRIVATE ${_SRCS}) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/math_opt/io/CMakeLists.txt b/ortools/math_opt/io/CMakeLists.txt new file mode 100644 index 0000000000..ef5100411b --- /dev/null +++ b/ortools/math_opt/io/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_io) +add_library(${NAME} OBJECT) + +file(GLOB _SRCS "*.h" "*.cc") +target_sources(${NAME} PRIVATE ${_SRCS}) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/math_opt/labs/CMakeLists.txt b/ortools/math_opt/labs/CMakeLists.txt new file mode 100644 index 0000000000..70e7410cae --- /dev/null +++ b/ortools/math_opt/labs/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_labs) +add_library(${NAME} OBJECT) + +file(GLOB _SRCS "*.h" "*.cc") +target_sources(${NAME} PRIVATE ${_SRCS}) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/math_opt/solvers/CMakeLists.txt b/ortools/math_opt/solvers/CMakeLists.txt new file mode 100644 index 0000000000..739dd4c8cb --- /dev/null +++ b/ortools/math_opt/solvers/CMakeLists.txt @@ -0,0 +1,42 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_solvers) +add_library(${NAME} OBJECT) + +file(GLOB_RECURSE _SRCS "*.h" "*.cc") +if(NOT USE_GLPK) + list(FILTER _SRCS EXCLUDE REGEX "/glpk/") + list(FILTER _SRCS EXCLUDE REGEX "/glpk_.*.h$") + list(FILTER _SRCS EXCLUDE REGEX "/glpk_.*.cc$") +endif() +if(NOT USE_GUROBI) + list(FILTER _SRCS EXCLUDE REGEX "/gurobi/") + list(FILTER _SRCS EXCLUDE REGEX "/gurobi_.*.h$") + list(FILTER _SRCS EXCLUDE REGEX "/gurobi_.*.cc$") +endif() +if(NOT USE_SCIP) + list(FILTER _SRCS EXCLUDE REGEX "/gscip/") + list(FILTER _SRCS EXCLUDE REGEX "/gscip_.*.h$") + list(FILTER _SRCS EXCLUDE REGEX "/gscip_.*.cc$") +endif() +target_sources(${NAME} PRIVATE ${_SRCS}) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + $<$:GLPK::GLPK> + $<$:libscip> + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/math_opt/storage/CMakeLists.txt b/ortools/math_opt/storage/CMakeLists.txt new file mode 100644 index 0000000000..8f788c80de --- /dev/null +++ b/ortools/math_opt/storage/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_storage) +add_library(${NAME} OBJECT) + +file(GLOB _SRCS "*.h" "*.cc") +target_sources(${NAME} PRIVATE ${_SRCS}) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/math_opt/validators/CMakeLists.txt b/ortools/math_opt/validators/CMakeLists.txt new file mode 100644 index 0000000000..f7cb1d4f18 --- /dev/null +++ b/ortools/math_opt/validators/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2010-2022 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. + +set(NAME ${PROJECT_NAME}_math_opt_validators) +add_library(${NAME} OBJECT) + +file(GLOB _SRCS "*.h" "*.cc") +target_sources(${NAME} PRIVATE ${_SRCS}) +set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(${NAME} PUBLIC + $ + $) +target_link_libraries(${NAME} PRIVATE + absl::strings + ${PROJECT_NAMESPACE}::math_opt_proto) diff --git a/ortools/packing/CMakeLists.txt b/ortools/packing/CMakeLists.txt index 4a3b87d7c4..b5385c9e19 100644 --- a/ortools/packing/CMakeLists.txt +++ b/ortools/packing/CMakeLists.txt @@ -26,6 +26,5 @@ target_include_directories(${NAME} PRIVATE target_link_libraries(${NAME} PRIVATE absl::flags absl::strings - protobuf::libprotobuf - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::packing ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::packing ALIAS ${NAME}) diff --git a/ortools/pdlp/CMakeLists.txt b/ortools/pdlp/CMakeLists.txt index 3975b8cb7d..aa8d042a42 100644 --- a/ortools/pdlp/CMakeLists.txt +++ b/ortools/pdlp/CMakeLists.txt @@ -35,7 +35,6 @@ target_link_libraries(${NAME} PRIVATE absl::memory absl::strings absl::str_format - protobuf::libprotobuf Eigen3::Eigen - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::pdlp ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::pdlp ALIAS ${NAME}) diff --git a/ortools/port/CMakeLists.txt b/ortools/port/CMakeLists.txt index c9327c16b8..782984b24b 100644 --- a/ortools/port/CMakeLists.txt +++ b/ortools/port/CMakeLists.txt @@ -26,5 +26,5 @@ target_include_directories(${NAME} PRIVATE target_link_libraries(${NAME} PRIVATE absl::strings protobuf::libprotobuf - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::port ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::port ALIAS ${NAME}) diff --git a/ortools/sat/CMakeLists.txt b/ortools/sat/CMakeLists.txt index aec4bec3f3..0f6ff95204 100644 --- a/ortools/sat/CMakeLists.txt +++ b/ortools/sat/CMakeLists.txt @@ -36,8 +36,8 @@ target_link_libraries(${NAME} PRIVATE absl::str_format protobuf::libprotobuf $<$:Coin::Cbc> - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::sat ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::sat ALIAS ${NAME}) # Sat Runner add_executable(sat_runner) diff --git a/ortools/scheduling/CMakeLists.txt b/ortools/scheduling/CMakeLists.txt index 5fa0cb2b3f..bd7f244688 100644 --- a/ortools/scheduling/CMakeLists.txt +++ b/ortools/scheduling/CMakeLists.txt @@ -26,5 +26,5 @@ target_include_directories(${NAME} PRIVATE target_link_libraries(${NAME} PRIVATE absl::strings protobuf::libprotobuf - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::scheduling ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::scheduling ALIAS ${NAME}) diff --git a/ortools/util/CMakeLists.txt b/ortools/util/CMakeLists.txt index 827f4387c8..d6d4082c39 100644 --- a/ortools/util/CMakeLists.txt +++ b/ortools/util/CMakeLists.txt @@ -32,5 +32,5 @@ target_link_libraries(${NAME} PRIVATE absl::strings absl::str_format protobuf::libprotobuf - ${PROJECT_NAME}::proto) -#add_library(${PROJECT_NAME}::util ALIAS ${NAME}) + ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto) +#add_library(${PROJECT_NAMESPACE}::util ALIAS ${NAME})