Files
ortools-clone/makefiles/Makefile.cpp.mk

622 lines
19 KiB
Makefile
Raw Permalink Normal View History

2025-01-10 11:35:44 +01:00
# Copyright 2010-2025 Google LLC
2022-06-20 18:27:09 +02:00
# 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.
2018-02-28 10:02:06 +01:00
# ---------- C++ support ----------
2022-05-25 11:55:06 +02:00
.PHONY: help_cpp # Generate list of C++ targets with descriptions.
help_cpp:
2018-03-02 13:41:00 +01:00
@echo Use one of the following C++ targets:
ifeq ($(PLATFORM),WIN64)
2018-07-05 16:08:54 +02:00
@$(GREP) "^.PHONY: .* #" $(CURDIR)/makefiles/Makefile.cpp.mk | $(SED) "s/\.PHONY: \(.*\) # \(.*\)/\1\t\2/"
2018-03-06 15:03:19 +01:00
@echo off & echo(
2018-02-28 10:02:06 +01:00
else
2018-07-05 16:08:54 +02:00
@$(GREP) "^.PHONY: .* #" $(CURDIR)/makefiles/Makefile.cpp.mk | $(SED) "s/\.PHONY: \(.*\) # \(.*\)/\1\t\2/" | expand -t20
@echo
2018-02-28 10:02:06 +01:00
endif
2018-04-25 16:52:01 +02:00
# Checks if the user has overwritten default install prefix.
# cf https://www.gnu.org/prep/standards/html_node/Directory-Variables.html#index-prefix
ifeq ($(PLATFORM),WIN64)
prefix ?= C:\\Program Files\\or-tools
2018-04-25 16:52:01 +02:00
else
prefix ?= /usr/local
endif
# Checks if the user has overwritten default libraries and binaries.
BUILD_TYPE ?= Release
USE_COINOR ?= ON
USE_GLPK ?= OFF
2025-06-11 15:23:46 +02:00
USE_HIGHS ?= ON
2022-05-02 16:02:54 +02:00
USE_PDLP := ON # OFF not supported
USE_SCIP ?= ON
USE_CPLEX ?= OFF
2023-06-13 23:08:10 +02:00
USE_DOTNET_CORE_31 ?= OFF
USE_DOTNET_8 ?= ON
2022-10-27 10:56:55 +02:00
BUILD_VENV ?= ON
2022-04-08 11:19:59 +02:00
JOBS ?= 4
2022-04-08 11:19:59 +02:00
# Main targets.
.PHONY: detect_cpp # Show variables used to build C++ OR-Tools.
.PHONY: third_party # Build OR-Tools Prerequisite
2022-04-08 11:19:59 +02:00
.PHONY: cpp # Build C++ OR-Tools library.
.PHONY: check_cpp # Run all C++ OR-Tools samples and examples targets.
.PHONY: test_cpp # Run all C++ OR-Tools test targets.
.PHONY: test_fz # Run all Flatzinc test targets.
.PHONY: archive_cpp # Add C++ OR-Tools to archive.
.PHONY: clean_cpp # Clean C++ output from previous build.
GENERATOR ?= $(CMAKE_PLATFORM)
third_party:
cmake -S . -B $(BUILD_DIR) -DBUILD_DEPS=ON \
-DBUILD_DOTNET=$(BUILD_DOTNET) \
-DBUILD_JAVA=$(BUILD_JAVA) \
-DBUILD_PYTHON=$(BUILD_PYTHON) \
-DBUILD_EXAMPLES=OFF \
-DBUILD_SAMPLES=OFF \
2022-10-21 17:07:47 +02:00
-DBUILD_TESTING=OFF \
-DUSE_COINOR=$(USE_COINOR) \
-DUSE_GLPK=$(USE_GLPK) \
2022-10-05 18:33:43 +02:00
-DUSE_HIGHS=$(USE_HIGHS) \
2022-05-02 16:02:54 +02:00
-DUSE_PDLP=$(USE_PDLP) \
-DUSE_SCIP=$(USE_SCIP) \
-DUSE_CPLEX=$(USE_CPLEX) \
-DUSE_DOTNET_CORE_31=$(USE_DOTNET_CORE_31) \
-DUSE_DOTNET_8=$(USE_DOTNET_8) \
2022-10-27 10:56:55 +02:00
-DBUILD_VENV=$(BUILD_VENV) \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) \
$(CMAKE_ARGS) \
-G $(GENERATOR)
2022-02-18 19:04:21 +01:00
# OR Tools unique library.
cpp:
$(MAKE) third_party
cmake --build $(BUILD_DIR) --target install --config $(BUILD_TYPE) -j $(JOBS) -v
check_cpp: check_cpp_pimpl
2022-02-18 19:04:21 +01:00
test_cpp: \
cpp \
2022-02-18 19:04:21 +01:00
test_cc_contrib \
2022-02-18 23:08:40 +01:00
test_cc_cpp
2022-02-18 19:04:21 +01:00
2022-02-18 19:13:01 +01:00
test_fz: \
cpp \
2022-02-18 19:04:21 +01:00
rfz_golomb \
2022-02-18 23:08:40 +01:00
rfz_alpha
2022-02-18 19:04:21 +01:00
2022-04-08 11:19:59 +02:00
TEMP_CPP_DIR := temp_cpp
$(TEMP_CPP_DIR):
$(MKDIR) $(TEMP_CPP_DIR)
2022-04-08 11:19:59 +02:00
# Deprecated alias
2022-05-25 11:55:06 +02:00
.PHONY: help_cc
help_cc: help_cpp
$(warning $@ is deprecated please use $< instead.)
.PHONY: detect_cc
detect_cc: detect_cpp
2022-05-25 11:55:06 +02:00
$(warning $@ is deprecated please use $< instead.)
.PHONY: cc
cc: cpp
$(warning $@ is deprecated please use @< instead.)
.PHONY: check_cc
check_cc: check_cpp
$(warning $@ is deprecated please use $< instead.)
.PHONY: check_cpp_%
check_cc_%: check_cpp_%
$(warning $@ is deprecated please use @< instead.)
.PHONY: test_cc
test_cc: test_cpp
$(warning $@ is deprecated please use @< instead.)
.PHONY: test_cc_%
test_cc_%: test_cpp_%
$(warning $@ is deprecated please use @< instead.)
2022-04-08 11:19:59 +02:00
.PHONY: package_cpp
package_cpp: archive_cpp
.PHONY: package_cc
package_cc: package_cpp
$(warning $@ is deprecated please use @< instead.)
.PHONY: clean_cc
clean_cc: clean_cpp
$(warning $@ is deprecated please use $< instead.)
2022-04-08 11:19:59 +02:00
# Now flatzinc is build with cpp
fz: cpp
$(warning $@ is deprecated please use $< instead.)
##################
## C++ SOURCE ##
##################
ifeq ($(SOURCE_SUFFIX),.cc) # Those rules will be used if SOURCE contain a .cc file
SOURCE_PROJECT_DIR := $(SOURCE)
SOURCE_PROJECT_DIR := $(subst /$(SOURCE_NAME).cc,, $(SOURCE_PROJECT_DIR))
SOURCE_PROJECT_PATH = $(subst /,$S,$(SOURCE_PROJECT_DIR))
$(TEMP_CPP_DIR)/$(SOURCE_NAME): | $(TEMP_CPP_DIR)
$(MKDIR) $(TEMP_CPP_DIR)$S$(SOURCE_NAME)
$(TEMP_CPP_DIR)/$(SOURCE_NAME)/CMakeLists.txt: ${SRC_DIR}/ortools/cpp/CMakeLists.txt.in | $(TEMP_CPP_DIR)/$(SOURCE_NAME)
$(COPY) ortools$Scpp$SCMakeLists.txt.in $(TEMP_CPP_DIR)$S$(SOURCE_NAME)$SCMakeLists.txt
$(SED) -i -e 's/@CPP_NAME@/$(SOURCE_NAME)/' \
$(TEMP_CPP_DIR)$S$(SOURCE_NAME)$SCMakeLists.txt
$(SED) -i -e 's/@CPP_FILE_NAME@/$(SOURCE_NAME).cc/' \
$(TEMP_CPP_DIR)$S$(SOURCE_NAME)$SCMakeLists.txt
$(SED) -i -e 's;@TEST_ARGS@;$(ARGS);' \
$(TEMP_CPP_DIR)$S$(SOURCE_NAME)$SCMakeLists.txt
.PHONY: build # Build a C++ program.
build: cpp \
$(SOURCE) \
$(TEMP_CPP_DIR)/$(SOURCE_NAME)/CMakeLists.txt
-$(DELREC) $(TEMP_CPP_DIR)$S$(SOURCE_NAME)$Sbuild
$(COPY) $(subst /,$S,$(SOURCE)) $(TEMP_CPP_DIR)$S$(SOURCE_NAME)$S$(SOURCE_NAME).cc
cd $(TEMP_CPP_DIR)$S$(SOURCE_NAME) &&\
cmake -S. -Bbuild \
2022-04-11 18:14:03 +02:00
-DCMAKE_PREFIX_PATH=$(OR_ROOT_FULL)/$(INSTALL_DIR) \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-G $(GENERATOR) \
$(CMAKE_ARGS)
ifneq ($(PLATFORM),WIN64)
cd $(TEMP_CPP_DIR)$S$(SOURCE_NAME) && cmake --build build --config $(BUILD_TYPE) --target all -v
else
cd $(TEMP_CPP_DIR)$S$(SOURCE_NAME) && cmake --build build --config $(BUILD_TYPE) --target ALL_BUILD -v
endif
.PHONY: run # Run a C++ program.
run: build
ifneq ($(PLATFORM),WIN64)
cd $(TEMP_CPP_DIR)$S$(SOURCE_NAME) && cmake --build build --config $(BUILD_TYPE) --target test -v
else
cd $(TEMP_CPP_DIR)$S$(SOURCE_NAME) && cmake --build build --config $(BUILD_TYPE) --target RUN_TESTS -v
endif
endif
2018-10-12 11:48:03 +02:00
##################################
## CPP Tests/Examples/Samples ##
##################################
# Samples
define cpp-sample-target =
$(TEMP_CPP_DIR)/$1: | $(TEMP_CPP_DIR)
-$(MKDIR) $(TEMP_CPP_DIR)$S$1
$(TEMP_CPP_DIR)/$1/%: \
$(SRC_DIR)/ortools/$1/samples/%.cc \
| $(TEMP_CPP_DIR)/$1
-$(MKDIR) $(TEMP_CPP_DIR)$S$1$S$$*
$(TEMP_CPP_DIR)/$1/%/CMakeLists.txt: \
2022-10-19 17:51:20 +02:00
$(SRC_DIR)/ortools/$1/samples/%.cc \
${SRC_DIR}/ortools/cpp/CMakeLists.txt.in \
| $(TEMP_CPP_DIR)/$1/%
$(COPY) ortools$Scpp$SCMakeLists.txt.in $(TEMP_CPP_DIR)$S$1$S$$*$SCMakeLists.txt
$(SED) -i -e 's/@CPP_NAME@/$$*/' \
$(TEMP_CPP_DIR)$S$1$S$$*$SCMakeLists.txt
$(SED) -i -e 's/@CPP_FILE_NAME@/$$*.cc/' \
$(TEMP_CPP_DIR)$S$1$S$$*$SCMakeLists.txt
$(SED) -i -e 's/@TEST_ARGS@//' \
$(TEMP_CPP_DIR)$S$1$S$$*$SCMakeLists.txt
$(TEMP_CPP_DIR)/$1/%/%.cc: \
$(SRC_DIR)/ortools/$1/samples/%.cc \
| $(TEMP_CPP_DIR)/$1/%
$(MKDIR_P) $(TEMP_CPP_DIR)$S$1$S$$*
$(COPY) $(SRC_DIR)$Sortools$S$1$Ssamples$S$$*.cc \
$(TEMP_CPP_DIR)$S$1$S$$*
rcpp_%: \
cpp \
2022-10-19 17:51:20 +02:00
$(SRC_DIR)/ortools/$1/samples/%.cc \
$(TEMP_CPP_DIR)/$1/%/CMakeLists.txt \
$(TEMP_CPP_DIR)/$1/%/%.cc \
FORCE
cd $(TEMP_CPP_DIR)$S$1$S$$* &&\
cmake -S. -Bbuild \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_PREFIX_PATH=$(OR_ROOT_FULL)/$(INSTALL_DIR) \
-DCMAKE_INSTALL_PREFIX=install \
$(CMAKE_ARGS) \
-G $(GENERATOR)
ifneq ($(PLATFORM),WIN64)
cd $(TEMP_CPP_DIR)$S$1$S$$* && cmake --build build --config $(BUILD_TYPE) --target all -v
cd $(TEMP_CPP_DIR)$S$1$S$$* && cmake --build build --config $(BUILD_TYPE) --target test -v
else
cd $(TEMP_CPP_DIR)$S$1$S$$* && cmake --build build --config $(BUILD_TYPE) --target ALL_BUILD -v
cd $(TEMP_CPP_DIR)$S$1$S$$* && cmake --build build --config $(BUILD_TYPE) --target RUN_TESTS -v
endif
endef
2025-06-02 09:50:18 +02:00
CPP_SAMPLES := algorithms graph glop constraint_solver linear_solver math_opt model_builder pdlp routing sat set_cover
$(foreach sample,$(CPP_SAMPLES),$(eval $(call cpp-sample-target,$(sample))))
# Examples
define cpp-example-target =
$(TEMP_CPP_DIR)/$1: | $(TEMP_CPP_DIR)
-$(MKDIR) $(TEMP_CPP_DIR)$S$1
2022-10-19 17:51:20 +02:00
$(TEMP_CPP_DIR)/$1/%: \
$(SRC_DIR)/examples/$1/%.cc \
| $(TEMP_CPP_DIR)/$1
-$(MKDIR) $(TEMP_CPP_DIR)$S$1$S$$*
2022-10-19 17:51:20 +02:00
$(TEMP_CPP_DIR)/$1/%/CMakeLists.txt: \
$(SRC_DIR)/examples/$1/%.cc \
${SRC_DIR}/ortools/cpp/CMakeLists.txt.in \
| $(TEMP_CPP_DIR)/$1/%
$(COPY) ortools$Scpp$SCMakeLists.txt.in $(TEMP_CPP_DIR)$S$1$S$$*$SCMakeLists.txt
$(SED) -i -e 's/@CPP_NAME@/$$*/' \
$(TEMP_CPP_DIR)$S$1$S$$*$SCMakeLists.txt
$(SED) -i -e 's/@CPP_FILE_NAME@/$$*.cc/' \
$(TEMP_CPP_DIR)$S$1$S$$*$SCMakeLists.txt
$(SED) -i -e 's/@TEST_ARGS@//' \
$(TEMP_CPP_DIR)$S$1$S$$*$SCMakeLists.txt
$(TEMP_CPP_DIR)/$1/%/%.cc: \
$(SRC_DIR)/examples/$1/%.cc \
| $(TEMP_CPP_DIR)/$1/%
$(MKDIR_P) $(TEMP_CPP_DIR)$S$1$S$$*
$(COPY) $(SRC_DIR)$Sexamples$S$1$S$$*.cc \
$(TEMP_CPP_DIR)$S$1$S$$*
rcpp_%: \
cpp \
2022-10-19 17:51:20 +02:00
$(SRC_DIR)/examples/$1/%.cc \
$(TEMP_CPP_DIR)/$1/%/CMakeLists.txt \
$(TEMP_CPP_DIR)/$1/%/%.cc \
FORCE
cd $(TEMP_CPP_DIR)$S$1$S$$* &&\
cmake -S. -Bbuild \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_PREFIX_PATH=$(OR_ROOT_FULL)/$(INSTALL_DIR) \
-DCMAKE_INSTALL_PREFIX=install \
$(CMAKE_ARGS) \
-G $(GENERATOR)
ifneq ($(PLATFORM),WIN64)
cd $(TEMP_CPP_DIR)$S$1$S$$* && cmake --build build --config $(BUILD_TYPE) --target all -v
cd $(TEMP_CPP_DIR)$S$1$S$$* && cmake --build build --config $(BUILD_TYPE) --target test -v
else
cd $(TEMP_CPP_DIR)$S$1$S$$* && cmake --build build --config $(BUILD_TYPE) --target ALL_BUILD -v
cd $(TEMP_CPP_DIR)$S$1$S$$* && cmake --build build --config $(BUILD_TYPE) --target RUN_TESTS -v
endif
endef
CPP_EXAMPLES := contrib cpp
$(foreach example,$(CPP_EXAMPLES),$(eval $(call cpp-example-target,$(example))))
2021-01-05 23:05:46 +01:00
##################################
## Course scheduling example ##
##################################
2022-06-21 11:35:03 +02:00
# TODO(user) Port it to CMake
# examples/cpp/course_scheduling.proto: ;
#
# $(SRC_DIR)/examples/cpp/course_scheduling.pb.cc: \
# $(SRC_DIR)/examples/cpp/course_scheduling.proto | $(TEMP_CPP_DIR)/examples/cpp
# $(PROTOC) \
# --proto_path=$(INSTALL_DIR)/include \
# $(PROTOBUF_PROTOC_INC) \
# --cpp_out=. \
# $(SRC_DIR)/examples/cpp/course_scheduling.proto
#
# $(SRC_DIR)/examples/cpp/course_scheduling.pb.h: $(SRC_DIR)/examples/cpp/course_scheduling.pb.cc
# $(TOUCH) examples$Scpp$Scourse_scheduling.pb.h
#
# bin/course_scheduling$E: \
# $(SRC_DIR)/examples/cpp/course_scheduling.h \
# $(SRC_DIR)/examples/cpp/course_scheduling.cc \
# $(SRC_DIR)/examples/cpp/course_scheduling.pb.h \
# $(SRC_DIR)/examples/cpp/course_scheduling.pb.cc \
# $(SRC_DIR)/examples/cpp/course_scheduling_run.cc \
# cpp \
# | bin
# cmake build to generate bin$Scourse_scheduling$E
#
# rcpp_course_scheduling: bin/course_scheduling$E FORCE
# bin$S$*$E $(ARGS)
####################
## Test targets ##
####################
2022-02-18 19:04:21 +01:00
.PHONY: test_cpp_algorithms_samples # Build and Run all C++ Algorithms Samples (located in ortools/algorithms/samples)
test_cpp_algorithms_samples: \
rcpp_knapsack \
rcpp_simple_knapsack_program
2022-02-18 19:04:21 +01:00
.PHONY: test_cpp_graph_samples # Build and Run all C++ Graph Samples (located in ortools/graph/samples)
test_cpp_graph_samples: \
rcpp_simple_max_flow_program \
rcpp_simple_min_cost_flow_program
.PHONY: test_cpp_constraint_solver_samples # Build and Run all C++ CP Samples (located in ortools/constraint_solver/samples)
test_cpp_constraint_solver_samples: \
rcpp_minimal_jobshop_cp \
rcpp_nurses_cp \
rcpp_rabbits_and_pheasants_cp \
rcpp_simple_ls_program \
rcpp_simple_cp_program \
rcpp_simple_routing_program \
rcpp_tsp \
rcpp_tsp_cities \
rcpp_tsp_circuit_board \
rcpp_tsp_distance_matrix \
rcpp_vrp \
rcpp_vrp_breaks \
rcpp_vrp_capacity \
rcpp_vrp_drop_nodes \
rcpp_vrp_global_span \
rcpp_vrp_initial_routes \
rcpp_vrp_pickup_delivery \
rcpp_vrp_pickup_delivery_fifo \
rcpp_vrp_pickup_delivery_lifo \
rcpp_vrp_resources \
rcpp_vrp_solution_callback \
rcpp_vrp_starts_ends \
rcpp_vrp_time_windows \
rcpp_vrp_with_time_limit
2022-02-18 19:04:21 +01:00
.PHONY: test_cpp_linear_solver_samples # Build and Run all C++ LP Samples (located in ortools/linear_solver/samples)
test_cpp_linear_solver_samples: \
rcpp_assignment_mip \
rcpp_basic_example \
rcpp_bin_packing_mip \
rcpp_integer_programming_example \
rcpp_linear_programming_example \
rcpp_mip_var_array \
rcpp_multiple_knapsack_mip \
rcpp_simple_lp_program \
rcpp_simple_mip_program \
rcpp_stigler_diet
2022-10-26 15:26:39 +02:00
.PHONY: test_cpp_model_builder_samples # Build and Run all C++ CP Samples (located in ortools/model_builder/samples)
test_cpp_model_builder_samples: \
2022-02-18 19:04:21 +01:00
2022-10-26 15:22:17 +02:00
.PHONY: test_cpp_pdlp_samples # Build and Run all C++ CP Samples (located in ortools/model_builder/samples)
test_cpp_pdlp_samples: \
rcpp_simple_pdlp_program
2022-02-18 19:04:21 +01:00
.PHONY: test_cpp_sat_samples # Build and Run all C++ Sat Samples (located in ortools/sat/samples)
test_cpp_sat_samples: \
2022-10-17 16:11:22 +02:00
rcpp_assignment_groups_sat \
rcpp_assignment_sat \
2022-10-17 16:11:22 +02:00
rcpp_assignment_task_sizes_sat \
rcpp_assignment_teams_sat \
rcpp_assumptions_sample_sat \
rcpp_binpacking_problem_sat \
rcpp_bool_or_sample_sat \
rcpp_channeling_sample_sat \
2022-10-17 16:11:22 +02:00
rcpp_copy_model_sample_sat \
rcpp_cp_is_fun_sat \
2022-10-17 16:11:22 +02:00
rcpp_cp_sat_example \
rcpp_earliness_tardiness_cost_sample_sat \
rcpp_interval_sample_sat \
rcpp_literal_sample_sat \
2022-10-17 16:11:22 +02:00
rcpp_minimal_jobshop_sat \
rcpp_multiple_knapsack_sat \
rcpp_non_linear_sat \
rcpp_no_overlap_sample_sat \
2022-10-17 16:11:22 +02:00
rcpp_nqueens_sat \
rcpp_nurses_sat \
rcpp_optional_interval_sample_sat \
rcpp_rabbits_and_pheasants_sat \
rcpp_ranking_sample_sat \
rcpp_reified_sample_sat \
2022-10-17 16:11:22 +02:00
rcpp_schedule_requests_sat \
rcpp_search_for_all_solutions_sample_sat \
rcpp_simple_sat_program \
rcpp_solution_hinting_sample_sat \
rcpp_solve_and_print_intermediate_solutions_sample_sat \
rcpp_solve_with_time_limit_sample_sat \
rcpp_step_function_sample_sat \
rcpp_stop_after_n_solutions_sample_sat
.PHONY: check_cpp_pimpl
check_cpp_pimpl: \
test_cpp_algorithms_samples \
test_cpp_graph_samples \
2022-04-08 11:19:59 +02:00
test_cpp_constraint_solver_samples \
test_cpp_linear_solver_samples \
test_cpp_model_builder_samples \
2022-10-26 15:22:17 +02:00
test_cpp_pdlp_samples \
test_cpp_sat_samples \
2022-02-18 19:04:21 +01:00
\
rcpp_linear_programming \
rcpp_constraint_programming_cp \
rcpp_integer_programming \
rcpp_knapsack \
rcpp_max_flow \
2022-04-08 11:19:59 +02:00
rcpp_min_cost_flow
2022-02-18 19:04:21 +01:00
2022-10-05 12:46:43 +02:00
.PHONY: test_cc_contrib # Build and Run all C++ Contrib (located in examples/contrib)
2022-04-08 11:19:59 +02:00
test_cc_contrib:
2022-02-18 19:04:21 +01:00
2022-10-05 12:46:43 +02:00
.PHONY: test_cc_cpp # Build and Run all C++ Examples (located in examples/cpp)
2022-02-18 19:04:21 +01:00
test_cc_cpp: \
rcpp_costas_array_sat \
rcpp_cryptarithm_sat \
rcpp_flow_api \
rcpp_linear_assignment_api \
rcpp_linear_solver_protocol_buffers \
rcpp_magic_sequence_sat \
rcpp_magic_square_sat \
rcpp_nqueens \
rcpp_random_tsp \
rcpp_slitherlink_sat \
rcpp_strawberry_fields_with_column_generation \
rcpp_uncapacitated_facility_location \
# rcpp_weighted_tardiness_sat # need input file
2022-06-21 11:35:03 +02:00
# TODO(user) how to build cvrptwlib and depends on it
# rcpp_cvrp_disjoint_tw \
# rcpp_cvrptw \
# rcpp_cvrptw_with_breaks \
# rcpp_cvrptw_with_refueling \
# rcpp_cvrptw_with_resources \
# rcpp_cvrptw_with_stop_times_and_resources
# $(MAKE) run \
2022-06-01 15:31:25 +02:00
SOURCE=examples/cpp/dimacs_assignment.cc \
ARGS=examples/cpp/dimacs.asn
2022-02-18 19:04:21 +01:00
$(MAKE) run \
SOURCE=examples/cpp/dobble_ls.cc \
ARGS="--time_limit_in_ms=10000"
$(MAKE) run \
SOURCE=examples/cpp/golomb_sat.cc \
ARGS="--size=5"
$(MAKE) run \
SOURCE=examples/cpp/jobshop_sat.cc \
2022-07-29 11:42:42 +02:00
ARGS="--input=$(subst $S,/,$(OR_ROOT_FULL))/examples/cpp/jobshop"
2022-02-18 19:04:21 +01:00
$(MAKE) run \
SOURCE=examples/cpp/mps_driver.cc \
2022-07-29 11:42:42 +02:00
ARGS="--input=$(subst $S,/,$(OR_ROOT_FULL))/examples/cpp/test.mps"
2022-02-18 19:04:21 +01:00
$(MAKE) run \
SOURCE=examples/cpp/network_routing_sat.cc \
ARGS="--clients=10 --backbones=5 --demands=10 --traffic_min=5 --traffic_max=10 --min_client_degree=2 --max_client_degree=5 --min_backbone_degree=3 --max_backbone_degree=5 --max_capacity=20 --fixed_charge_cost=10"
$(MAKE) run \
SOURCE=examples/cpp/sports_scheduling_sat.cc \
ARGS="--params max_time_in_seconds:10.0"
# $(MAKE) run SOURCE=examples/cpp/frequency_assignment_problem.cc # Need data file
2022-06-01 15:31:25 +02:00
# $(MAKE) run SOURCE=examples/cpp/pdptw.cc \
ARGS="--pdp_file examples/cpp/pdptw.txt" # Fails on windows...
# $(MAKE) run \
SOURCE=examples/cpp/shift_minimization_sat.cc \
2022-07-29 11:42:42 +02:00
ARGS="--input=$(subst $S,/,$(OR_ROOT_FULL))/examples/cpp/shift_minimization.dat"
2022-02-18 19:04:21 +01:00
rfz_%: cpp
2025-09-22 17:23:45 +02:00
$(INSTALL_DIR)$Sbin$Sfzn-cp-sat$E $(OR_ROOT_FULL)/examples/flatzinc/$*.fzn
###############
## Archive ##
###############
archive_cpp: $(INSTALL_CPP_NAME)$(ARCHIVE_EXT)
$(INSTALL_CPP_NAME):
$(MKDIR) $(INSTALL_CPP_NAME)
$(INSTALL_CPP_NAME)/examples: | $(INSTALL_CPP_NAME)
$(MKDIR) $(INSTALL_CPP_NAME)$Sexamples
define cpp-sample-archive =
$(INSTALL_CPP_NAME)/examples/%/CMakeLists.txt: \
$(TEMP_CPP_DIR)/$1/%/CMakeLists.txt \
$(SRC_DIR)/ortools/$1/samples/%.cc \
| $(INSTALL_CPP_NAME)/examples
-$(MKDIR_P) $(INSTALL_CPP_NAME)$Sexamples$S$$*
$(COPY) $(SRC_DIR)$Sortools$S$1$Ssamples$S$$*.cc $(INSTALL_CPP_NAME)$Sexamples$S$$*
$(COPY) $(TEMP_CPP_DIR)$S$1$S$$*$SCMakeLists.txt $(INSTALL_CPP_NAME)$Sexamples$S$$*
endef
$(foreach sample,$(CPP_SAMPLES),$(eval $(call cpp-sample-archive,$(sample))))
define cpp-example-archive =
$(INSTALL_CPP_NAME)/examples/%/CMakeLists.txt: \
$(TEMP_CPP_DIR)/$1/%/CMakeLists.txt \
$(SRC_DIR)/examples/$1/%.cc \
| $(INSTALL_CPP_NAME)/examples
-$(MKDIR_P) $(INSTALL_CPP_NAME)$Sexamples$S$$*
$(COPY) $(SRC_DIR)$Sexamples$S$1$S$$*.cc $(INSTALL_CPP_NAME)$Sexamples$S$$*
$(COPY) $(TEMP_CPP_DIR)$S$1$S$$*$SCMakeLists.txt $(INSTALL_CPP_NAME)$Sexamples$S$$*
endef
$(foreach example,$(CPP_EXAMPLES),$(eval $(call cpp-example-archive,$(example))))
SAMPLE_CPP_FILES = \
$(addsuffix /CMakeLists.txt,$(addprefix $(INSTALL_CPP_NAME)/examples/,$(basename $(notdir $(wildcard ortools/*/samples/*.cc)))))
EXAMPLE_CPP_FILES = \
$(addsuffix /CMakeLists.txt,$(addprefix $(INSTALL_CPP_NAME)/examples/,$(basename $(notdir $(wildcard examples/contrib/*.cc))))) \
$(addsuffix /CMakeLists.txt,$(addprefix $(INSTALL_CPP_NAME)/examples/,$(basename $(notdir $(wildcard examples/cpp/*.cc)))))
$(INSTALL_CPP_NAME)$(ARCHIVE_EXT): \
$(SAMPLE_CPP_FILES) \
$(EXAMPLE_CPP_FILES) \
2022-04-25 15:36:48 +02:00
tools/README.cpp.md tools/Makefile.cpp.mk
2022-06-03 14:46:39 +02:00
$(MAKE) third_party BUILD_DOTNET=OFF BUILD_JAVA=OFF BUILD_PYTHON=OFF INSTALL_DIR=$(OR_ROOT)$(INSTALL_CPP_NAME)
cmake --build $(BUILD_DIR) --target install --config $(BUILD_TYPE) -j $(JOBS) -v
$(COPY) tools$SREADME.cpp.md $(INSTALL_CPP_NAME)$SREADME.md
2022-04-25 15:36:48 +02:00
$(COPY) tools$SMakefile.cpp.mk $(INSTALL_CPP_NAME)$SMakefile
$(SED) -i -e 's/@PROJECT_VERSION@/$(OR_TOOLS_VERSION)/' $(INSTALL_CPP_NAME)$SMakefile
ifeq ($(PLATFORM),WIN64)
$(ZIP) -r $(INSTALL_CPP_NAME)$(ARCHIVE_EXT) $(INSTALL_CPP_NAME)
else
$(TAR) --no-same-owner -czvf $(INSTALL_CPP_NAME)$(ARCHIVE_EXT) $(INSTALL_CPP_NAME)
endif
# Test archive
TEMP_CPP_TEST_DIR := temp_cpp_test
.PHONY: test_archive_cpp # Test C++ OR-Tools archive is OK.
test_archive_cpp: $(INSTALL_CPP_NAME)$(ARCHIVE_EXT)
-$(DELREC) $(TEMP_CPP_TEST_DIR)
-$(MKDIR) $(TEMP_CPP_TEST_DIR)
ifeq ($(PLATFORM),WIN64)
$(UNZIP) $< -d $(TEMP_CPP_TEST_DIR)
else
$(TAR) -xvf $< -C $(TEMP_CPP_TEST_DIR)
endif
cd $(TEMP_CPP_TEST_DIR)$S$(INSTALL_CPP_NAME) \
&& $(MAKE) MAKEFLAGS= \
&& $(MAKE) MAKEFLAGS= test
################
## Cleaning ##
################
clean_cpp:
-$(DELREC) $(BUILD_DIR)
-$(DELREC) $(INSTALL_DIR)
-$(DELREC) $(TEMP_CPP_DIR)
-$(DELREC) $(INSTALL_CPP_NAME)
-$(DELREC) or-tools_cpp_*
-$(DELREC) $(TEMP_CPP_TEST_DIR)
-$(DEL) *.deb
2018-08-31 18:14:17 +02:00
#############
## DEBUG ##
#############
detect_cpp:
2018-03-06 14:34:17 +01:00
@echo Relevant info for the C++ build:
@echo SRC_DIR = $(SRC_DIR)
@echo BUILD_DIR = $(BUILD_DIR)
@echo INSTALL_DIR = $(INSTALL_DIR)
@echo prefix = $(prefix)
@echo BUILD_TYPE = $(BUILD_TYPE)
@echo USE_GLOP = ON
@echo USE_PDLP = ON
@echo USE_COINOR = $(USE_COINOR)
@echo USE_SCIP = $(USE_SCIP)
@echo USE_GLPK = $(USE_GLPK)
@echo USE_CPLEX = $(USE_CPLEX)
ifdef GLPK_ROOT
@echo GLPK_ROOT = $(GLPK_ROOT)
endif
ifdef CPLEX_ROOT
@echo CPLEX_ROOT = $(CPLEX_ROOT)
endif
ifdef XPRESS_ROOT
@echo XPRESS_ROOT = $(XPRESS_ROOT)
endif
@echo INSTALL_CPP_NAME = $(INSTALL_CPP_NAME)
ifeq ($(PLATFORM),WIN64)
2018-04-25 16:32:46 +02:00
@echo off & echo(
else
@echo
endif