diff --git a/cmake/README.md b/cmake/README.md index ca229a7557..930ae5c264 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -64,6 +64,7 @@ CMake as a standalone project or it can be incorporated into an existing CMake project. + ## Dependencies OR-Tools depends on severals mandatory libraries. You can compile them all at @@ -96,10 +97,13 @@ default): test it on public CI and support can be broken.** + ## CMake Options + There are several options that can be passed to CMake to modify how the code is built.
For all of these options and parameters you have to use `-D=`.
Following a list of available options, for the full list run: + ```sh cmake -S. -Bbuild -LH ``` @@ -145,8 +149,8 @@ cmake -S. -Bbuild -LH | `UNIVERSAL_JAVA_PACKAGE` | OFF | Build a multi platform package (i.e. `ortools-java` will depends on all native packages)
Only available if `BUILD_JAVA=ON` | | | | | - + ## Integrating OR-Tools in your CMake Project You should be able to integrate OR-Tools in your C++ CMake project following one diff --git a/examples/cpp/cvrptw.cc b/examples/cpp/cvrptw.cc index a1e6dac33f..686453bb78 100644 --- a/examples/cpp/cvrptw.cc +++ b/examples/cpp/cvrptw.cc @@ -21,6 +21,7 @@ // distances are computed using the Manhattan distance. Distances are assumed // to be in meters and times in seconds. +#include #include #include "absl/flags/parse.h" @@ -61,8 +62,8 @@ ABSL_FLAG(std::string, routing_search_parameters, "", const char* kTime = "Time"; const char* kCapacity = "Capacity"; -const int64 kMaxNodesPerGroup = 10; -const int64 kSameVehicleCost = 1000; +const int64_t kMaxNodesPerGroup = 10; +const int64_t kSameVehicleCost = 1000; int main(int argc, char** argv) { google::InitGoogleLogging(argv[0]); @@ -80,9 +81,9 @@ int main(int argc, char** argv) { RoutingModel routing(manager); // Setting up locations. - const int64 kXMax = 100000; - const int64 kYMax = 100000; - const int64 kSpeed = 10; + const int64_t kXMax = 100000; + const int64_t kYMax = 100000; + const int64_t kSpeed = 10; LocationContainer locations( kSpeed, absl::GetFlag(FLAGS_vrp_use_deterministic_random_seed)); for (int location = 0; location <= absl::GetFlag(FLAGS_vrp_orders); @@ -99,8 +100,8 @@ int main(int argc, char** argv) { routing.SetArcCostEvaluatorOfAllVehicles(vehicle_cost); // Adding capacity dimension constraints. - const int64 kVehicleCapacity = 40; - const int64 kNullCapacitySlack = 0; + const int64_t kVehicleCapacity = 40; + const int64_t kNullCapacitySlack = 0; RandomDemand demand(manager.num_nodes(), kDepot, absl::GetFlag(FLAGS_vrp_use_deterministic_random_seed)); demand.Initialize(); @@ -112,8 +113,8 @@ int main(int argc, char** argv) { /*fix_start_cumul_to_zero=*/true, kCapacity); // Adding time dimension constraints. - const int64 kTimePerDemandUnit = 300; - const int64 kHorizon = 24 * 3600; + const int64_t kTimePerDemandUnit = 300; + const int64_t kHorizon = 24 * 3600; ServiceTimePlusTransition time( kTimePerDemandUnit, [&demand](RoutingNodeIndex i, RoutingNodeIndex j) { @@ -132,25 +133,25 @@ int main(int argc, char** argv) { // Adding time windows. std::mt19937 randomizer( GetSeed(absl::GetFlag(FLAGS_vrp_use_deterministic_random_seed))); - const int64 kTWDuration = 5 * 3600; + const int64_t kTWDuration = 5 * 3600; for (int order = 1; order < manager.num_nodes(); ++order) { - const int64 start = + const int64_t start = absl::Uniform(randomizer, 0, kHorizon - kTWDuration); time_dimension.CumulVar(order)->SetRange(start, start + kTWDuration); } // Adding penalty costs to allow skipping orders. - const int64 kPenalty = 10000000; + const int64_t kPenalty = 10000000; const RoutingIndexManager::NodeIndex kFirstNodeAfterDepot(1); for (RoutingIndexManager::NodeIndex order = kFirstNodeAfterDepot; order < manager.num_nodes(); ++order) { - std::vector orders(1, manager.NodeToIndex(order)); + std::vector orders(1, manager.NodeToIndex(order)); routing.AddDisjunction(orders, kPenalty); } // Adding same vehicle constraint costs for consecutive nodes. if (absl::GetFlag(FLAGS_vrp_use_same_vehicle_costs)) { - std::vector group; + std::vector group; for (RoutingIndexManager::NodeIndex order = kFirstNodeAfterDepot; order < manager.num_nodes(); ++order) { group.push_back(manager.NodeToIndex(order)); diff --git a/ortools/base/int_type.h b/ortools/base/int_type.h index a82d625213..dd21976053 100644 --- a/ortools/base/int_type.h +++ b/ortools/base/int_type.h @@ -146,7 +146,6 @@ #define OR_TOOLS_BASE_INT_TYPE_H_ #include - #include #include #include // NOLINT diff --git a/ortools/base/jniutil.h b/ortools/base/jniutil.h index c28e60c2e8..f3db9e55d6 100644 --- a/ortools/base/jniutil.h +++ b/ortools/base/jniutil.h @@ -17,7 +17,6 @@ #include #include - #include "ortools/base/logging.h" class JNIUtil { diff --git a/ortools/base/logging.cc b/ortools/base/logging.cc index 1e02d114a2..ce4bb40990 100644 --- a/ortools/base/logging.cc +++ b/ortools/base/logging.cc @@ -208,7 +208,7 @@ static void GetHostName(string* hostname) { *buf.nodename = '\0'; } *hostname = buf.nodename; -#else // _MSC_VER +#else // _MSC_VER char buf[MAX_COMPUTERNAME_LENGTH + 1]; DWORD len = MAX_COMPUTERNAME_LENGTH + 1; if (GetComputerNameA(buf, &len)) { @@ -650,7 +650,7 @@ static void ColoredWriteToStderr(LogSeverity severity, const char* message, fflush(stderr); // Restores the text color. SetConsoleTextAttribute(stderr_handle, old_color_attrs); -#else // !_MSC_VER +#else // !_MSC_VER fprintf(stderr, "\033[0;3%sm", GetAnsiColorCode(color)); fwrite(message, len, 1, stderr); fprintf(stderr, "\033[m"); // Resets the terminal to default. @@ -1186,7 +1186,7 @@ LogMessage::~LogMessage() { } else { delete allocated_; } -#else // !defined(GLOG_THREAD_LOCAL_STORAGE) +#else // !defined(GLOG_THREAD_LOCAL_STORAGE) delete allocated_; #endif // defined(GLOG_THREAD_LOCAL_STORAGE) } diff --git a/ortools/base/mathutil.h b/ortools/base/mathutil.h index cc17689740..96bb4518ad 100644 --- a/ortools/base/mathutil.h +++ b/ortools/base/mathutil.h @@ -15,7 +15,6 @@ #define OR_TOOLS_BASE_MATHUTIL_H_ #include - #include #include diff --git a/tools/cross_compile.sh b/tools/cross_compile.sh index b102c832c7..de539b1911 100755 --- a/tools/cross_compile.sh +++ b/tools/cross_compile.sh @@ -20,7 +20,7 @@ function unpack() { local -r DESTINATION="${ARCHIVE_DIR}/${RELATIVE_DIR}" if [[ ! -d "${DESTINATION}" ]] ; then local -r ARCHIVE_NAME=$(basename "${URL}") - test -f "${ARCHIVE_NAME}" || wget "${URL}" + [[ -f "${ARCHIVE_NAME}" ]] || wget "${URL}" extract "${ARCHIVE_NAME}" rm -f "${ARCHIVE_NAME}" fi @@ -52,8 +52,8 @@ function install_qemu() { # Qemu (meson based build) depends on: pkgconf, libglib2.0, python3, ninja ./configure \ - --prefix=${QEMU_INSTALL} \ - --target-list=${QEMU_TARGET} \ + --prefix="${QEMU_INSTALL}" \ + --target-list="${QEMU_TARGET}" \ --audio-drv-list= \ --disable-brlapi \ --disable-curl \ @@ -222,13 +222,13 @@ function run_test() { set -x case ${PROJECT} in glop) - ${RUN_CMD} bin/simple_glop_program ;; + "${RUN_CMD}" bin/simple_glop_program ;; or-tools) for test_binary in \ "${BUILD_DIR}"/bin/simple_* \ "${BUILD_DIR}"/bin/*tsp* \ "${BUILD_DIR}"/bin/*vrp*; do - ${RUN_CMD} "${test_binary}" + "${RUN_CMD}" "${test_binary}" done ;; *) @@ -280,7 +280,8 @@ function main() { assert_defined PROJECT assert_defined TARGET - declare -r PROJECT_DIR="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)" + declare -r PROJECT_DIR + PROJECT_DIR="$(cd -P -- "$(dirname -- "$0")/.." && pwd -P)" declare -r ARCHIVE_DIR="${PROJECT_DIR}/build_cross/archives" declare -r BUILD_DIR="${PROJECT_DIR}/build_cross/${TARGET}" declare -r TOOLCHAIN_FILE=${ARCHIVE_DIR}/toolchain_${TARGET}.cmake diff --git a/tools/generate_all_deps.sh b/tools/generate_all_deps.sh index 1461891c88..3cef98ea33 100755 --- a/tools/generate_all_deps.sh +++ b/tools/generate_all_deps.sh @@ -15,3 +15,4 @@ tools/generate_deps.sh GSCIP gscip base port tools/generate_deps.sh GUROBI gurobi base tools/generate_deps.sh LP linear_solver base util lp_data glop bop gscip gurobi tools/generate_deps.sh CP constraint_solver base util graph linear_solver sat +