daixtrose / cmake_utilities Goto Github PK
View Code? Open in Web Editor NEWCMake utilities addressing configuration management and dependency hell mitigation
License: MIT License
CMake utilities addressing configuration management and dependency hell mitigation
License: MIT License
Proposal: Add Version: v1.0.0
at the top of each dependencies.txt and make it mandatory, i.e. bail out if missing.
This is a demo that handles dependencies purely in CMake by reading dependencies.txt files from the root directory of a project (and recursively for all listed dependencies). It only requires git and a non-ancient CMake version (> 3.19) to be installed.
The dependencies.txt format is repo-uri revision [subdirectory]
with one dependency per line. revision
can be anything that can be checked out by git. subdirectory
is optional in case the dependencies.txt or CMakeLists.txt file are not in the git root.
The RepoMan module can be either included in CMake projects or be called by its name on the command line inside a non-CMake project. The demo projects already include it, but it can also be called via command line while within any project directory. The only difference is that the latter will not configure/generate a project.
In RepoMan.cmake the default filename is defined as my_deps.txt
. This should be a name more likely to be used.
lib_A
currently does not depend on libFreeAssange, thereby lacking the opportunity to show how overwriting of dependencies of dependencies can work.
Not sure if this is a bug. FetchContent
allows one to declare private names for dependencies (please note the lowercase catch2
):
FetchContent(catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2 GIT_TAG v2.x)
But it seems that the directory population uses the original uppercase name. To my surprise the reference to the _SOURCE_DIR
must use the original upper case name, i.e.
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/contrib)
Use the testsuite in https://github.com/dep-heaven/tool_1:
git clone https://github.com/dep-heaven/tool_1
cd tool_1/
mkdir build
cd build/
cmake ..
...
WARNING! Something is still wrong here!
RepoMan should populate selected name, not original name
==> Toplevel: catch2_SOURCE_DIR = ''
==> Toplevel: Catch2_SOURCE_DIR = '/home/markus/PROJECT/GARBAGE/tool_1/ws/catch2'
==> Toplevel: lib_A_SOURCE_DIR = '/home/markus/PROJECT/GARBAGE/tool_1/ws/lib_A'
...
Use the testsuite in https://github.com/dep-heaven/tool_1:
git clone https://github.com/dep-heaven/tool_1
cd tool_1/
mkdir build
cd build/
cmake ..
Cloning into 'tool_1'...
remote: Enumerating objects: 33, done.
remote: Counting objects: 100% (33/33), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 33 (delta 9), reused 25 (delta 5), pack-reused 0
Receiving objects: 100% (33/33), 8.45 KiB | 577.00 KiB/s, done.
Resolving deltas: 100% (9/9), done.
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Resolving dependencies of project /home/markus/PROJECT/GARBAGE/tool_1
-- Checking dependency 'lib_A': https://github.com/dep-heaven/lib_A @ master-yoda
-- Initializing in '/home/markus/PROJECT/GARBAGE/tool_1/ws/lib_A'
-- Checking dependency 'lib_B': https://github.com/dep-heaven/lib_B @ master-yoda
-- Initializing in '/home/markus/PROJECT/GARBAGE/tool_1/ws/lib_B'
-- Checking dependency 'libFreeAssange': https://github.com/dep-heaven/libFreeAssange @ belmarsh
-- Initializing in '/home/markus/PROJECT/GARBAGE/tool_1/ws/libFreeAssange'
-- Checking dependency 'catch2': https://github.com/catchorg/Catch2 @ v2.x
-- Initializing in '/home/markus/PROJECT/GARBAGE/tool_1/ws/catch2'
-- Checking dependency 'fmt': https://github.com/fmtlib/fmt @ master
-- Initializing in '/home/markus/PROJECT/GARBAGE/tool_1/ws/fmt'
-- The C compiler identification is GNU 12.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Version: 10.1.1
-- Build type:
WARNING! Something is still wrong here!
RepoMan should populate selected name, not original name
==> Toplevel: catch2_SOURCE_DIR = ''
==> Toplevel: Catch2_SOURCE_DIR = '/home/markus/PROJECT/GARBAGE/tool_1/ws/catch2'
==> Toplevel: lib_A_SOURCE_DIR = '/home/markus/PROJECT/GARBAGE/tool_1/ws/lib_A'
Catch path is '/home/markus/PROJECT/GARBAGE/tool_1/ws/catch2/extras'
-- DEFINE_UNIT_TEST_NAME = test_tool_1
-- DEFINE_UNIT_TEST_FILES = ../src/fn.cpp;test_main.cpp;test_tool_1.cpp
-- Dependencies:
-- lib_A @ master-yoda, chosen from [master-yoda]
-- lib_B @ master-yoda, chosen from [master-yoda]
-- libFreeAssange @ belmarsh, chosen from [belmarsh]
-- catch2 @ v2.x, chosen from [v2.x]
-- fmt @ master, chosen from [master]
-- Configuring done
CMake Error at test-catch/CMakeLists.txt:24 (add_executable):
Target "test_tool_1" links to target "Daixtrose::lib_A" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
Call Stack (most recent call first):
test-catch/CMakeLists.txt:43 (define_unit_test)
CMake Error at CMakeLists.txt:47 (add_executable):
Target "tool_1" links to target "Daixtrose::lib_A" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.