Skip to content

Commit

Permalink
WIP cmake: Add math_opt
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizux committed Aug 31, 2023
1 parent dcade2d commit 9f8ce4b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,19 @@ endif()

include(CMakeDependentOption)

# Optional tools (enabled by default)
## Flatzinc
CMAKE_DEPENDENT_OPTION(BUILD_FLATZINC "Build flatzinc" ON "BUILD_CXX" OFF)
message(STATUS "Build Flatzinc: ${BUILD_FLATZINC}")

## LP Parser
CMAKE_DEPENDENT_OPTION(BUILD_LP_PARSER "Build lp_parser" ON "BUILD_CXX" OFF)
message(STATUS "Build LP Parser: ${BUILD_LP_PARSER}")

## MathOpt
CMAKE_DEPENDENT_OPTION(BUILD_MATH_OPT "Build the MATH_OPT" ON "BUILD_CXX" OFF)
message(STATUS "Build MathOpt: ${BUILD_MATH_OPT}")

CMAKE_DEPENDENT_OPTION(BUILD_GLOP "Build GLOP standalone" ON "NOT BUILD_CXX" OFF)
message(STATUS "Build standalone Glop: ${BUILD_GLOP}")

Expand Down Expand Up @@ -251,6 +258,7 @@ if(USE_PDLP)
endif()

## SCIP
# see: https://github.com/scipopt/scip
CMAKE_DEPENDENT_OPTION(USE_SCIP "Use the Scip solver" ON "BUILD_CXX" OFF)
message(STATUS "SCIP support: ${USE_SCIP}")
if(USE_SCIP)
Expand Down
15 changes: 15 additions & 0 deletions cmake/cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ list(APPEND OR_TOOLS_COMPILE_DEFINITIONS
"USE_BOP" # enable BOP support
"USE_GLOP" # enable GLOP support
)
# Optional Components
if(BUILD_LP_PARSER)
list(APPEND OR_TOOLS_COMPILE_DEFINITIONS "USE_LP_PARSER")
endif()
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
"USE_CBC" # enable COIN-OR CBC support
Expand Down Expand Up @@ -188,6 +195,13 @@ file(GLOB_RECURSE proto_files RELATIVE ${PROJECT_SOURCE_DIR}
"ortools/scheduling/*.proto"
"ortools/util/*.proto"
)
if(BUILD_MATH_OPT)
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)
file(GLOB_RECURSE pdlp_proto_files RELATIVE ${PROJECT_SOURCE_DIR} "ortools/pdlp/*.proto")
list(APPEND proto_files ${pdlp_proto_files})
Expand Down Expand Up @@ -261,6 +275,7 @@ foreach(SUBPROJECT IN ITEMS
bop
constraint_solver
${GLPK_DIR}
${MATH_OPT_DIR}
${PDLP_DIR}
${GSCIP_DIR}
glop
Expand Down
38 changes: 38 additions & 0 deletions ortools/math_opt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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.

if(NOT BUILD_MATH_OPT)
return()
endif()

file(GLOB_RECURSE _SRCS "*.h" "*.cc")
list(FILTER _SRCS EXCLUDE REGEX "/samples/")

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
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>)
target_link_libraries(${NAME} PRIVATE
#absl::memory
#absl::strings
#absl::str_format
#protobuf::libprotobuf
${PROJECT_NAME}::proto)
#add_library(${PROJECT_NAME}::math_opt ALIAS ${NAME})

0 comments on commit 9f8ce4b

Please sign in to comment.