diff --git a/CMakeLists.txt b/CMakeLists.txt index 69ea6a8..f2cfa35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,18 +2,10 @@ # 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.3) +cmake_minimum_required(VERSION 3.8) project(cppast VERSION 0.0) # options -if(CMAKE_BUILD_TYPE MATCHES Debug) - set(default_assertions ON) -else() - set(default_assertions OFF) -endif() -option(CPPAST_ENABLE_ASSERTIONS "whether or not to enable internal assertions for the cppast library" ${default_assertions}) -option(CPPAST_ENABLE_PRECONDITION_CHECKS "whether or not to enable precondition checks" ON) - option(CPPAST_BUILD_TEST "whether or not to build the tests" OFF) option(CPPAST_BUILD_EXAMPLE "whether or not to build the examples" OFF) option(CPPAST_BUILD_TOOL "whether or not to build the tool" OFF) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 549873a..ff1d2b8 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -5,7 +5,6 @@ function(_cppast_example name) add_executable(cppast_example_${name} ${name}.cpp example_parser.hpp) target_link_libraries(cppast_example_${name} PUBLIC cppast) - set_target_properties(cppast_example_${name} PROPERTIES CXX_STANDARD 11) endfunction() _cppast_example(ast_printer) diff --git a/include/cppast/detail/assert.hpp b/include/cppast/detail/assert.hpp index fee744c..89f5ebb 100644 --- a/include/cppast/detail/assert.hpp +++ b/include/cppast/detail/assert.hpp @@ -7,16 +7,16 @@ #include -#ifdef CPPAST_ENABLE_ASSERTIONS -# define CPPAST_ASSERTION_LEVEL 1 -#else +#ifndef CPPAST_ASSERTION_LEVEL # define CPPAST_ASSERTION_LEVEL 0 #endif -#ifdef CPPAST_ENABLE_PRECONDITION_CHECKS -# define CPPAST_PRECONDITION_LEVEL 1 -#else -# define CPPAST_PRECONDITION_LEVEL 0 +#ifndef CPPAST_PRECONDITION_LEVEL +# ifdef NDEBUG +# define CPPAST_PRECONDITION_LEVEL 0 +# else +# define CPPAST_PRECONDITION_LEVEL 1 +# endif #endif namespace cppast diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe00494..0a7c85e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,16 +102,17 @@ set(libclang_source libclang/variable_parser.cpp) add_library(cppast ${detail_header} ${header} ${source} ${libclang_source}) -set_target_properties(cppast PROPERTIES CXX_STANDARD 11) -target_include_directories(cppast PUBLIC ../include) +target_compile_features(cppast PUBLIC cxx_std_11) +target_include_directories(cppast PRIVATE ../include SYSTEM INTERFACE ../include) target_link_libraries(cppast PUBLIC type_safe _cppast_tiny_process _cppast_libclang) target_compile_definitions(cppast PUBLIC CPPAST_VERSION_MINOR="${cppast_VERSION_MINOR}" CPPAST_VERSION_MAJOR="${cppast_VERSION_MAJOR}" CPPAST_VERSION_STRING="${cppast_VERSION}") -if(CPPAST_ENABLE_ASSERTIONS) - target_compile_definitions(cppast PUBLIC CPPAST_ENABLE_ASSERTIONS) -endif() -if(CPPAST_ENABLE_PRECONDITION_CHECKS) - target_compile_definitions(cppast PUBLIC CPPAST_ENABLE_PRECONDITION_CHECKS) -endif() +target_compile_options(cppast PRIVATE + # clang/GCC warnings + $<$,$>: + -pedantic-errors -Werror -Wall -Wextra -Wconversion -Wsign-conversion> + # MSVC warnings + $<$: + /WX /W4>) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 03d9b6b..f9cad06 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -47,9 +47,9 @@ 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" CPPAST_COMPILE_COMMANDS="${CMAKE_BINARY_DIR}") -set_target_properties(cppast_test PROPERTIES CXX_STANDARD 11) -add_test(NAME test COMMAND cppast_test) +add_test(NAME unit_test COMMAND cppast_test "~[integration]") +add_test(NAME integration_test COMMAND cppast_test "[integration]") if(CPPAST_TEST_GCOV AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")) setup_target_for_coverage(