2019-11-21 16:52:31 +00:00
|
|
|
cmake_minimum_required(VERSION 3.1.0)
|
|
|
|
project("cpp-peglib")
|
|
|
|
|
|
|
|
# Check if a supported compiler is used to setup the C++ standard to use:
|
|
|
|
get_property(known_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
|
|
|
|
list(FIND known_features "cxx_std_17" found)
|
|
|
|
if(NOT ${found} EQUAL -1)
|
|
|
|
# C++17 standard is supported
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
else()
|
|
|
|
# Check for C++11 standard support
|
|
|
|
list(FIND known_features "cxx_std_11" found)
|
|
|
|
if(NOT ${found} EQUAL -1)
|
|
|
|
# C++11 standard is supported
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
2016-06-09 02:17:07 +00:00
|
|
|
endif()
|
2019-11-21 16:52:31 +00:00
|
|
|
endif()
|
2016-06-01 10:30:26 +00:00
|
|
|
|
2019-11-21 16:52:31 +00:00
|
|
|
if(${found} EQUAL -1)
|
|
|
|
message(FATAL_ERROR "Your compiler is not supported.")
|
2016-06-01 10:30:26 +00:00
|
|
|
endif()
|
|
|
|
|
2019-11-21 16:52:31 +00:00
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
2016-06-01 10:30:26 +00:00
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
|
|
|
|
OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
|
|
|
set(warning_options -Weverything
|
|
|
|
-Wno-c++98-compat
|
|
|
|
-Wno-padded
|
|
|
|
-Wno-c++98-compat-pedantic
|
|
|
|
-Wno-exit-time-destructors
|
|
|
|
-Wno-missing-prototypes
|
|
|
|
-Wno-weak-vtables
|
|
|
|
-Wno-global-constructors
|
|
|
|
-Wno-format-nonliteral
|
|
|
|
-Wno-switch-enum
|
|
|
|
-Wno-missing-noreturn
|
|
|
|
-Wno-covered-switch-default
|
2020-01-25 00:58:43 +00:00
|
|
|
-Wno-c++2a-compat
|
2016-06-01 10:30:26 +00:00
|
|
|
)
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set(warning_options -Wall -Wpedantic -Wextra)
|
2016-06-07 08:50:47 +00:00
|
|
|
elseif(MSVC)
|
2016-06-07 07:54:02 +00:00
|
|
|
set(warning_options /W4 /wd4503 /wd4512)
|
2016-06-01 10:30:26 +00:00
|
|
|
endif()
|
|
|
|
|
2016-06-07 08:29:45 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
set(add_link_deps pthread)
|
|
|
|
endif()
|
|
|
|
|
2016-06-07 08:50:47 +00:00
|
|
|
if(MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
|
|
|
|
endif()
|
|
|
|
|
2016-05-29 21:13:39 +00:00
|
|
|
enable_testing()
|
|
|
|
|
2015-11-30 22:26:06 +00:00
|
|
|
add_subdirectory(test)
|
|
|
|
add_subdirectory(example)
|
2020-01-23 23:29:13 +00:00
|
|
|
add_subdirectory(lint)
|
2020-01-25 03:54:03 +00:00
|
|
|
|
2020-01-25 04:35:25 +00:00
|
|
|
# find_package(LLVM CONFIG)
|
|
|
|
# if(LLVM_FOUND)
|
|
|
|
# add_subdirectory(pl0)
|
|
|
|
# endif()
|