Configuring CMake fails
stephenberry opened this issue · 4 comments
Configuring CMake with stdexec as a dependency works the first time entirely from scratch (on Mac/Windows). However, subsequent calls to CMake will produce the following error:
CMake Error at build/_deps/stdexec-src/test/CMakeLists.txt:140 (include):
include could not find requested file:
/contrib/Catch.cmake
CMake Error at build/_deps/stdexec-src/test/CMakeLists.txt:142 (catch_discover_tests):
Unknown CMake command "catch_discover_tests".
Deleting the cache seems to work, except on Linux which seems to have this problem more persistently.
We're configuring with STD_BUILD_TESTS turned off.
stdexec doesn't use STD_BUILD_TESTS
for anything. it builds tests if either of STDEXEC_BUILD_TESTS
or BUILD_TESTING
is set to a truthy value.
i have never seen this error, but then again i don't typically build stdexec as a dependency. i'll see if i can repro when i have a chance.
I am finding the bug to be intermittent. Two observations when this error occurs:
- the catch repo was not included in the
CMAKE_BINARY_DIR/_deps
folder (it was not downloaded) - the path error indicates
contrib/Catch.cmake
when it should be something line${CMAKE_BINARY_DIR}/_deps/catch2-src/contrib/Catch.cmake
I avoided this error by not using CPM in my project:
function (fetch_stdexec)
set(branch_or_tag "main")
set(url "https://github.com/NVIDIA/stdexec.git")
set(target_folder "${CMAKE_BINARY_DIR}/_deps/stdexec-src")
if (NOT EXISTS ${target_folder})
execute_process(
COMMAND git clone --depth 1 --branch "${branch_or_tag}" --recursive "${url}" "${target_folder}"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE exec_process_result
OUTPUT_VARIABLE exec_process_output
)
if(NOT exec_process_result EQUAL "0")
message(FATAL_ERROR "Git clone failed: ${exec_process_output}")
else()
message(STATUS "Git clone succeeded: ${exec_process_output}")
endif()
endif()
set(stdexec_SOURCE_DIR ${target_folder} CACHE INTERNAL "stdexec source folder" FORCE)
set(stdexec_INCLUDE_DIR ${target_folder}/include CACHE INTERNAL "stdexec include folder" FORCE)
#[[ Switched from using:
include(FetchContent)
FetchContent_Declare(
stdexec
GIT_REPOSITORY https://github.com/NVIDIA/stdexec.git
GIT_TAG main
GIT_SHALLOW TRUE
)
set(STDEXEC_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(stdexec)
#]]
endfunction()
This oneliner reproduces the issue:
docker run ubuntu:24.04 bash -c 'apt update ; apt install -y cmake git g++ ; mkdir repro ; cd repro ; git clone https://github.com/NVIDIA/stdexec.git ; git -C stdexec checkout bfc2610b2e92e467174f83fc9c573cfb3dec1196 ; echo -e "cmake_minimum_required(VERSION 3.25)\nproject(repro CXX)\ninclude(CTest)\nadd_subdirectory(stdexec)" > CMakeLists.txt ; mkdir build ; cd build ; cmake ..'
My pull request here attempts to resolve it: #1380