Improve CMake
This commit is contained in:
parent
a98cbc8518
commit
d44571f1c8
5 changed files with 19 additions and 27 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@
|
|||
|
||||
#include <debug_assert.hpp>
|
||||
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-pedantic-errors -Werror -Wall -Wextra -Wconversion -Wsign-conversion>
|
||||
# MSVC warnings
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/WX /W4>)
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue