Coder Social home page Coder Social logo

cmake_utilities's Issues

Dependency target not found

How to reproduce

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 ..

Output

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?

Demo example `tool_1` fails to configure on second run

Environment

  • WSL2 on Windows 10
  • Linux [...] 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
  • cmake version 3.27.4

Steps to reproduce

git clone https://github.com/dep-heaven/tool_1
cd tool_1
mkdir build
cd build/
cmake ..

The last call populates the dependencies to ws

rm -rf *
cmake ..

CMake fails with

...
==> Toplevel: lib_A_SOURCE_DIR = ''
Catch path is '/extras'
CMake Error at test-catch/CMakeLists.txt:7 (include):
  include could not find requested file:

    Catch


-- DEFINE_UNIT_TEST_NAME = test_tool_1
-- DEFINE_UNIT_TEST_FILES = ../src/fn.cpp;test_main.cpp;test_tool_1.cpp
CMake Error at test-catch/CMakeLists.txt:51 (catch_discover_tests):
  Unknown CMake command "catch_discover_tests".


-- Configuring incomplete, errors occurred!

Full sequence of a failure

user@jost:~/PROJECT/tool_1/build$ cmake ..
-- Resolving dependencies of project /home/markus/PROJECT/tool_1
-- Checking dependency 'lib_A': https://github.com/dep-heaven/lib_A @ master-yoda
-- Initializing in '/home/markus/PROJECT/tool_1/ws/lib_A'
-- Checking dependency 'lib_B': https://github.com/dep-heaven/lib_B @ master-yoda
-- Initializing in '/home/markus/PROJECT/tool_1/ws/lib_B'
-- Checking dependency 'libFreeAssange': https://github.com/dep-heaven/libFreeAssange @ belmarsh
-- Initializing in '/home/markus/PROJECT/tool_1/ws/libFreeAssange'
-- Checking dependency 'catch2': https://github.com/catchorg/Catch2 @ v2.x
-- Initializing in '/home/markus/PROJECT/tool_1/ws/catch2'
-- Checking dependency 'fmt': https://github.com/fmtlib/fmt @ master
-- Initializing in '/home/markus/PROJECT/tool_1/ws/fmt'
-- Resolving dependencies of project /home/markus/PROJECT/tool_1/ws/lib_A
-- Checking dependency 'catch2': https://github.com/catchorg/Catch2 @ v2.x
-- Checking dependency 'fmt': https://github.com/fmtlib/fmt @ master
-- {fmt} version: 10.2.2
-- Build type: 
-- Resolving dependencies of project /home/markus/PROJECT/tool_1/ws/lib_B
-- Checking dependency 'libFreeAssange': https://github.com/dep-heaven/libFreeAssange @ wikileaks
-- Dependency 'libFreeAssange @ wikileaks' is overridden with 'libFreeAssange @ belmarsh'
-- Checking dependency 'catch2': https://github.com/catchorg/Catch2 @ v2.x
-- Checking dependency 'fmt': https://github.com/fmtlib/fmt @ master
-- Resolving dependencies of project /home/markus/PROJECT/tool_1/ws/libFreeAssange
-- Checking dependency 'catch2': https://github.com/catchorg/Catch2 @ v2.x
-- Checking dependency 'fmt': https://github.com/fmtlib/fmt @ master
WARNING! Something is still wrong here!
   RepoMan should populate selected name, not original name
==> Toplevel: catch2_SOURCE_DIR = '/home/markus/PROJECT/tool_1/ws/catch2'
==> Toplevel: Catch2_SOURCE_DIR = '/home/markus/PROJECT/tool_1/ws/catch2'
==> Toplevel: lib_a_SOURCE_DIR = '/home/markus/PROJECT/tool_1/ws/lib_A'
==> Toplevel: lib_A_SOURCE_DIR = '/home/markus/PROJECT/tool_1/ws/lib_A'
Catch path is '/home/markus/PROJECT/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
--     lib_B @ master-yoda
--     libFreeAssange @ belmarsh, chosen from [belmarsh, wikileaks]
--     catch2 @ v2.x, chosen from [v2.x, v2.x, v2.x, v2.x]
--     fmt @ master, chosen from [master, master, master, master]
-- Configuring done (16.7s)
-- Generating done (0.0s)
-- Build files have been written to: /home/markus/PROJECT/tool_1/build
user@jost:~/PROJECT/tool_1/build$ rm -rf *
user@jost:~/PROJECT/tool_1/build$ cmake ..
-- 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/tool_1
-- Checking dependency 'lib_A': https://github.com/dep-heaven/lib_A @ master-yoda
-- Dependency 'lib_A': ok (master-yoda)
-- Checking dependency 'lib_B': https://github.com/dep-heaven/lib_B @ master-yoda
-- Dependency 'lib_B': ok (master-yoda)
-- Checking dependency 'libFreeAssange': https://github.com/dep-heaven/libFreeAssange @ belmarsh
-- Dependency 'libFreeAssange': ok (belmarsh)
-- Checking dependency 'catch2': https://github.com/catchorg/Catch2 @ v2.x
-- Dependency 'catch2': ok (v2.x)
-- Checking dependency 'fmt': https://github.com/fmtlib/fmt @ master
-- Dependency 'fmt': ok (master)
WARNING! Something is still wrong here!
   RepoMan should populate selected name, not original name
==> Toplevel: catch2_SOURCE_DIR = '/home/markus/PROJECT/tool_1/ws/catch2'
==> Toplevel: Catch2_SOURCE_DIR = ''
==> Toplevel: lib_a_SOURCE_DIR = '/home/markus/PROJECT/tool_1/ws/lib_A'
==> Toplevel: lib_A_SOURCE_DIR = ''
Catch path is '/extras'
CMake Error at test-catch/CMakeLists.txt:7 (include):
  include could not find requested file:

    Catch


-- DEFINE_UNIT_TEST_NAME = test_tool_1
-- DEFINE_UNIT_TEST_FILES = ../src/fn.cpp;test_main.cpp;test_tool_1.cpp
CMake Error at test-catch/CMakeLists.txt:51 (catch_discover_tests):
  Unknown CMake command "catch_discover_tests".


-- Configuring incomplete, errors occurred!

Dependency resolver ignores user-defined name of library

Summary

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)

How to reproduce

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 ..

Output

...
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'
...

Pure CMake approach

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.

repoman.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.