Use catch via FetchContent

Fixes #111 and #112.
This commit is contained in:
Jonathan Müller 2021-02-17 13:37:14 +01:00
commit 39ba4f5de2
9 changed files with 15 additions and 15 deletions

View file

@ -2,7 +2,7 @@
# This file is subject to the license terms in the LICENSE file
# found in the top-level directory of this distribution.
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.11)
project(cppast VERSION 0.0)
# options

View file

@ -46,6 +46,7 @@ if(build_tool)
execute_process(COMMAND git submodule update --init -- external/cxxopts
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(CXXOPTS_BUILD_TESTS OFF)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/cxxopts EXCLUDE_FROM_ALL)
endif()

View file

@ -2,11 +2,11 @@
# This file is subject to the license terms in the LICENSE file
# found in the top-level directory of this distribution.
# download catch
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/catch.hpp)
file(DOWNLOAD https://raw.githubusercontent.com/catchorg/Catch2/v2.x/single_include/catch2/catch.hpp
${CMAKE_CURRENT_BINARY_DIR}/catch.hpp)
endif()
# Fetch catch.
message(STATUS "Fetching catch")
include(FetchContent)
FetchContent_Declare(catch URL https://github.com/catchorg/Catch2/archive/v2.13.4.zip)
FetchContent_MakeAvailable(catch)
set(tests
code_generator.cpp
@ -42,9 +42,8 @@ foreach(file ${files})
endforeach()
add_executable(cppast_test test.cpp test_parser.hpp ${tests})
target_include_directories(cppast_test PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(cppast_test PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../src)
target_link_libraries(cppast_test PUBLIC cppast)
target_include_directories(cppast_test PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../src ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(cppast_test PUBLIC cppast Catch2)
target_compile_definitions(cppast_test PUBLIC CPPAST_INTEGRATION_FILE="${CMAKE_CURRENT_SOURCE_DIR}/integration.cpp"
CPPAST_COMPILE_COMMANDS="${CMAKE_BINARY_DIR}")

View file

@ -4,7 +4,7 @@
#include <cppast/cpp_token.hpp>
#include <catch.hpp>
#include <catch2/catch.hpp>
#include <algorithm>
#include <initializer_list>

View file

@ -2,7 +2,7 @@
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
#include <catch.hpp>
#include <catch2/catch.hpp>
#include <cppast/libclang_parser.hpp>

View file

@ -4,7 +4,7 @@
#include <cppast/parser.hpp>
#include <catch.hpp>
#include <catch2/catch.hpp>
using namespace cppast;

View file

@ -1,4 +1,4 @@
#include <catch.hpp>
#include <catch2/catch.hpp>
#include <fstream>
#include "libclang/preprocessor.hpp"

View file

@ -3,4 +3,4 @@
// found in the top-level directory of this distribution.
#define CATCH_CONFIG_MAIN
#include <catch.hpp>
#include <catch2/catch.hpp>

View file

@ -7,7 +7,7 @@
#include <fstream>
#include <catch.hpp>
#include <catch2/catch.hpp>
#include <cppast/code_generator.hpp>
#include <cppast/cpp_class.hpp>