daixtrose / cmake_utilities

CMake utilities addressing configuration management and dependency hell mitigation
MIT License
7 stars 1 forks source link

Dependency resolver ignores user-defined name of library #6

Open daixtrose opened 1 year ago

daixtrose commented 1 year ago

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'
...
daixtrose commented 1 year ago

Not sure if

                    if(NOT REPOMAN_DEPENDENCY_URI)
                        string(TOLOWER ${REPOMAN_DEPENDENCY_NAME} LOWER_NAME)
                        string(TOUPPER ${REPOMAN_DEPENDENCY_NAME} UPPER_NAME)
                        set(FETCHCONTENT_SOURCE_DIR_${UPPER_NAME} "${${LOWER_NAME}_SOURCE_DIR}")
                    endif()

is a good idea. To be discussed.

cpp-entwickler-de commented 1 year ago

The variables used here are not set by us, nor FetchContent. They are set by CMake when using add_subdirectory() with a directory that contains a project() call. They are always using the subproject name, regardless of the name used by us. Another option would be to use FetchContent_GetProperties() with our selected name to get the proper variables.