Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies issues when building or-tools 7.0 from Cmake error #1167

Closed
AxelDelsol opened this issue Mar 29, 2019 · 2 comments
Closed

Dependencies issues when building or-tools 7.0 from Cmake error #1167

AxelDelsol opened this issue Mar 29, 2019 · 2 comments
Assignees
Labels
Build: CMake CMake based build issue Duplicate Feature Request Missing Feature/Wrapper OS: Linux GNU/Linux OS OS: Mac MacOS OS: Windows Windows OS
Milestone

Comments

@AxelDelsol
Copy link

AxelDelsol commented Mar 29, 2019

I am sorry if I should have reopened my previous issues. I found more bugs when building and installing the latest version of CMake.

Here is what I tested to "solve" the problem :

TLDR

To build and use or-tools 7.0 when downloading the source code from the latest release (as of 2019/03/29):

  1. Change https://github.com/Mizux/Cbc to https://github.com/Mizux/coinor-cbc in cbc.CMakeLists.txt according to Building or-tools 7.0 from Cmake error #1159
  2. run cmake and get the following error : includes target "ortools" which requires target "absl_base" that is not in the export set.
  3. Change "${CMAKE_INSTALL_LIBDIR}/cmake/" to "${CMAKE_INSTALL_LIBDIR}/cmake/absl" in absl-cpp-src/CMakeLists.txt
  4. Change set(ABSL_ENABLE_INSTALL FALSE) to TRUE in in absl-cpp-src/CMakeLists.txt
  5. Add find_dependency(absl REQUIRED NO_MODULE) in ortoolsConfig.cmake.in
  6. Add set(GFLAGS_USE_TARGET_NAMESPACE TRUE) in ortoolsConfig.cmake.in after include (CMakeFindDependencyMacro)
  7. rerun cmake
  8. make -j4
  9. make install

Detail

With default sources :

/or-tools-7.0-build/cbc-src does not contain a CMakeLists.txt file.

Test 1
  1. Change path in cbc.CMakeLists.txt according to Building or-tools 7.0 from Cmake error #1159

Ouput :

CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "absl_base" that is not in the export set.
CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "absl_raw_hash_set" that is not in the export set.
CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "absl_hash" that is not in the export set.
CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "absl_memory" that is not in the export set.
CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "absl_meta" that is not in the export set.
CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "absl_str_format" that is not in the export set.
CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "absl_strings" that is not in the export set.
CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "absl_synchronization" that is not in the export set.
CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "absl_any" that is not in the export set.
CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "gflags_nothreads_static" that is not in this export set, but 2 times in others.
CMake Error: install(EXPORT "glog-targets" ...) includes target "glog" which requires target "gflags_nothreads_static" that is not in this export set, but 2 times in others.

Building and testing works.
No warning during the installation but will cause an error when trying to use ortools::ortools target (missing targets)

Test 2
  1. Change path in cbc.CMakeLists.txt according to Building or-tools 7.0 from Cmake error #1159
  2. Tag bf29470 does not exist in https://github.com/abseil/abseil-cpp. Try master instead and remove the patch

-> Same output as before

For the following : tag is bf29470 and the patch is kept.

Test 3
  1. Change path in cbc.CMakeLists.txt according to Building or-tools 7.0 from Cmake error #1159

  2. Add absl-cpp-src/CMakeLists.txt at line 127 : message(STATUS "ABSL install enabled ? ${ABSL_ENABLE_INSTALL}")
    ABSL install enabled ? FALSE .ABSL_ENABLE_INSTALL is set to false at line 42 because we are using abseil as a subproject in or-tools.

  3. Change set(ABSL_ENABLE_INSTALL FALSE) to TRUE in absl-cpp-src/CMakeLists.txt at line 42

Ouput :

CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "gflags_nothreads_static" that is not in this export set, but 2 times in others.
CMake Error: install(EXPORT "glog-targets" ...) includes target "glog" which requires target "gflags_nothreads_static" that is not in this export set, but 2 times in others.

Building and testing works.

When trying to use ortools::ortools after installation in a new project (using the cmake tutorial provided with or-tools):

The following imported targets are referenced, but are missing: absl::base
  absl::raw_hash_set absl::hash absl::memory absl::meta absl::str_format
  absl::strings absl::synchronization absl::any
Test 4
  1. Change path in cbc.CMakeLists.txt according to Building or-tools 7.0 from Cmake error #1159
  2. Change "${CMAKE_INSTALL_LIBDIR}/cmake/" to "${CMAKE_INSTALL_LIBDIR}/cmake/absl" in absl-cpp-src/CMakeLists.txt
  3. Add find_dependency(absl REQUIRED NO_MODULE) in ortoolsConfig.cmake.in

Ouput :

CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "gflags_nothreads_static" that is not in this export set, but 2 times in others.
CMake Error: install(EXPORT "glog-targets" ...) includes target "glog" which requires target "gflags_nothreads_static" that is not in this export set, but 2 times in others.

Building and testing works.

When trying to use ortools::ortools after installation in a new project (using the cmake tutorial provided with or-tools):

Target "CVRP" links to target "gflags::gflags" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?
Test 5
  1. Change "${CMAKE_INSTALL_LIBDIR}/cmake/" to "${CMAKE_INSTALL_LIBDIR}/cmake/absl" in absl-cpp-src/CMakeLists.txt
  2. Add find_dependency(absl REQUIRED NO_MODULE) in ortoolsConfig.cmake.in
  3. Add set(GFLAGS_USE_TARGET_NAMESPACE TRUE) in ortoolsConfig.cmake.in

Ouput :

CMake Error: install(EXPORT "ortoolsTargets" ...) includes target "ortools" which requires target "gflags_nothreads_static" that is not in this export set, but 2 times in others.
CMake Error: install(EXPORT "glog-targets" ...) includes target "glog" which requires target "gflags_nothreads_static" that is not in this export set, but 2 times in others.

Everything works fine even with the CMake error but I could not find why.

@Mizux Mizux added Feature Request Missing Feature/Wrapper OS: Windows Windows OS OS: Linux GNU/Linux OS OS: Mac MacOS Build: CMake CMake based build issue labels Mar 29, 2019
@Mizux Mizux added this to the v7.1 milestone Mar 29, 2019
@Mizux Mizux self-assigned this Mar 29, 2019
@Mizux Mizux mentioned this issue Apr 1, 2019
11 tasks
@Mizux
Copy link
Collaborator

Mizux commented Apr 1, 2019

Test 1

Bravo ! you just figure out the limitation of add_subdirectory() vs regular cmake install dependencies ;)
I'm currently in the process of reworking the way we consume our dependencies on CMake-based build
-> #1116

First step was to work for the abseil team to add install rules, second step will be a rework of Cbc then third step I'll rework the way we consume dependencies.

Please note CMake support is still "experimental" so up to now you should use the Make-based build...

note: From CMake release 3.13

The install(TARGETS) command learned to install targets created outside the current directory.

src: https://cmake.org/cmake/help/v3.13/release/3.13.html#commands

Test 2

strange abseil do have this short SHA1 see -> abseil/abseil-cpp@bf29470

Test 3

Yes, related to Test 1, currently we the abseil-team we are changing our mind, we will need to install abseil-cpp first.
good news my patch to install rules have been merged internally and should be all available on github...

Test 4

bear in mind that find_dependency() does not support REQUIRED or NO_MODULE or any find_package() options before CMake 3.9 IIRC

The CMakeFindDependencyMacro module find_dependency macro now forwards all arguments to the underlying find_package() call. Existing uses will continue to function as before, but callers can now access the full suite of arguments that find_package accepts.

src: https://cmake.org/cmake/help/v3.9/release/3.9.html#modules

Test 5

copy/paste you must mean find_dependency(gflag) I guess

note: I marked it as duplicate of #1116

@Mizux Mizux added the Duplicate label Apr 1, 2019
@Mizux
Copy link
Collaborator

Mizux commented May 3, 2019

Everything is on master now, so I'll close this as obsolete/done now.

Thanks for the feedback and don't hesitate to come back if needed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build: CMake CMake based build issue Duplicate Feature Request Missing Feature/Wrapper OS: Linux GNU/Linux OS OS: Mac MacOS OS: Windows Windows OS
Projects
None yet
Development

No branches or pull requests

2 participants