Fix CMake package config file#3068
Fix CMake package config file#3068Mizux merged 2 commits intogoogle:masterfrom gmgunter:cmake-config-fix
Conversation
There are currently a few issues with how the COIN-OR dependencies are resolved when using `find_package(ortools CONFIG)` to add or-tools to an external CMake project. * With CMake >=3.9.6, we try to find the Clp and Cbc packages using the CONFIG mode of `find_package`. This always fails since neither library provides a CMake config file. * If we address the above issue by instead using the MODULE mode of `find_package`, then we need to add `FindCbc.cmake` and `FindCpl.cmake` scripts to the CMAKE_MODULE_PATH in order to teach CMake how to find these dependencies. I propose that or-tools should install these scripts alongside its config file so that they're available to external CMake projects. * Finally, the `FindCbc.cmake` script included with or-tools defines the variable `CBC_FOUND` when it's successful, rather than `Cbc_FOUND` as expected (CMake variables are case-sensitive). The `FindCpl.cmake` script has a similar issue. As a result, even when the above two points are addressed, `find_package(ortools CONFIG)` will still fail because CMake erroneously thinks that these two dependencies weren't succesfully found. This commit attempts to address the above issues with the following changes: * The or-tools CMake config file is modified to allow searching for Cbc and Cpl using the MODULE mode of `find_package`. * `FindCbc.cmake` and `FindCpl.cmake` are installed with the CMake package config files and are added to the CMAKE_MODULE_PATH if `USE_COINOR` was truthy. * The `FindCbc.cmake` and `FindCpl.cmake` files are modified to change the case of variables they export.
|
That's too bad. The most elegant solution would definitely be for these upstream packages to add CMake support.
This would be really nice. I installed or-tools via the conda-forge package, which builds with |
|
FYI I'll need to change the module CMake since:
On my way to fix it, if you have some regression in your own workflow, please let me know... |
|
Sounds good 👌 |
|
@Mizux I'll probably be the one to rip out all the |
note: here pkg-config/autotools based build means what coin-or provide if I understand correctly your point |
a) The current name of most coin-or ports in vcpkg is wrong according to https://github.com/microsoft/vcpkg/blob/master/docs/maintainers/maintainer-guide.md#check-names-against-other-repositories (basically the ports need a prefix b)
vcpkg has a port for pkgconf. If it is installed CMake's
No. Upstream it or leave it. Source packages have to come from the authoritative source. So I already started ripping it out: microsoft/vcpkg#29398. basically the only thing left to do is fixing openmvg and getting the linux VM to have autoconf 2.71 |
There are currently a few issues with how the COIN-OR dependencies are resolved when using
find_package(ortools CONFIG)to add or-tools to an external CMake project.With CMake >=3.9.6, we try to find the Clp and Cbc packages using the CONFIG mode of
find_package. This always fails since neither coin-or/Clp nor coin-or/Cbc provides a CMake config file.If we address the above issue by instead using the MODULE mode of
find_package, then we need to addFindCbc.cmakeandFindCpl.cmakescripts to the CMAKE_MODULE_PATH in order to teach CMake how to find these dependencies. I propose that or-tools should install these scripts alongside its config file so that they're available to external CMake projects.Finally, the
FindCbc.cmakescript included with or-tools defines the variableCBC_FOUNDwhen it's successful, rather thanCbc_FOUNDas expected (CMake variables are case-sensitive). TheFindCpl.cmakescript has a similar issue. As a result, even when the above two points are addressed,find_package(ortools CONFIG)will still fail because CMake erroneously thinks that these two dependencies weren't succesfully found.This PR attempts to address the above issues with the following changes:
The CMake config file is modified to allow searching for Cbc and Cpl using the MODULE mode of
find_package.FindCbc.cmakeandFindCpl.cmakeare installed with the CMake package config files and are added to the CMAKE_MODULE_PATH ifUSE_COINORwas truthy.The
FindCbc.cmakeandFindCpl.cmakefiles are modified to change the case of the variables they export.