Issue
I have two FetchContent actions to get two repositories. One repo works fine with the SourceDir populated. The other has an empty SourceDir. Both repos are downloaded and populated in the _deps
directory.
/home/rmerriam/.local/share/JetBrains/Toolbox/apps/clion/bin/cmake/linux/x64/bin/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/home/rmerriam/.local/share/JetBrains/Toolbox/apps/clion/bin/ninja/linux/x64/ninja -G Ninja -S /mnt/devel/cpp_articles -B /mnt/devel/cpp_articles/cmake-build-release
MYS_UTIL SRC_DIR /mnt/devel/cpp_articles/cmake-build-release/_deps/mys-util-src
TRACE_SRC_DIR
-- Configuring done (0.9s)
-- Generating done (0.0s)
-- Build files have been written to: /mnt/devel/cpp_articles/cmake-build-release
[Finished]
The line MYS_UTIL SRC_DIR shows the directory for it. The line TRACE_SRC_DIR is blank.
Here is the CMakeLists.txt:
cmake_minimum_required(VERSION 3.27)
project(mys_to)
include(FetchContent)
add_compile_options(-std=c++23
-Werror -Wpedantic -Wall -Wno-unused-variable
-fno-exceptions -fdiagnostics-plain-output
# -fconcepts-diagnostics-depth=2
)
FetchContent_Declare(
Trace
GIT_REPOSITORY https://gitlab.com/mystic-lake-libs/Trace.git
GIT_TAG main
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
)
FetchContent_MakeAvailable(Trace)
FetchContent_Declare(
mys-util
GIT_REPOSITORY https://gitlab.com/mystic-lake-libs/mys-util
GIT_TAG main
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
)
FetchContent_MakeAvailable(mys-util)
message(STATUS ${mys-util_SOURCE_DIR})
message(STATUS ${Trace_SOURCE_DIR})
include_directories(${Trace_SOURCE_DIR})
include_directories(${mys-util_SOURCE_DIR})
Any suggestions on what is going wrong?
Solution
Module FetchContent defines project-related variables by prefixing them with the name of the project in lowercase. So, for the project Trace
the name of the variable containing its source directory is trace_SOURCE_DIR
.
Answered By - Tsyvarev Answer Checked By - David Goodson (WPSolving Volunteer)