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

CMake: install target not working: fails: file INSTALL cannot find absl-config.cmake #1025

Closed
phillip-keldenich opened this issue Jan 22, 2019 · 5 comments
Assignees
Labels
Bug Build: CMake CMake based build issue OS: Linux GNU/Linux OS OS: Mac MacOS
Milestone

Comments

@phillip-keldenich
Copy link

I tried building and installing the source code from git (I tried both master and tags/v7.0-beta1 with the same error) on Mac OS, installing as dependencies only wget/cmake (using homebrew).

Configuring, building and even testing using the standard CMake workflow

mkdir build && cd build
cmake ..
make -j8

work fine (except for tons of warnings regarding the deprecated "register" keyword and some .cc-files without symbols).

However, running make install (or, equivalently, cmake --build . --target install) fails because the file build/abseil-cpp-src/CMake/absl-config.cmake is missing.
I tried to run

find build | grep absl-config

too see whether the file is present somewhere else, but there appears to be no such file in the build directory.

-- Installing: /usr/local/lib/cmake/protobuf/protobuf-module.cmake
-- Installing: /usr/local/lib/cmake/protobuf/protobuf-options.cmake
-- Installing: /usr/local/lib/cmake/protobuf/protobuf-config.cmake
-- Installing: /usr/local/lib/cmake/protobuf/protobuf-config-version.cmake
-- Installing: /usr/local/lib/cmake/absl/absl-targets.cmake
-- Installing: /usr/local/lib/cmake/absl/absl-targets-release.cmake
CMake Error at abseil-cpp-build/cmake_install.cmake:55 (file):
  file INSTALL cannot find
  "/Users/me/Source/or-tools/build/abseil-cpp-src/CMake/absl-config.cmake".
Call Stack (most recent call first):
  external/cmake_install.cmake:41 (include)
  cmake_install.cmake:103 (include)

If I manually add an empty file in its place, the install goes through without error. However, as expected, I cannot use ortools in my cmake project with an empty absl-config.cmake file installed:

find_package(ortools CONFIG REQUIRED)

yields the following error:

CMake Error at CMakeLists.txt:12 (find_package):
  Found package configuration file:

    /usr/local/lib/cmake/ortools/ortoolsConfig.cmake

  but it set ortools_FOUND to FALSE so package "ortools" is considered to be
  NOT FOUND.  Reason given by package:

  The following imported targets are referenced, but are missing:
  absl::absl_base absl::absl_container absl::absl_hash absl::absl_memory
  absl::absl_meta absl::absl_str_format absl::absl_strings
  absl::absl_synchronization absl::absl_types

I then proceeded to find absl-config.cmake in /patches (in the source directory).
This file seems to contain a syntax error at least in tags/v7.0-beta1 (missing closing parenthesis).
I guess something was supposed to copy that file to the build directory where install expects it; I did that manually, retried the install, and it worked.

I still had no luck consuming ortools cmake config files in my cmake project, still with the same error message as before.
Adding a
find_package(absl CONFIG REQUIRED)
before that fixed this issue, so that configuring, building and linking (in my own CMake project) against ortools::ortools now works.

Was I doing something wrong here, like missing a "patching" step when running cmake? Then that should maybe be included somewhere in the documentation.

@Mizux Mizux self-assigned this Jan 23, 2019
@Mizux Mizux added this to the v7.0 milestone Jan 23, 2019
@Mizux Mizux added Bug OS: Linux GNU/Linux OS OS: Mac MacOS Build: CMake CMake based build issue labels Jan 23, 2019
@Mizux
Copy link
Collaborator

Mizux commented Jan 23, 2019

hi,

Thanks for the feedback, I need to rework the abseil-cpp integration against abseil/abseil-cpp#182 .

or-tools should depends on absl::base not absl::absl_base.

On my way to fix it...

@KK666-AI
Copy link

KK666-AI commented Jan 30, 2019

@phillip-keldenich I also try to install v7.0-beta1 based on source code, and meet the following error:
./ortools/algorithms/knapsack_solver.h:65:32: fatal error: absl/memory/memory.h: No such file or directory

Do you fix this error?

Finally, despite I haven't fix this error, I install v7.0 by
pip3.6 install ortools==7.0b6150

@Mizux Mizux changed the title Installing on Mac fails: file INSTALL cannot find absl-config.cmake CMake: Installing fails: file INSTALL cannot find absl-config.cmake Jan 30, 2019
@phillip-keldenich
Copy link
Author

No, for me, building (compiling etc.) worked fine, only installation didn't. This error sounds like some missing include directories somewhere in the build process. I also did not try to install ortools using pip (i.e., python package management), but directly using the source code.

I guess that fixing any issues will be harder for you than for me since you are not (completely) in control of the build process and debugging a build done on-the-fly by a package manager like pip will at least be quite inconvenient. Without further information, it also is not clear whether the problem is a bug in the pip package (possible) or ortools itself (also possible).

@Mizux
Copy link
Collaborator

Mizux commented Jan 30, 2019

The main issues with the current CMake based build, is:

  1. Few dependencies are not CMake based, and their rpath is not set (Cbc, no to mention any dependencies )
  2. Abseil-cpp need to be bump to have the lastest CMake target layout since I rework all CMakeLists.txt and was able to (redo) and submit it all on Piper last December and it has been exported to the public repo IIRC (see CMake: Rework to use absl_cc abseil/abseil-cpp#199 for details).
  3. Abseil-cpp don't provide install rule but I have a PR for abseil-cpp HEAD in progress see [WIP] CMake Install rule proposal abseil/abseil-cpp#182 (and it is replicated as internal pending submit so it should be close to the official ;) )
  4. last but not least, you can't create working install rule if you integrate your dependencies using the add_subdirectory()/ExternalProject() hack (what I do currently)
    TLDR: when you install a cmake target (e.g. ortools) you must also install all target_link_libraries() targets which are not IMPORTED target (e.g. absl::base) in the same export (i.e. absl targets must be installed in the export ortoolsTargets which is quite intrusive).
    bonus limitation: you can't install target ALIAS (say hello to absl::base target ALIAS 😄 , note: yes you can retrieve the original target name)
    bonus limitation: before cmake 3.13 you can't install target define outside of the current directory scope so you have to patch all dependencies to use your export file name...
    Todo(mizux): create a repository and longer/detailed explanation why it doesn't scale.
    note: PR Feature/better find package #1019 will help a little, but the wall process of dependencies must be rework to use an installed dependencies based CMake build i.e. or-tools build/install its deps otherwise it consume distro install package (which should provide imported targets)....
    note: you can find a nice topic on this subject (install dependencies) when abseil-cpp was refusing to have install target to be or not to be: CMake install()  abseil/abseil-cpp#38

EDIT: mostly fix by #1116 For OR-Tools only, need to explain how to install dependencies if your package manager (apk, pacman, yum, apt-get, zypper, homebrew, vcpkg, conan, hunter) doesn't provide them (ed or not at the right version)...

@Mizux Mizux removed this from the v7.0 milestone Feb 21, 2019
@Mizux Mizux changed the title CMake: Installing fails: file INSTALL cannot find absl-config.cmake CMake: install target not working: fails: file INSTALL cannot find absl-config.cmake Feb 21, 2019
@Mizux
Copy link
Collaborator

Mizux commented Feb 21, 2019

Don't want to block the release v7.0 which BTW only use the Makefile-based build to generate all its binary artifacts.
So I will postpone it to 7.1 since we need a deep rework of all the CMake (experimental) stuff.

@Mizux Mizux added this to the v7.1 milestone Mar 8, 2019
@Mizux Mizux mentioned this issue Apr 12, 2019
11 tasks
@Mizux Mizux closed this as completed Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Build: CMake CMake based build issue OS: Linux GNU/Linux OS OS: Mac MacOS
Projects
None yet
Development

No branches or pull requests

3 participants