2
0
mirror of https://github.com/boostorg/parser.git synced 2026-02-02 21:12:13 +00:00
Files
parser/CMakeLists.txt
2018-09-24 06:48:48 -05:00

106 lines
2.9 KiB
CMake

cmake_minimum_required(VERSION 3.5)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(cxx_defs)
set(std_flag)
set(clang_on_linux false)
if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(std_flag -std=c++11)
add_definitions(-g -Wall)
set(cxx_defs
${std_flag}
-stdlib=libc++
-Wno-parentheses
-ftemplate-depth-300
)
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
set(clang_on_linux true)
endif ()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
set(std_flag -std=c++11)
add_definitions(-g -Wall)
set(cxx_defs ${std_flag} -ftemplate-depth-300 -Wno-parentheses)
endif ()
include(dependencies)
find_package(PythonInterp)
if (PYTHONINTERP_FOUND)
message("-- Found Python ${PYTHON_VERSION_STRING} (${PYTHON_EXECUTABLE})")
endif ()
##################################################
# 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(link_flags -fsanitize=address)
elseif (USE_UBSAN)
set(link_flags -fsanitize=undefined)
endif()
# TODO: Turn this on if a static lib is desired; there's no need for it now.
if (false)
##################################################
# Static lib
##################################################
add_library(
yaml-static
STATIC
src/characters.cpp
src/basic_structures.cpp
src/flow_style.cpp
src/block_style.cpp
src/stream.cpp
)
target_compile_options(yaml-static PUBLIC ${cxx_defs})
target_include_directories(yaml-static PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(yaml-static PUBLIC boost)
target_link_libraries(yaml-static ${link_flags})
if (USE_ASAN OR USE_UBSAN)
target_compile_options(yaml-static PUBLIC ${link_flags})
endif()
if (clang_on_linux)
target_link_libraries(yaml-static c++)
endif ()
endif ()
##################################################
# Dynamic lib
##################################################
add_library(
yaml
SHARED
src/characters.cpp
src/basic_structures.cpp
src/flow_style.cpp
src/block_style.cpp
src/stream.cpp
)
target_compile_options(yaml PUBLIC ${cxx_defs})
target_include_directories(yaml PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(yaml PUBLIC boost)
target_link_libraries(yaml ${link_flags})
if (USE_ASAN OR USE_UBSAN)
target_compile_options(yam PUBLIC ${link_flags})
endif()
if (clang_on_linux)
target_link_libraries(yaml c++)
endif ()
add_subdirectory(test)
add_subdirectory(perf)
set(BUILD_COMPARE_LIBYAML false CACHE BOOL "Set to true to build correctness and perf tests for libyaml.")
if (BUILD_COMPARE_LIBYAML)
add_subdirectory(compare_libyaml)
endif ()