2023-07-25 18:09:52 +00:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2017-04-19 13:47:40 +00:00
|
|
|
enable_testing()
|
2019-06-14 15:24:21 +00:00
|
|
|
|
2024-01-07 09:06:50 +00:00
|
|
|
project(toml11 VERSION 3.8.1)
|
2019-06-14 15:24:21 +00:00
|
|
|
|
2020-09-14 17:25:38 +00:00
|
|
|
option(toml11_BUILD_TEST "Build toml tests" OFF)
|
2022-03-04 02:55:55 +00:00
|
|
|
option(toml11_INSTALL "Install CMake targets during install step." ON)
|
2020-01-08 14:07:05 +00:00
|
|
|
option(toml11_TEST_WITH_ASAN "use LLVM address sanitizer" OFF)
|
|
|
|
option(toml11_TEST_WITH_UBSAN "use LLVM undefined behavior sanitizer" OFF)
|
2019-06-14 15:24:21 +00:00
|
|
|
|
2022-03-16 13:40:42 +00:00
|
|
|
option(TOML11_USE_UNRELEASED_TOML_FEATURES
|
|
|
|
"use features in toml-lang/toml master while testing" OFF)
|
|
|
|
|
2020-09-16 13:16:40 +00:00
|
|
|
if(MSVC)
|
2021-12-18 05:23:58 +00:00
|
|
|
# add_definitions("/Zc:__cplusplus") # define __cplusplus value correctly
|
2021-04-02 06:39:23 +00:00
|
|
|
add_definitions("/utf-8") # enable to use u8"" literal
|
2021-04-02 08:21:25 +00:00
|
|
|
if(MSVC_VERSION LESS 1910)
|
2021-04-02 09:24:17 +00:00
|
|
|
message(STATUS "MSVC < 1910. DEFINE_CONVERSION_NON_INTRUSIVE is disabled")
|
2021-04-02 08:21:25 +00:00
|
|
|
add_definitions(-DTOML11_WITHOUT_DEFINE_NON_INTRUSIVE)
|
|
|
|
elseif(MSVC_VERSION LESS 1920)
|
|
|
|
add_definitions("/experimental:preprocessor") # MSVC 2017
|
|
|
|
else()
|
|
|
|
add_definitions("/Zc:preprocessor") # MSVC 2019
|
|
|
|
endif()
|
2020-09-16 13:16:40 +00:00
|
|
|
endif()
|
|
|
|
|
2019-06-14 15:24:21 +00:00
|
|
|
# Set some common directories
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
set(toml11_install_cmake_dir ${CMAKE_INSTALL_LIBDIR}/cmake/toml11)
|
|
|
|
set(toml11_install_include_dir ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
set(toml11_config_dir ${CMAKE_CURRENT_BINARY_DIR}/cmake/)
|
|
|
|
set(toml11_config ${toml11_config_dir}/toml11Config.cmake)
|
|
|
|
set(toml11_config_version ${toml11_config_dir}/toml11ConfigVersion.cmake)
|
|
|
|
|
|
|
|
add_library(toml11 INTERFACE)
|
2019-06-19 07:53:45 +00:00
|
|
|
target_include_directories(toml11 INTERFACE
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
|
|
|
$<INSTALL_INTERFACE:${toml11_install_include_dir}>
|
2019-06-14 15:24:21 +00:00
|
|
|
)
|
|
|
|
add_library(toml11::toml11 ALIAS toml11)
|
|
|
|
|
|
|
|
# Write config and version config files
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
write_basic_package_version_file(
|
2019-06-19 07:53:45 +00:00
|
|
|
${toml11_config_version}
|
|
|
|
VERSION ${toml11_VERSION}
|
|
|
|
COMPATIBILITY SameMajorVersion
|
2019-06-14 15:24:21 +00:00
|
|
|
)
|
|
|
|
|
2022-03-04 02:55:55 +00:00
|
|
|
if (toml11_INSTALL)
|
|
|
|
configure_package_config_file(
|
|
|
|
cmake/toml11Config.cmake.in
|
|
|
|
${toml11_config}
|
|
|
|
INSTALL_DESTINATION ${toml11_install_cmake_dir}
|
|
|
|
PATH_VARS toml11_install_cmake_dir
|
|
|
|
)
|
2019-06-14 15:24:21 +00:00
|
|
|
|
2022-03-04 02:55:55 +00:00
|
|
|
# Install config files
|
|
|
|
install(FILES ${toml11_config} ${toml11_config_version}
|
|
|
|
DESTINATION ${toml11_install_cmake_dir}
|
|
|
|
)
|
2019-06-14 15:24:21 +00:00
|
|
|
|
2022-03-04 02:55:55 +00:00
|
|
|
# Install header files
|
|
|
|
install(
|
|
|
|
FILES toml.hpp
|
|
|
|
DESTINATION "${toml11_install_include_dir}"
|
|
|
|
)
|
|
|
|
install(
|
|
|
|
DIRECTORY "toml"
|
|
|
|
DESTINATION "${toml11_install_include_dir}"
|
|
|
|
FILES_MATCHING PATTERN "*.hpp"
|
|
|
|
)
|
2019-06-14 15:24:21 +00:00
|
|
|
|
2022-03-04 02:55:55 +00:00
|
|
|
# Export targets and install them
|
|
|
|
install(TARGETS toml11
|
|
|
|
EXPORT toml11Targets
|
|
|
|
)
|
|
|
|
install(EXPORT toml11Targets
|
|
|
|
FILE toml11Targets.cmake
|
|
|
|
DESTINATION ${toml11_install_cmake_dir}
|
|
|
|
NAMESPACE toml11::
|
|
|
|
)
|
|
|
|
endif()
|
2019-06-14 15:24:21 +00:00
|
|
|
|
|
|
|
if (toml11_BUILD_TEST)
|
2019-06-19 07:53:45 +00:00
|
|
|
add_subdirectory(tests)
|
2019-06-17 08:04:39 +00:00
|
|
|
endif ()
|