CMakePP / CMakeTest

A unit-testing framework for CMake functions
https://cmakepp.github.io/CMakeTest/
Apache License 2.0
10 stars 6 forks source link

[BUG] CMakePPLang include error on project using CMakeTest #105

Closed zachcran closed 2 months ago

zachcran commented 2 months ago

Describe the bug When attempting to configure a CMake project that uses CMakeTest, an error about include could not find fine requested file: cmakepp_lang/cmakepp_lang occurs. The full error is contained in this file.

CMakePPLang seems to be found and usable up until the point that the context returns to the top-level CMakeLists.txt file after finding and including CMakeTest. Then, calling include(cmake_test/cmake_test) results in the inclusion errors.

To Reproduce Steps to reproduce the behavior:

  1. Create a new CMake project directory with a CMakeLists.txt file that has the basics to fetch and include CMakeTest:
    
    cmake_minimum_required(VERSION 3.19)

project(test_project)

macro(get_cmake_test) include(cmake_test/cmake_test OPTIONAL RESULT_VARIABLE cmake_test_found) if(NOT cmake_test_found)

Store whether we are building tests or not, then turn off the tests

    set(build_testing_old "${BUILD_TESTING}")
    set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
    # Download CMakeTest and bring it into scope
    include(FetchContent)
    FetchContent_Declare(
         cmake_test
         GIT_REPOSITORY https://github.com/CMakePP/CMakeTest
   )
   FetchContent_MakeAvailable(cmake_test)

   # Restore the previous value
   set(BUILD_TESTING "${build_testing_old}" CACHE BOOL "" FORCE)
endif()

endmacro()

Call the function we just wrote to get CMakeTest

get_cmake_test()

Include CMakeTest

include(cmake_test/cmake_test)


2. Attempt to configure this project with `cmake -B build -S .`.
3. The error mentioned above should occur during configuration.

**Expected behavior**
There should not be an error and `cmakepp_lang/cmakepp_lang` should be found correctly since it is found and included in CMakeTest.

**Additional context**
This was also briefly discussed in #101 in the comments after the issue was resolved.
yobeonline commented 2 months ago

Thank you for writing this issue. I did not have a chance to before today.