Cleanup CMake based build #1116
Labels
Bug
Build: CMake
CMake based build issue
Feature Request
Missing Feature/Wrapper
Lang: C++
Native implementation issue
OS: Linux
GNU/Linux OS
OS: Mac
MacOS
OS: Windows
Windows OS
Milestone
Introduction
All CMakeLists.txt need a deep refactoring about the dependencies management.
Quick Survey
Prebuilt vs Sources
There is two main way to consume a dependency,
Using some prebuilt binary
Integrating the dependency source to your project and compile them along the way.
IMPORTED
must form a closure on the install export set. (seeadd_subdirectory()
limitation below)How to retrieve dependency Source ?
How to retrieve Prebuilt
find_package()
and it's the user responsibility to provide them...cons: do at build time not access to project stuff e.g. config.cmake...
find_package()
see: https://github.com/Mizux/cmake-abseil/tree/install
Three shades of ExternalProject usage
AFAIK there is three way to use CMake
ExternalProject
module."submodule hack" like gtest doc
see https://github.com/google/googletest/tree/master/googletest#incorporating-into-an-existing-cmake-project
(ed notice the configure/build/install command set to empty string -> only the "download/update step is performed") like a git submodule (aka Strategy 2)
"prebuilt hack" like "submobule hack" BUT build/install it in a staging area and add this staging to CMAKE_PREFIX_PATH
example: https://github.com/Mizux/cmake-abseil/tree/install
Roadmap
install/find_package()
overadd_subdirectory()
)add_subdirectory()
doesn't work...Misc
Related PR
find_package()
everywhere, Tricks: you may have hiddenadd_subdirectory()
inside FindFoo.cmakeRelated issues
Reference
youtube: https://youtu.be/sBP17HQAQjk
add_subdirectory()
limitationIf you see this kind error
Bravo ! you just figure out the limitation of add_subdirectory() vs regular cmake install dependencies ;)
add_subdirectory() add dependency targets not as
IMPORTED
targets so your export set must contains them (think of a graph closure of all target not imported) which you can't do unless hacking dependency source to modify the export set name...note: bear in mind that until CMake 3.13, you can't add target to your super project export set.
src: https://cmake.org/cmake/help/v3.13/release/3.13.html#commands
note: simpler example here: https://github.com/Mizux/cmake-abseil
Coin-OR integration
long story: coin-Cbc was on svn and I created the repo Mizux/cbc based on their "mono-repo" svn archive, then I added a CMake-based build.
Now, coin-OR use a one repo per library approach, you can see on github they have split coin-or in several repo, so I moved it to mizux/coinor-cbc in order to fork coinor/Cbc to add (again) a CMake-Based build.
Here the list of my fork:
Hope to soon send PR to coin-or maintainer, CMake patches/improvement are welcome !
warning: until I would consider my CMake integration "Stable/good enough" I'll heavily use rebase/fixup on my branch to keep an atomic final CMake single patch, which mean don't rely on SHA1 until release (i.e. PR is sent to coin-or)...
The text was updated successfully, but these errors were encountered: