Skip to content

Commit

Permalink
cmake: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizux committed Jul 12, 2024
1 parent d38fcfb commit f5d9ea7
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 31 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,13 @@ if(BUILD_TESTING)
CMAKE_DEPENDENT_OPTION(BUILD_googletest "Build googletest" OFF
"NOT BUILD_DEPS" ON)
message(STATUS "Build googletest: ${BUILD_googletest}")

CMAKE_DEPENDENT_OPTION(BUILD_benchmark "Build benchmark" OFF
"NOT BUILD_DEPS" ON)
message(STATUS "Build benchmark: ${BUILD_benchmark}")
else()
set(BUILD_googletest OFF)
set(BUILD_benchmark OFF)
endif()

# Optional third party solvers (enabled by default)
Expand Down
2 changes: 1 addition & 1 deletion Dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Clp=1.17.7
Cgl=0.60.5
Cbc=2.10.7
GLPK=5.0
HiGHS=v1.7.0
HiGHS=v1.7.1
Scip=v900
# Python
pybind11=v2.12.0
Expand Down
2 changes: 1 addition & 1 deletion Version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
OR_TOOLS_MAJOR=9
OR_TOOLS_MINOR=10
OR_TOOLS_MINOR=11
#PRE_RELEASE=YES
32 changes: 21 additions & 11 deletions cmake/cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,12 @@ if(USE_SCIP OR BUILD_MATH_OPT)
list(APPEND OR_TOOLS_PROTO_FILES ${GSCIP_PROTO_FILES})
endif()

# ORTools proto
generate_proto_library(
NAME ${PROJECT_NAME}
NAME ortools
FILES ${OR_TOOLS_PROTO_FILES})

# MathOpt proto
if(BUILD_MATH_OPT)
file(GLOB_RECURSE MATH_OPT_PROTO_FILES RELATIVE ${PROJECT_SOURCE_DIR}
"ortools/math_opt/*.proto"
Expand All @@ -244,7 +246,7 @@ if(BUILD_MATH_OPT)
generate_proto_library(
NAME math_opt
FILES ${MATH_OPT_PROTO_FILES}
LINK_LIBRARIES ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto)
LINK_LIBRARIES ${PROJECT_NAMESPACE}::ortools_proto)
endif()

###############
Expand Down Expand Up @@ -298,11 +300,17 @@ if(XCODE)
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)
# Add ${PROJECT_NAMESPACE}::ortools_proto to libortools
target_sources(${PROJECT_NAME} PRIVATE
$<TARGET_OBJECTS:${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto>)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAMESPACE}::${PROJECT_NAME}_proto)
$<TARGET_OBJECTS:${PROJECT_NAMESPACE}::ortools_proto>)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAMESPACE}::ortools_proto)

if(BUILD_MATH_OPT)
# Add ${PROJECT_NAMESPACE}::math_opt_proto to libortools
target_sources(${PROJECT_NAME} PRIVATE
$<TARGET_OBJECTS:${PROJECT_NAMESPACE}::math_opt_proto>)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAMESPACE}::math_opt_proto)
endif()

foreach(SUBPROJECT IN ITEMS
base
Expand Down Expand Up @@ -331,11 +339,6 @@ foreach(SUBPROJECT IN ITEMS
endforeach()

if(BUILD_MATH_OPT)
#target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAMESPACE}::math_opt_proto)
target_sources(${PROJECT_NAME} PRIVATE
$<TARGET_OBJECTS:${PROJECT_NAMESPACE}::math_opt_proto>)
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()
Expand All @@ -349,6 +352,13 @@ target_sources(${PROJECT_NAME} PRIVATE $<TARGET_OBJECTS:${PROJECT_NAME}_linear_s
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_linear_solver_proto_solver)

# Dependencies
if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES
INSTALL_RPATH "@loader_path")
elseif(UNIX)
set_target_properties(${PROJECT_NAME} PROPERTIES
INSTALL_RPATH "$ORIGIN")
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC
${CMAKE_DL_LIBS}
ZLIB::ZLIB
Expand Down
57 changes: 48 additions & 9 deletions cmake/dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ if(BUILD_absl)
set(ABSL_PROPAGATE_CXX_STD ON)
set(ABSL_BUILD_TESTING OFF)
FetchContent_Declare(
abseil-cpp
absl
GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
GIT_TAG "20240116.2"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/abseil-cpp-20240116.2.patch"
)
FetchContent_MakeAvailable(abseil-cpp)
FetchContent_MakeAvailable(absl)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
Expand All @@ -102,12 +103,15 @@ if(BUILD_Protobuf)
set(protobuf_BUILD_SHARED_LIBS OFF)
set(protobuf_BUILD_EXPORT OFF)
set(protobuf_MSVC_STATIC_RUNTIME OFF)
#set(protobuf_BUILD_LIBUPB ON)
FetchContent_Declare(
Protobuf
GIT_REPOSITORY "https://github.com/protocolbuffers/protobuf.git"
GIT_TAG "v26.1"
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v26.1.patch"
GIT_SHALLOW TRUE
GIT_SUBMODULES ""
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v26.1.patch")
)
FetchContent_MakeAvailable(Protobuf)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
Expand All @@ -124,6 +128,7 @@ if(BUILD_re2)
re2
GIT_REPOSITORY "https://github.com/google/re2.git"
GIT_TAG "2024-04-01"
GIT_SHALLOW TRUE
#PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/re2-2024-04-01.patch"
)
FetchContent_MakeAvailable(re2)
Expand All @@ -145,6 +150,7 @@ if(BUILD_Eigen3)
eigen3
GIT_REPOSITORY "https://gitlab.com/libeigen/eigen.git"
GIT_TAG "3.4.0"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/eigen3-3.4.0.patch"
)
FetchContent_MakeAvailable(eigen3)
Expand All @@ -169,7 +175,8 @@ if(BUILD_PYTHON AND BUILD_pybind11)
FetchContent_Declare(
pybind11
GIT_REPOSITORY "https://github.com/pybind/pybind11.git"
GIT_TAG "v2.12.0"
GIT_TAG "v2.13.1"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11.patch"
)
FetchContent_MakeAvailable(pybind11)
Expand All @@ -183,7 +190,8 @@ if(BUILD_PYTHON AND BUILD_pybind11_abseil)
FetchContent_Declare(
pybind11_abseil
GIT_REPOSITORY "https://github.com/pybind/pybind11_abseil.git" # 2024/01/11
GIT_TAG "52f27398876a3177049977249e004770bd869e61"
GIT_TAG "v202402.0"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11_abseil.patch"
)
FetchContent_MakeAvailable(pybind11_abseil)
Expand All @@ -197,8 +205,9 @@ if(BUILD_PYTHON AND BUILD_pybind11_protobuf)
FetchContent_Declare(
pybind11_protobuf
GIT_REPOSITORY "https://github.com/pybind/pybind11_protobuf.git"
GIT_TAG "3b11990a99dea5101799e61d98a82c4737d240cc" # 2024/01/04
GIT_TAG "84653a591aea5df482dc2bde42c19efafbd53a57" # 2024/06/28
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11_protobuf.patch"
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(pybind11_protobuf)
list(POP_BACK CMAKE_MESSAGE_INDENT)
Expand All @@ -221,6 +230,7 @@ if(BUILD_GLPK)
glpk
GIT_REPOSITORY "https://github.com/Mizux/GLPK.git"
GIT_TAG "5.0"
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(glpk)
list(POP_BACK CMAKE_MESSAGE_INDENT)
Expand All @@ -234,11 +244,13 @@ if(BUILD_HIGHS)
message(CHECK_START "Fetching HiGHS")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(CI OFF) # disable CI tests
set(BUILD_EXAMPLES OFF)
FetchContent_Declare(
highs
GIT_REPOSITORY "https://github.com/ERGO-Code/HiGHS.git"
GIT_TAG "v1.7.0"
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/highs.patch"
GIT_TAG "v1.7.1"
GIT_SHALLOW TRUE
#PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/highs.patch"
)
FetchContent_MakeAvailable(highs)
list(POP_BACK CMAKE_MESSAGE_INDENT)
Expand Down Expand Up @@ -267,6 +279,7 @@ if(BUILD_SCIP)
scip
GIT_REPOSITORY "https://github.com/scipopt/scip.git"
GIT_TAG "v900"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/scip-v900.patch"
)
FetchContent_MakeAvailable(scip)
Expand All @@ -288,6 +301,7 @@ if(BUILD_CoinUtils)
CoinUtils
GIT_REPOSITORY "https://github.com/Mizux/CoinUtils.git"
GIT_TAG "cmake/2.11.6"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/coinutils-2.11.patch")
FetchContent_MakeAvailable(CoinUtils)
Expand All @@ -305,6 +319,7 @@ if(BUILD_Osi)
Osi
GIT_REPOSITORY "https://github.com/Mizux/Osi.git"
GIT_TAG "cmake/0.108.7"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/osi-0.108.patch")
FetchContent_MakeAvailable(Osi)
Expand All @@ -322,6 +337,7 @@ if(BUILD_Clp)
Clp
GIT_REPOSITORY "https://github.com/Mizux/Clp.git"
GIT_TAG "cmake/1.17.7"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/clp-1.17.4.patch")
FetchContent_MakeAvailable(Clp)
Expand All @@ -339,6 +355,7 @@ if(BUILD_Cgl)
Cgl
GIT_REPOSITORY "https://github.com/Mizux/Cgl.git"
GIT_TAG "cmake/0.60.5"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/cgl-0.60.patch")
FetchContent_MakeAvailable(Cgl)
Expand All @@ -356,6 +373,7 @@ if(BUILD_Cbc)
Cbc
GIT_REPOSITORY "https://github.com/Mizux/Cbc.git"
GIT_TAG "cmake/2.10.7"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/cbc-2.10.patch")
FetchContent_MakeAvailable(Cbc)
Expand All @@ -378,11 +396,32 @@ if(BUILD_googletest)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0)
GIT_TAG v1.14.0
GIT_SHALLOW TRUE
#PATCH_COMMAND git apply --ignore-whitespace ""
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF)
set(GTEST_HAS_ABSL ON)
FetchContent_MakeAvailable(googletest)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()

if(BUILD_benchmark)
message(CHECK_START "Fetching benchmark")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.8.4
GIT_SHALLOW TRUE
#PATCH_COMMAND git apply --ignore-whitespace ""
)
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_ENABLE_WERROR OFF)
set(BENCHMARK_ENABLE_INSTALL OFF)
FetchContent_MakeAvailable(benchmark)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
7 changes: 5 additions & 2 deletions cmake/dotnet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ configure_file(
COPYONLY)
set(DOTNET_README_DIR "${PROJECT_BINARY_DIR}/dotnet")

configure_file(${PROJECT_SOURCE_DIR}/ortools/dotnet/Directory.Build.props.in ${PROJECT_BINARY_DIR}/dotnet/Directory.Build.props)
configure_file(
${PROJECT_SOURCE_DIR}/ortools/dotnet/Directory.Build.props.in
${PROJECT_BINARY_DIR}/dotnet/Directory.Build.props)

############################
## .Net SNK file ##
Expand Down Expand Up @@ -636,7 +638,8 @@ if(NOT EXAMPLE_FILE_NAME)
OUTPUT ${DOTNET_EXAMPLE_DIR}/timestamp
COMMAND ${CMAKE_COMMAND} -E env --unset=TARGETNAME
${DOTNET_EXECUTABLE} build --nologo -c Release ${EXAMPLE_NAME}.csproj
COMMAND ${CMAKE_COMMAND} -E env --unset=TARGETNAME ${DOTNET_EXECUTABLE} pack -c Release ${EXAMPLE_NAME}.csproj
COMMAND ${CMAKE_COMMAND} -E env --unset=TARGETNAME
${DOTNET_EXECUTABLE} pack --nologo -c Release ${EXAMPLE_NAME}.csproj
COMMAND ${CMAKE_COMMAND} -E touch ${DOTNET_EXAMPLE_DIR}/timestamp
DEPENDS
${DOTNET_EXAMPLE_DIR}/${EXAMPLE_NAME}.csproj
Expand Down
2 changes: 1 addition & 1 deletion makefiles/Makefile.port.mk
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ ifeq ($(OR_TOOLS_PATCH),)
$(warning you are using a shallow copy)
OR_TOOLS_PATCH:= 9999
else
OR_TOOLS_PATCH:= $(shell git rev-list --count v$(OR_TOOLS_MAJOR).0..HEAD)
OR_TOOLS_PATCH:= $(shell git rev-list --count --quiet v$(OR_TOOLS_MAJOR).0..HEAD || echo 0)
endif
else
$(warning you are not using a .git archive)
Expand Down
12 changes: 6 additions & 6 deletions makefiles/docker/centos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ RUN wget -q "https://cmake.org/files/v3.28/cmake-3.28.3-linux-x86_64.sh" \
&& rm cmake-3.28.3-linux-x86_64.sh
CMD [ "/usr/bin/bash" ]

# Install SWIG 4.1.1
# Install SWIG 4.2.1
FROM base AS swig
RUN dnf -y update \
&& dnf -y install pcre2-devel \
&& dnf clean all \
&& rm -rf /var/cache/dnf \
&& wget -q "https://downloads.sourceforge.net/project/swig/swig/swig-4.1.1/swig-4.1.1.tar.gz" \
&& tar xvf swig-4.1.1.tar.gz \
&& rm swig-4.1.1.tar.gz \
&& cd swig-4.1.1 \
&& wget -q "https://downloads.sourceforge.net/project/swig/swig/swig-4.2.1/swig-4.2.1.tar.gz" \
&& tar xvf swig-4.2.1.tar.gz \
&& rm swig-4.2.1.tar.gz \
&& cd swig-4.2.1 \
&& ./configure --prefix=/usr \
&& make -j 4 \
&& make install \
&& cd .. \
&& rm -rf swig-4.1.1
&& rm -rf swig-4.2.1

0 comments on commit f5d9ea7

Please sign in to comment.