Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring CMake fails #1371

Open
stephenberry opened this issue Jul 10, 2024 · 4 comments
Open

Configuring CMake fails #1371

stephenberry opened this issue Jul 10, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@stephenberry
Copy link

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.

@ericniebler
Copy link
Collaborator

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.

@ericniebler ericniebler added the bug Something isn't working label Jul 11, 2024
@wsberry
Copy link

wsberry commented Jul 11, 2024

I am finding the bug to be intermittent. Two observations when this error occurs:

  1. the catch repo was not included in the CMAKE_BINARY_DIR/_deps folder (it was not downloaded)
  2. the path error indicates contrib/Catch.cmake when it should be something line ${CMAKE_BINARY_DIR}/_deps/catch2-src/contrib/Catch.cmake

@wsberry
Copy link

wsberry commented Jul 11, 2024

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()

@ednolan
Copy link
Contributor

ednolan commented Jul 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants