# Copyright (C) 2024 T. Zachary Laine # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) # Generated by `boostdep --cmake parser` cmake_minimum_required(VERSION 3.14...3.20) project(boost_parser VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) add_library(boost_parser INTERFACE) add_library(Boost::parser ALIAS boost_parser) target_include_directories(boost_parser INTERFACE include) target_link_libraries(boost_parser INTERFACE Boost::assert Boost::hana Boost::type_index ) else() cmake_minimum_required(VERSION 3.14...3.20) project(parse) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) ################################################## # C++ standard version selection ################################################## set(CXX_STD 17 CACHE STRING "Set to 14, 17, etc., to enable C++14, C++17, etc.") message("-- Using -std=c++${CXX_STD}") # to just check the different frontend flavours we could use the following code if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") get_filename_component(CNAME "${CMAKE_CXX_COMPILER}" NAME) message(STATUS "Detected MSVC style compiler frontend '" ${CNAME} "'") add_definitions(/W3) add_compile_options(/Zc:__cplusplus) # not sure, if it necessary for clang-cl elseif (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") get_filename_component(CNAME "${CMAKE_CXX_COMPILER}" NAME) message(STATUS "Detected GNU style compiler frontend '" ${CNAME} "'") add_definitions(-Wall) endif () # alternatively the boolean variable 'MSVC' is equivalent to 'if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")' # summary for a more detailed analysis (https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html#variables-that-provide-information): # CMAKE_CXX_COMPILER_ID: Clang, GNU, MSVC # CMAKE_CXX_COMPILER_FRONTEND_VARIANT: GNU, MSVC # CMAKE_CXX_SIMULATE_ID: MSVC (for Microsoft clang and clang-cl as they use the MSVC runtime) # CMAKE_CXX_PLATFORM_ID: Windows, Darwin, MinGW, MSYS, Linux, UNIX, ... # Variables that describe the system (https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html#variables-that-describe-the-system) ################################################## # Build config ################################################## set(BUILD_WITH_HANA false CACHE BOOL "Build with optional Hana support (and BOOST_PARSER_USE_HANA_TUPLE defined).") if (BUILD_WITH_HANA) add_definitions(-DBOOST_PARSER_USE_HANA_TUPLE) endif() ################################################## # Dependencies ################################################## include(dependencies) ################################################## # Sanitizers ################################################## set(USE_ASAN false CACHE BOOL "Set to true to enable -fsanitize=address when building tests.") set(USE_UBSAN false CACHE BOOL "Set to true to enable -fsanitize=undefined when building tests.") if (USE_ASAN AND USE_UBSAN) message(FATAL_ERROR "USE_ASAN and USE_UBSAN must not be enabled at the same time") elseif (USE_ASAN) set(compile_flags -fsanitize=address) set(link_flags -fsanitize=address) elseif (USE_UBSAN) set(compile_flags -fsanitize=undefined) set(link_flags -fsanitize=undefined) endif() ################################################## # Parser ################################################## add_library(parser INTERFACE) target_include_directories(parser INTERFACE ${CMAKE_SOURCE_DIR}/include) if (Boost_FOUND) target_include_directories(parser INTERFACE ${Boost_INCLUDE_DIRS}) endif() ################################################## # Subdirectories ################################################## add_subdirectory(test) add_subdirectory(example) endif()