Use external Catch2 if available in cmake build (#600)

This commit is contained in:
Alexey Sokolov 2023-03-25 17:29:08 +00:00 committed by GitHub
parent b0ed8b7a3c
commit a015950eaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 11 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.1)
project(RecastNavigation) project(RecastNavigation)

View File

@ -213,7 +213,7 @@ project "Tests"
"../Recast/Source", "../Recast/Source",
"../Tests/Recast", "../Tests/Recast",
"../Tests", "../Tests",
"../Tests/Contrib/Catch" "../Tests/Contrib"
} }
files { files {
"../Tests/*.h", "../Tests/*.h",
@ -223,7 +223,7 @@ project "Tests"
"../Tests/Recast/*.cpp", "../Tests/Recast/*.cpp",
"../Tests/Detour/*.h", "../Tests/Detour/*.h",
"../Tests/Detour/*.cpp", "../Tests/Detour/*.cpp",
"../Tests/Contrib/Catch/*.cpp" "../Tests/Contrib/catch2/*.cpp"
} }
-- project dependencies -- project dependencies

View File

@ -1,9 +1,7 @@
file(GLOB TESTS_SOURCES *.cpp Detour/*.cpp Recast/*.cpp Contrib/Catch/*.cpp) file(GLOB TESTS_SOURCES Detour/*.cpp Recast/*.cpp)
include_directories(../Detour/Include) include_directories(../Detour/Include)
include_directories(../Recast/Include) include_directories(../Recast/Include)
include_directories(./Contrib/Catch)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(Tests ${TESTS_SOURCES}) add_executable(Tests ${TESTS_SOURCES})
@ -11,4 +9,13 @@ set_property(TARGET Tests PROPERTY CXX_STANDARD 17)
add_dependencies(Tests Recast Detour) add_dependencies(Tests Recast Detour)
target_link_libraries(Tests Recast Detour) target_link_libraries(Tests Recast Detour)
find_package(Catch2 QUIET)
if (Catch2_FOUND)
target_link_libraries(Tests Catch2::Catch2WithMain)
else()
include_directories(./Contrib)
target_sources(Tests PRIVATE Contrib/catch2/catch_amalgamated.cpp)
endif()
add_test(Tests Tests) add_test(Tests Tests)

View File

@ -12,7 +12,7 @@
// You probably shouldn't edit it directly. // You probably shouldn't edit it directly.
// ---------------------------------------------------------- // ----------------------------------------------------------
#include "catch_amalgamated.hpp" #include "catch_all.hpp"
#ifndef CATCH_WINDOWS_H_PROXY_HPP_INCLUDED #ifndef CATCH_WINDOWS_H_PROXY_HPP_INCLUDED

View File

@ -1,4 +1,4 @@
#include "catch_amalgamated.hpp" #include "catch2/catch_all.hpp"
#include "DetourCommon.h" #include "DetourCommon.h"

View File

@ -1,7 +1,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "catch_amalgamated.hpp" #include "catch2/catch_all.hpp"
#include "Recast.h" #include "Recast.h"
#include "RecastAlloc.h" #include "RecastAlloc.h"

View File

@ -1,2 +0,0 @@
#define CATCH_CONFIG_MAIN
#include "catch_amalgamated.hpp"