Build or-tools 7.1 with cmake

Viewed 371

I am trying to build or-tools version 7.1 with cmake (3.16.3) in Linux Mint 20 Ulyana (based on ubuntu focal)

I am following the instructions from here https://github.com/google/or-tools/blob/f3fd201e68cf75b7720ff5c3cadc599a1d02b54b/cmake/README.md

First i run cmake -H. -Bbuild -G "Unix Makefiles" but this failed because dependencies not found so i replaced it with cmake -H. -Bbuild -G "Unix Makefiles" -DBUILD_DEPS=ON

But after a while got the following errors

[ 55%] No test step for 'Cbc_project'
[ 66%] Completed 'Cbc_project'
[100%] Built target Cbc_project
-- Building Cbc: ...DONE
-- Configuring done
CMake Error at ortools/constraint_solver/CMakeLists.txt:57 (add_dependencies):
  The dependency target "absl::container" of target
  "ortools_constraint_solver" does not exist.


CMake Error at ortools/glop/CMakeLists.txt:50 (add_dependencies):
  The dependency target "absl::container" of target "ortools_glop" does not
  exist.


CMake Error at ortools/linear_solver/CMakeLists.txt:54 (add_dependencies):
  The dependency target "absl::container" of target "ortools_linear_solver"
  does not exist.


CMake Error at ortools/sat/CMakeLists.txt:60 (add_dependencies):
  The dependency target "absl::container" of target "ortools_sat" does not
  exist.


CMake Error at ortools/constraint_solver/CMakeLists.txt:33 (target_compile_options):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>

  Target "absl::container" not found.


CMake Error at ortools/constraint_solver/CMakeLists.txt:45 (target_compile_definitions):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>

  Target "absl::container" not found.


CMake Error at ortools/constraint_solver/CMakeLists.txt:20 (target_include_directories):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>

  Target "absl::container" not found.


CMake Error at ortools/constraint_solver/CMakeLists.txt:45 (target_compile_definitions):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>

  Target "absl::container" not found.


CMake Error at ortools/constraint_solver/CMakeLists.txt:20 (target_include_directories):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>

  Target "absl::container" not found.


CMake Error at ortools/glop/CMakeLists.txt:30 (target_compile_options):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>

  Target "absl::container" not found.


CMake Error at ortools/glop/CMakeLists.txt:40 (target_compile_definitions):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>

  Target "absl::container" not found.


CMake Error at ortools/glop/CMakeLists.txt:19 (target_include_directories):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>

  Target "absl::container" not found.


CMake Error at ortools/glop/CMakeLists.txt:40 (target_compile_definitions):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>

  Target "absl::container" not found.


CMake Error at ortools/glop/CMakeLists.txt:19 (target_include_directories):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>

  Target "absl::container" not found.


CMake Error at ortools/linear_solver/CMakeLists.txt:32 (target_compile_options):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>

  Target "absl::container" not found.


CMake Error at ortools/linear_solver/CMakeLists.txt:43 (target_compile_definitions):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>

  Target "absl::container" not found.


CMake Error at ortools/linear_solver/CMakeLists.txt:20 (target_include_directories):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>

  Target "absl::container" not found.


CMake Error at ortools/linear_solver/CMakeLists.txt:43 (target_compile_definitions):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>

  Target "absl::container" not found.


CMake Error at ortools/linear_solver/CMakeLists.txt:20 (target_include_directories):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>

  Target "absl::container" not found.


CMake Error at ortools/sat/CMakeLists.txt:34 (target_compile_options):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>

  Target "absl::container" not found.


CMake Error at ortools/sat/CMakeLists.txt:47 (target_compile_definitions):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>

  Target "absl::container" not found.


CMake Error at ortools/sat/CMakeLists.txt:20 (target_include_directories):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>

  Target "absl::container" not found.


CMake Error at ortools/sat/CMakeLists.txt:47 (target_compile_definitions):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>

  Target "absl::container" not found.


CMake Error at ortools/sat/CMakeLists.txt:20 (target_include_directories):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>

  Target "absl::container" not found.


-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

Thank you in advance!

2 Answers

CMake was not fully implemented in 7.1.

Why stay on 7.1? Why not use make in 7.1 ?

The problem is abseil-cpp master have dropped the absl::container CMake target.

To summary in v7.1 the CMake based build when building all deps using -DBUILD_DEPS=ON will use abseil-cpp master branch ref: https://github.com/google/or-tools/blob/f3fd201e68cf75b7720ff5c3cadc599a1d02b54b/cmake/dependencies/CMakeLists.txt#L50-L59

But since v7.1 release the absl::container target has been dropped

The empty absl::container target has been removed from the CMake build. This target had no effect and references to this target in user code can safely be removed. see: https://github.com/abseil/abseil-cpp/releases/tag/20210324.2

A possible workaround would be to change the TAG master to 20200923.3 in cmake/dependencies/CMakeLists.txt#L50-L59

BUT as Laurent said we strongly recommend you to use the last stable version v9.1

Related