I installed Catch2 on Windows, located in C:/Program Files (x86)/Catch2/
, but something went wrong when I use find_package
to use Catch2.
In detail, using this cmake file:
project(UnitTest)
cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 17)
find_package(Catch2)
And cmake failed with
CMake Warning at CMakeLists.txt:7 (find_package):
Could not find a configuration file for package "Catch2" that is compatible
with requested version "".
The following configuration files were considered but not accepted:
C:/Program Files (x86)/Catch2/lib/cmake/Catch2/Catch2Config.cmake, version: 3.3.2 (64bit)
I tried to use find_package(Catch2 3)
and find_package(Catch2 3.3.2)
but they all failed due to version dismatch.
I also tried find_package(Catch2 "3.3.2 (64bit)")
, but it failed due to invalid call to find_package
.
I wonder what's happening and how to fix this?
Catch2 is installed using something like this:
git clone git@github.com:catchorg/Catch2.git
cd Catch2
cmake -Bbuild . -DBUILD_TESTING=OFF
cmake --build build/ --config release --target install