diff --git a/CMakeLists.txt b/CMakeLists.txt index 166e5a2..67a0382 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ option(BUILD_TESTING "build test" OFF) # The ctest variable for building tests if(${CPPAST_BUILD_TEST} OR ${BUILD_TESTING} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)) set(build_test ON) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # for the self integration test else() set(build_test OFF) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b83bf1e..fe00494 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,7 +15,6 @@ set(header ../include/cppast/cpp_class_template.hpp ../include/cppast/cpp_decltype_type.hpp ../include/cppast/cpp_entity.hpp - ../include/cppast/cpp_entity.hpp ../include/cppast/cpp_entity_container.hpp ../include/cppast/cpp_entity_index.hpp ../include/cppast/cpp_entity_kind.hpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0475d8d..f4ed9a8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -34,10 +34,18 @@ set(tests preprocessor.cpp visitor.cpp) +# generate list of source files for the self parsing test +get_target_property(files cppast SOURCES) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cppast_files.hpp "// list of cppast source file includes\n") +foreach(file ${files}) + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/cppast_files.hpp "\"${CMAKE_CURRENT_SOURCE_DIR}/../src/${file}\",\n") +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_compile_definitions(cppast_test PUBLIC CPPAST_INTEGRATION_FILE="${CMAKE_CURRENT_SOURCE_DIR}/integration.cpp") set_target_properties(cppast_test PROPERTIES CXX_STANDARD 11) enable_testing() diff --git a/test/integration.cpp b/test/integration.cpp index f20f091..b95a8ce 100644 --- a/test/integration.cpp +++ b/test/integration.cpp @@ -113,3 +113,19 @@ TEST_CASE("stdlib", "[!hide][integration]") resolve_includes(parser, file.value(), config); REQUIRE(!parser.error()); } + +TEST_CASE("cppast", "[!hide][integration]") +{ + const char* files[] = { +#include + }; + + cpp_entity_index idx; + simple_file_parser parser(type_safe::ref(idx), default_logger()); + + libclang_compilation_database database("../"); + libclang_compile_config config(database, CPPAST_INTEGRATION_FILE); + parse_files(parser, files, config); + + REQUIRE(!parser.error()); +}