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.
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: https://github.com/google/or-tools/blob/80857633a75a5e336ab9e064249aef5f5ec0bb9a/CMakeLists.txt#L59-L68
note: I've send a PR to coin-or maintainer to add them.
see https://github.com/coin-or/CoinUtils/pull/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 https://github.com/Microsoft/vcpkg/pull/5166#issuecomment-457760339)
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
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
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
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?
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...
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?
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 ?
you need this:
https://github.com/google/or-tools/blob/f3fd201e68cf75b7720ff5c3cadc599a1d02b54b/cmake/cpp.cmake#L12-L13
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
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)
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
https://github.com/google/or-tools/blob/f3fd201e68cf75b7720ff5c3cadc599a1d02b54b/cmake/ortoolsConfig.cmake.in#L7-L52
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)
Kitware provides a FindZLIB.cmake as builtin -> I should not use CONFIG in find_dependency().
Thx for the "error report"
Most helpful comment
Thanks, I can now compile.
For reference, my CMakeList now looks like: