Skip to content

Commit 9283ac3

Browse files
committed
Make cppast compile with modern toolset
Fixed the following: - updated the cmake_minimum_required() target version to 4.0 : 3.x deprecated - Upgraded external repos to use the latest from the 3d party libraries - Upgraded Catch2 tests to use the newer test infra - Removed obsolete [!hide] from the test descriptions - fixed a warning in "" operator overload.
1 parent 5329e37 commit 9283ac3

14 files changed

Lines changed: 21 additions & 22 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: MIT
33
# found in the top-level directory of this distribution.
44

5-
cmake_minimum_required(VERSION 3.11)
5+
cmake_minimum_required(VERSION 4.0)
66
project(cppast VERSION 0.1.0)
77

88
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)

external/external.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if(build_tool)
3131
set(CXXOPTS_BUILD_TESTS OFF CACHE BOOL "")
3232

3333
message(STATUS "Fetching cxxopts")
34-
FetchContent_Declare(cxxopts URL https://github.com/jarro2783/cxxopts/archive/v2.2.1.zip)
34+
FetchContent_Declare(cxxopts GIT_REPOSITORY https://github.com/jarro2783/cxxopts GIT_TAG origin/master)
3535
FetchContent_MakeAvailable(cxxopts)
3636
endif()
3737

external/tpl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.1)
1+
cmake_minimum_required(VERSION 4.0)
22

33
project(tiny-process-library)
44

include/cppast/cpp_entity_index.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct cpp_entity_id : type_safe::strong_typedef<cpp_entity_id, detail::hash_typ
4646
inline namespace literals
4747
{
4848
/// \returns A new [cppast::cpp_entity_id]() created from the given string.
49-
inline cpp_entity_id operator"" _id(const char* str, std::size_t)
49+
inline cpp_entity_id operator""_id(const char* str, std::size_t)
5050
{
5151
return cpp_entity_id(str);
5252
}

test/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Fetch catch.
66
message(STATUS "Fetching catch")
77
include(FetchContent)
8-
FetchContent_Declare(catch URL https://github.com/catchorg/Catch2/archive/refs/tags/v2.13.9.zip)
8+
FetchContent_Declare(catch GIT_REPOSITORY https://github.com/catchorg/Catch2 GIT_TAG devel)
99
FetchContent_MakeAvailable(catch)
1010

1111
set(tests
@@ -42,9 +42,9 @@ foreach(file ${files})
4242
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/cppast_files.hpp "\"${CMAKE_CURRENT_SOURCE_DIR}/../src/${file}\",\n")
4343
endforeach()
4444

45-
add_executable(cppast_test test.cpp test_parser.hpp ${tests})
45+
add_executable(cppast_test test_parser.hpp ${tests})
4646
target_include_directories(cppast_test PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../src ${CMAKE_CURRENT_BINARY_DIR})
47-
target_link_libraries(cppast_test PUBLIC cppast Catch2)
47+
target_link_libraries(cppast_test PUBLIC cppast Catch2::Catch2WithMain)
4848
target_compile_definitions(cppast_test PUBLIC CPPAST_INTEGRATION_FILE="${CMAKE_CURRENT_SOURCE_DIR}/integration.cpp"
4949
CPPAST_COMPILE_COMMANDS="${CMAKE_BINARY_DIR}")
5050

test/cpp_friend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
using namespace cppast;
1616

17-
TEST_CASE("cpp_friend", "[!hide][clang4]")
17+
TEST_CASE("cpp_friend", "[.][clang4]")
1818
{
1919
auto code = R"(
2020
/// b

test/cpp_preprocessor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ TEST_CASE("command line macro definition")
119119
REQUIRE(!logger.error);
120120
}
121121

122+
static bool endsWith( std::string const& s, std::string const& suffix ) {
123+
return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin());
124+
}
125+
122126
TEST_CASE("cpp_include_directive")
123127
{
124128
write_file("cpp_include_directive-header.hpp", R"(
@@ -149,7 +153,7 @@ b
149153
REQUIRE(include.target().name() == include.name());
150154
REQUIRE(include.include_kind() == cppast::cpp_include_kind::system);
151155
REQUIRE(include.target().get(idx).empty());
152-
REQUIRE_THAT(include.full_path(), Catch::EndsWith("iostream"));
156+
REQUIRE(endsWith(include.full_path(), std::string("iostream")));
153157
}
154158
else if (include.name() == "cpp_include_directive-header.hpp")
155159
{

test/cpp_token.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <cppast/cpp_token.hpp>
55

6-
#include <catch2/catch.hpp>
6+
#include <catch2/catch_test_macros.hpp>
77

88
#include <algorithm>
99
#include <initializer_list>

test/integration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
using namespace cppast;
99

10-
TEST_CASE("stdlib", "[!hide][integration]")
10+
TEST_CASE("stdlib", "[.][integration]")
1111
{
1212
auto code = R"(
1313
// list of headers from: http://en.cppreference.com/w/cpp/header
@@ -113,7 +113,7 @@ TEST_CASE("stdlib", "[!hide][integration]")
113113
REQUIRE(!parser.error());
114114
}
115115

116-
TEST_CASE("cppast", "[!hide][integration]")
116+
TEST_CASE("cppast", "[integration]")
117117
{
118118
const char* files[] = {
119119
#include <cppast_files.hpp>

test/libclang_parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (C) 2017-2023 Jonathan Müller and cppast contributors
22
// SPDX-License-Identifier: MIT
33

4-
#include <catch2/catch.hpp>
4+
#include <catch2/catch_test_macros.hpp>
55

66
#include <cppast/libclang_parser.hpp>
77

0 commit comments

Comments
 (0)