I create 2 small cmake projects on VS.
- 1st project : MyCatch2installer – goal to install Catch2 independently
of other C++ project. - 2nd project: CMakeProject1 – goal to test
access to Catch at the CMake level
`
<code> #################################
#1st Project
project ("MyCatch2Installer")
# Source: https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md
set(CATCH2_VERSION 3.7.0)
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v${CATCH2_VERSION}
)
FetchContent_MakeAvailable(Catch2)
#################################
#2nd Project
project ("CMakeTestProject1")
list(APPEND CMAKE_PREFIX_PATH "C:/temp/MyCatch2Installer/out/build/x64-debug")
find_package(Catch2 REQUIRED)
#################################
</code>
<code> #################################
#1st Project
project ("MyCatch2Installer")
# Source: https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md
set(CATCH2_VERSION 3.7.0)
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v${CATCH2_VERSION}
)
FetchContent_MakeAvailable(Catch2)
#################################
#2nd Project
project ("CMakeTestProject1")
list(APPEND CMAKE_PREFIX_PATH "C:/temp/MyCatch2Installer/out/build/x64-debug")
find_package(Catch2 REQUIRED)
#################################
</code>
#################################
#1st Project
project ("MyCatch2Installer")
# Source: https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md
set(CATCH2_VERSION 3.7.0)
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v${CATCH2_VERSION}
)
FetchContent_MakeAvailable(Catch2)
#################################
#2nd Project
project ("CMakeTestProject1")
list(APPEND CMAKE_PREFIX_PATH "C:/temp/MyCatch2Installer/out/build/x64-debug")
find_package(Catch2 REQUIRED)
#################################
`
Part of the error message on find_package is :
Could not find a package configuration file provided by “Catch2” with
any of the following names:<code>Catch2Config.cmakecatch2-config.cmake</code><code>Catch2Config.cmake catch2-config.cmake </code>Catch2Config.cmake catch2-config.cmake
And after having checked, they have not be installed by the “MyCatch2Installer” Cmakelist.
At the execution of MyCatch2Installer i read the console message:
1> [CMake] — Build files have been written to: C:/temp/MyCatch2Installer/out/build/x64-debug
Last thing : i am using VisualStudioVersion=17.0