创建如下文件目录:
├───build/
├───src/
└───Sort.cpp
├───tests/
└───lib/
└───SortTest.cpp
└───CMakeLists.txt
├─── CMakeLists.txt
编辑根目录下的 CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
# project name and version
project(Example VERSION 1.0)
# add the executable
add_executable(Example src/Sort.cpp)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_subdirectory("tests")
在tests/lib目录下git clone Catch2 源码