diff --git a/CMakeLists.txt b/CMakeLists.txt index f2cfa35..b52906f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/external/external.cmake b/external/external.cmake index 4cff1f1..2da7599 100644 --- a/external/external.cmake +++ b/external/external.cmake @@ -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() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d83c504..a03f5cd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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}") diff --git a/test/cpp_token.cpp b/test/cpp_token.cpp index 547c40e..2c04428 100644 --- a/test/cpp_token.cpp +++ b/test/cpp_token.cpp @@ -4,7 +4,7 @@ #include -#include +#include #include #include diff --git a/test/libclang_parser.cpp b/test/libclang_parser.cpp index 4985402..0c35c4a 100644 --- a/test/libclang_parser.cpp +++ b/test/libclang_parser.cpp @@ -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 +#include #include diff --git a/test/parser.cpp b/test/parser.cpp index 9e8a783..39e3e63 100644 --- a/test/parser.cpp +++ b/test/parser.cpp @@ -4,7 +4,7 @@ #include -#include +#include using namespace cppast; diff --git a/test/preprocessor.cpp b/test/preprocessor.cpp index 40dab7e..df9a039 100644 --- a/test/preprocessor.cpp +++ b/test/preprocessor.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include "libclang/preprocessor.hpp" diff --git a/test/test.cpp b/test/test.cpp index 3260e0f..7c1202b 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -3,4 +3,4 @@ // found in the top-level directory of this distribution. #define CATCH_CONFIG_MAIN -#include +#include diff --git a/test/test_parser.hpp b/test/test_parser.hpp index e1bf289..5f36a30 100644 --- a/test/test_parser.hpp +++ b/test/test_parser.hpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include