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

CoinUtilsConfig.cmake not found #1236

Closed
JimMcMahon opened this issue May 1, 2019 · 12 comments
Closed

CoinUtilsConfig.cmake not found #1236

JimMcMahon opened this issue May 1, 2019 · 12 comments
Assignees
Labels
Build: CMake CMake based build issue Help Needed Modeling/Usage problem OS: Mac MacOS
Milestone

Comments

@JimMcMahon
Copy link

JimMcMahon commented May 1, 2019

I'm trying the cmake build to get cmake support and i keep running into this:

Could not find a package configuration file provided by "CoinUtils" with
  any of the following names:

    CoinUtilsConfig.cmake
    coinutils-config.cmake

  Add the installation prefix of "CoinUtils" to CMAKE_PREFIX_PATH or set
  "CoinUtils_DIR" to a directory containing one of the above files.  If
  "CoinUtils" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  build/cbc-src/CMakeLists.txt:63 (find_package)

Am i simply not configuring something properly? I've gone the brew route to get CoinUtils as well as installing CoinUtils from source to no available.

@Mizux
Copy link
Collaborator

Mizux commented May 2, 2019

Supposing you are using the master branch (our trunk)

I'm using a custom CMake based build of CoinUtils to provide a multi-platform CoinUtilsConfig.cmake
You may use -DBUILD_*:BOOL=ON to build them or BUIILD_DEPS:BOOL=ON to build them all...

see:

or-tools/CMakeLists.txt

Lines 59 to 68 in 8085763

CMAKE_DEPENDENT_OPTION(BUILD_CoinUtils "Build the CoinUtils dependency Library" OFF
"NOT BUILD_DEPS" ON)
CMAKE_DEPENDENT_OPTION(BUILD_Osi "Build the Osi dependency Library" OFF
"NOT BUILD_DEPS" ON)
CMAKE_DEPENDENT_OPTION(BUILD_Clp "Build the Clp dependency Library" OFF
"NOT BUILD_DEPS" ON)
CMAKE_DEPENDENT_OPTION(BUILD_Cgl "Build the Cgl dependency Library" OFF
"NOT BUILD_DEPS" ON)
CMAKE_DEPENDENT_OPTION(BUILD_Cbc "Build the Cbc dependency Library" OFF
"NOT BUILD_DEPS" ON)

note: I've send a PR to coin-or maintainer to add them.
see coin-or/CoinUtils#101 and others...
note2: I don't want to use their autotools based build since it didn't work when path contains space (e.g. Program Files on windows...)
note3: I'm also targeting vcpkg on the long run and currently the provided CMakelists.txt are broken and have not been PR to the coin-or project (see microsoft/vcpkg#5166 (comment))

An other way would be for you to provide a custom FindCoinUtils.cmake module (using the CMake FindPkgConfig module) to use your CoinUtils brew installation (you'll need to provide a coin::CoinUtils IMPORTED target IIRC)

Please note the CMake build is still experimental

@Mizux Mizux added Build: CMake CMake based build issue Help Needed Modeling/Usage problem OS: Mac MacOS labels May 2, 2019
@JimMcMahon
Copy link
Author

JimMcMahon commented May 3, 2019

Thanks for the reply. I was using the stable version which looks like it was the wrong branch.

So i did the following modification to the build commands:
cmake -DBUILD_DEPS:BOOL=ON -H. -Bbuild -G "Unix Makefiles"

and this was the result:

-- Build all dependencies: ON
-- Build ZLIB: ON
-- Build abseil-cpp: ON
-- Build gflags: ON
-- Build glog: ON
-- Build protobuf: ON
-- Build CoinUtils: ON
-- Build Osi: ON
-- Build Clp: ON
-- Build Cgl: ON
-- Build Cbc: ON

I can see all of the *config.cmake and *target.cmake files in the dependencies/install/lib/cmake folder,

When i step through the rest of the instructions,

cmake --build build
cmake --build build --target install

it seems that it's never actually building the dependencies on my machine. If I navigate to either dependencies/gflags/build/lib or dependencies/install/lib it didn't build any of the libraries for MacOSX

@Mizux
Copy link
Collaborator

Mizux commented May 3, 2019

it should build all dependencies at configure time (when you run cmake -DBUILD_DEPS:BOOL=ON -H. -Bbuild -G "Unix Makefiles")

I'll take a look this weekend ! Thx for the feedback

@Mizux Mizux self-assigned this May 3, 2019
@Mizux Mizux added this to the v7.1 milestone May 3, 2019
@JimMcMahon
Copy link
Author

JimMcMahon commented May 3, 2019

Looks like it's building the static libraries,

or-tools/build/dependencies/install/lib$ ls
cmake/                            libabsl_base.a                    libabsl_leak_check_disable.a      libabsl_time_zone.a
libCbc.a                          libabsl_city.a                    libabsl_malloc_internal.a         libgflags.a
libCbcSolver.a                    libabsl_civil_time.a              libabsl_raw_hash_set.a            libgflags_nothreads.a
libCgl.a                          libabsl_debugging_internal.a      libabsl_scoped_set_env.a          libglog.a
libClp.a                          libabsl_demangle_internal.a       libabsl_spinlock_wait.a           libprotobuf-lite.a
libClpSolver.a                    libabsl_dynamic_annotations.a     libabsl_stacktrace.a              libprotobuf.a
libCoinUtils.a                    libabsl_examine_stack.a           libabsl_str_format_internal.a     libprotoc.a
libOsi.a                          libabsl_failure_signal_handler.a  libabsl_strings.a                 libz.1.2.11.dylib*
libOsiCbc.a                       libabsl_graphcycles_internal.a    libabsl_strings_internal.a        libz.1.dylib@
libOsiClp.a                       libabsl_hash.a                    libabsl_symbolize.a               libz.a
libabsl_bad_any_cast_impl.a       libabsl_hashtablez_sampler.a      libabsl_synchronization.a         libz.dylib@
libabsl_bad_optional_access.a     libabsl_int128.a                  libabsl_throw_delegate.a          pkgconfig/
libabsl_bad_variant_access.a      libabsl_leak_check.a              libabsl_time.a

but when i go to build my project it can't find the static library:

ld: library not found for -lgflags::gflags_static
clang: error: linker command failed with exit code 1 (use -v to see invocation)

in my cmake project i'm doing the following which I think is correct:
target_link_libraries(${testname} taskAssignment ortools::ortools)

edit: I should include the warning i get from cmake as well -

CMake Error at CMakeLists.txt:64 (add_executable):
  Target "test_two" links to target "gflags::gflags_static" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?

@Mizux
Copy link
Collaborator

Mizux commented May 6, 2019

Please note, we don't install dependencies so you must provide them to your project...

How did you integrate ortools in "MyProject" ?

You can try to add to CMAKE_PREFIX_PATH the path of or-tools/build/dependencies/install and then a find_package(gflags) in your project....
The goal here is to be easy to integrate in the CMake ecosystem i.e. or-tools only provide an or-tools CMake package.

BUILD_DEPS is mostly used for testing purpose and wrapper package (Python,.Net, Java) in order to build standalone package.
But it may make sens to also install the dependencies you decide to build -> need to think of it for next release...

@Mizux Mizux modified the milestones: v7.1, v7.2 May 6, 2019
@JimMcMahon
Copy link
Author

I've integrated the or-tools project through cmake two ways but i get the same result, either I include

set(CMAKE_PREFIX_PATH "../../External/or-tools/build/dependencies/install/lib/cmake")

or I include the or-tools folder in the main directory, the results is in my previous message. If i'm going to install CoinUtils with cmake support, should I use the code in

/or-tools/build/dependencies/CoinUtils/source

for CointUtils and any other dependencies that I need CMake support for?

@MarcTestier
Copy link

Hi, I'm trying to integrate ortools to a CMake project and I've reached the same step as @JimMcMahon :

CMake Error at CMakeLists.txt:52 (add_executable):
  Target "VRPTest1Node" links to target "gflags::gflags_static" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?

I've tried with the stable branch built with make as well as the master + make and master + cmake.

I know I need to provide the dependencies myself and I've tried using both the gflags version built with ortools as well as a gflags version built externally (both as a shared and static lib) but still got the same problem.

My minimal version of the CMakeList look like that :

list(APPEND CMAKE_PREFIX_PATH "/home/m-a/vrp/or-tools/build/dependencies/install/")

find_package(ZLIB REQUIRED)
find_package(gflags REQUIRED)
find_package(ortools CONFIG REQUIRED)


add_executable(VRPTest1Node src/VRPTest1Node.cc)
target_link_libraries(VRPTest1Node ortools::ortools)

I've tried adding gflags to the CMAKE_PREFIX_PATH a few different ways as bellow :

list(APPEND CMAKE_PREFIX_PATH "/home/m-a/vrp/or-tools/build/dependencies/install/")
list(APPEND CMAKE_PREFIX_PATH "/home/m-a/vrp/gflags/build/")
list(APPEND CMAKE_PREFIX_PATH "/home/m-a/vrp/or-tools/build/dependencies/install/lib/")
list(APPEND CMAKE_PREFIX_PATH "/home/m-a/vrp/or-tools/build/dependencies/install/lib/cmake/gflags/")

And I've tried using find_package a few different ways too :

find_package(gflags REQUIRED)
find_package(gflags COMPONENTS static REQUIRED)
find_package(gflags PATHS /home/m-a/vrp/gflags/build/ NO_DEFAULT_PATH REQUIRED)
find_package(gflags PATHS /home/m-a/vrp/or-tools/build/dependencies/install/ NO_DEFAULT_PATH REQUIRED)
find_package(gflags PATHS /home/m-a/vrp/or-tools/build/dependencies/install/lib/cmake/gflags/ NO_DEFAULT_PATH REQUIRED)

Any idea what I'm doing wrong ?
@JimMcMahon Any progress integrating ortools to your CMake project ?

@Mizux
Copy link
Collaborator

Mizux commented May 17, 2019

you need this:

or-tools/cmake/cpp.cmake

Lines 12 to 13 in f3fd201

set(GFLAGS_USE_TARGET_NAMESPACE TRUE)
find_package(gflags REQUIRED CONFIG)

BTW sorry for the current "poor" integration documentation using the CMake-based build, I need to add ci/docker test and also try to build or-tools using external gflags or/and internal. And test the install rules too.
I'll work on it ASAP !

note: you should read/subscribe to #1116 and #1200

@MarcTestier
Copy link

MarcTestier commented May 17, 2019

Thanks, I can now compile.
For reference, my CMakeList now looks like:

list(APPEND CMAKE_PREFIX_PATH "/home/m-a/vrp/or-tools/build/dependencies/install/")

find_package(ZLIB REQUIRED)
set(GFLAGS_USE_TARGET_NAMESPACE TRUE)
find_package(gflags REQUIRED CONFIG)
find_package(ortools CONFIG REQUIRED)

add_executable(VRPTest1Node src/VRPTest1Node.cpp)
target_link_libraries(VRPTest1Node ortools::ortools)

@Mizux
Copy link
Collaborator

Mizux commented May 17, 2019

I'm not 100% (i.e. not tested) but maybe this should work too

list(APPEND CMAKE_PREFIX_PATH "/home/m-a/vrp/or-tools/build/dependencies/install/")

set(GFLAGS_USE_TARGET_NAMESPACE TRUE)
find_package(ortools CONFIG REQUIRED)

add_executable(VRPTest1Node src/VRPTest1Node.cpp)
target_link_libraries(VRPTest1Node ortools::ortools)

since we already load/search our dependencies using the dependencies module

include(CMakeFindDependencyMacro)
if(${CMAKE_VERSION} VERSION_LESS "3.9.6")
if(NOT ZLIB_FOUND)
find_dependency(ZLIB REQUIRED)
endif()
if(NOT absl_FOUND)
find_dependency(absl REQUIRED)
endif()
if(NOT gflags_FOUND)
find_dependency(gflags REQUIRED)
endif()
if(NOT glog_FOUND)
find_dependency(glog REQUIRED)
endif()
if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)
find_dependency(Protobuf REQUIRED)
endif()
if(NOT Clp_FOUND)
find_dependency(Clp REQUIRED)
endif()
if(NOT Cbc_FOUND)
find_dependency(Cbc REQUIRED)
endif()
else()
if(NOT ZLIB_FOUND)
find_dependency(ZLIB REQUIRED CONFIG)
endif()
if(NOT absl_FOUND)
find_dependency(absl REQUIRED CONFIG)
endif()
if(NOT gflags_FOUND)
find_dependency(gflags REQUIRED CONFIG)
endif()
if(NOT glog_FOUND)
find_dependency(glog REQUIRED CONFIG)
endif()
if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)
find_dependency(Protobuf REQUIRED CONFIG)
endif()
if(NOT Clp_FOUND)
find_dependency(Clp REQUIRED CONFIG)
endif()
if(NOT Cbc_FOUND)
find_dependency(Cbc REQUIRED CONFIG)
endif()
endif()

ref: CMakeFindDependencyMacro

@MarcTestier
Copy link

I can remove find_package(gflags REQUIRED CONFIG) but still need to find ZLIB for some reason, so I'm left with :

list(APPEND CMAKE_PREFIX_PATH "/home/m-a/vrp/or-tools/build/dependencies/install/")

find_package(ZLIB REQUIRED)
set(GFLAGS_USE_TARGET_NAMESPACE TRUE)
find_package(ortools CONFIG REQUIRED)

add_executable(VRPTest1Node src/VRPTest1Node.cpp)
target_link_libraries(VRPTest1Node ortools::ortools)

@Mizux
Copy link
Collaborator

Mizux commented May 17, 2019

Kitware provides a FindZLIB.cmake as builtin -> I should not use CONFIG in find_dependency().

Thx for the "error report"

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 Help Needed Modeling/Usage problem OS: Mac MacOS
Projects
None yet
Development

No branches or pull requests

3 participants