summaryrefslogtreecommitdiff
path: root/tomlplusplus/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'tomlplusplus/cmake')
-rw-r--r--tomlplusplus/cmake/install-rules.cmake53
-rw-r--r--tomlplusplus/cmake/project-is-top-level.cmake6
-rw-r--r--tomlplusplus/cmake/tomlplusplusConfig.cmake1
-rw-r--r--tomlplusplus/cmake/tomlplusplusConfig.cmake.meson.in29
-rw-r--r--tomlplusplus/cmake/tomlplusplusConfigVersion.cmake.meson.in48
-rw-r--r--tomlplusplus/cmake/variables.cmake19
6 files changed, 156 insertions, 0 deletions
diff --git a/tomlplusplus/cmake/install-rules.cmake b/tomlplusplus/cmake/install-rules.cmake
new file mode 100644
index 0000000000..4f0e85d71e
--- /dev/null
+++ b/tomlplusplus/cmake/install-rules.cmake
@@ -0,0 +1,53 @@
+include(CMakePackageConfigHelpers)
+include(GNUInstallDirs)
+
+install(
+ FILES "${PROJECT_SOURCE_DIR}/toml++.natvis" "${PROJECT_SOURCE_DIR}/cpp.hint"
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/tomlplusplus"
+ COMPONENT tomlplusplus_Development
+)
+
+install(
+ DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ COMPONENT tomlplusplus_Development
+ FILES_MATCHING REGEX "^.*[.](h|hpp|inl)$"
+)
+
+install(
+ TARGETS tomlplusplus_tomlplusplus
+ EXPORT tomlplusplusTargets
+ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+)
+
+write_basic_package_version_file(
+ tomlplusplusConfigVersion.cmake
+ COMPATIBILITY SameMajorVersion
+ ARCH_INDEPENDENT
+)
+
+set(
+ tomlplusplus_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/tomlplusplus"
+ CACHE STRING "CMake package config location relative to the install prefix"
+)
+
+mark_as_advanced(tomlplusplus_INSTALL_CMAKEDIR)
+
+install(
+ FILES
+ "${PROJECT_SOURCE_DIR}/cmake/tomlplusplusConfig.cmake"
+ "${PROJECT_BINARY_DIR}/tomlplusplusConfigVersion.cmake"
+ DESTINATION "${tomlplusplus_INSTALL_CMAKEDIR}"
+ COMPONENT tomlplusplus_Development
+)
+
+install(
+ EXPORT tomlplusplusTargets
+ NAMESPACE tomlplusplus::
+ DESTINATION "${tomlplusplus_INSTALL_CMAKEDIR}"
+ COMPONENT tomlplusplus_Development
+)
+
+if(PROJECT_IS_TOP_LEVEL)
+ include(CPack)
+endif()
diff --git a/tomlplusplus/cmake/project-is-top-level.cmake b/tomlplusplus/cmake/project-is-top-level.cmake
new file mode 100644
index 0000000000..3435fc0e48
--- /dev/null
+++ b/tomlplusplus/cmake/project-is-top-level.cmake
@@ -0,0 +1,6 @@
+# This variable is set by project() in CMake 3.21+
+string(
+ COMPARE EQUAL
+ "${CMAKE_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}"
+ PROJECT_IS_TOP_LEVEL
+)
diff --git a/tomlplusplus/cmake/tomlplusplusConfig.cmake b/tomlplusplus/cmake/tomlplusplusConfig.cmake
new file mode 100644
index 0000000000..ec9f7a0007
--- /dev/null
+++ b/tomlplusplus/cmake/tomlplusplusConfig.cmake
@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/tomlplusplusTargets.cmake)
diff --git a/tomlplusplus/cmake/tomlplusplusConfig.cmake.meson.in b/tomlplusplus/cmake/tomlplusplusConfig.cmake.meson.in
new file mode 100644
index 0000000000..b007b6850c
--- /dev/null
+++ b/tomlplusplus/cmake/tomlplusplusConfig.cmake.meson.in
@@ -0,0 +1,29 @@
+@PACKAGE_INIT@
+
+# If tomlplusplus::tomlplusplus target is not defined it will be included
+if(NOT TARGET tomlplusplus::tomlplusplus)
+
+ if (@compile_library@)
+ set(imported_type UNKNOWN)
+ else()
+ set(imported_type INTERFACE)
+ endif()
+
+ # Import tomlplusplus interface library
+ add_library(tomlplusplus::tomlplusplus ${imported_type} IMPORTED)
+ set_target_properties(tomlplusplus::tomlplusplus PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/@includedir@")
+
+ # Require C++17
+ target_compile_features(tomlplusplus::tomlplusplus INTERFACE cxx_std_17)
+
+ # Set the path to the installed library so that users can link to it
+ if (@compile_library@)
+ set_target_properties(tomlplusplus::tomlplusplus PROPERTIES
+ IMPORTED_LOCATION "${PACKAGE_PREFIX_DIR}/@libdir@/@lib_name@"
+ )
+ # compile_options not quoted on purpose
+ target_compile_options(tomlplusplus::tomlplusplus INTERFACE @compile_options@)
+ endif()
+
+endif()
diff --git a/tomlplusplus/cmake/tomlplusplusConfigVersion.cmake.meson.in b/tomlplusplus/cmake/tomlplusplusConfigVersion.cmake.meson.in
new file mode 100644
index 0000000000..16b9749383
--- /dev/null
+++ b/tomlplusplus/cmake/tomlplusplusConfigVersion.cmake.meson.in
@@ -0,0 +1,48 @@
+# This is a basic version file for the Config-mode of find_package().
+# It is used by write_basic_package_version_file() as input file for configure_file()
+# to create a version-file which can be installed along a config.cmake file.
+#
+# The created file sets PACKAGE_VERSION_EXACT if the current version string and
+# the requested version string are exactly the same and it sets
+# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
+# The variable CVF_VERSION must be set before calling configure_file().
+
+set(PACKAGE_VERSION "@version@")
+
+if (PACKAGE_FIND_VERSION_RANGE)
+ # Package version must be in the requested version range
+ if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
+ OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ endif()
+else()
+ if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+ endif()
+endif()
+
+
+# if the installed project requested no architecture check, don't perform the check
+if("True")
+ return()
+endif()
+
+# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
+if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
+ return()
+endif()
+
+# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
+if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
+ math(EXPR installedBits "8 * 8")
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif()
diff --git a/tomlplusplus/cmake/variables.cmake b/tomlplusplus/cmake/variables.cmake
new file mode 100644
index 0000000000..7e379eb001
--- /dev/null
+++ b/tomlplusplus/cmake/variables.cmake
@@ -0,0 +1,19 @@
+# ---- Warning guard ----
+
+# target_include_directories with the SYSTEM modifier will request the compiler
+# to omit warnings from the provided paths, if the compiler supports that
+# This is to provide a user experience similar to find_package when
+# add_subdirectory or FetchContent is used to consume this project
+set(tomlplusplus_warning_guard "")
+option(tomlplusplus_INSTALL "Enable generation of tomlplusplus install targets" ${PROJECT_IS_TOP_LEVEL})
+if(NOT PROJECT_IS_TOP_LEVEL)
+ option(
+ tomlplusplus_INCLUDES_WITH_SYSTEM
+ "Use SYSTEM modifier for tomlplusplus's includes, disabling warnings"
+ ON
+ )
+ mark_as_advanced(tomlplusplus_INCLUDES_WITH_SYSTEM)
+ if(tomlplusplus_INCLUDES_WITH_SYSTEM)
+ set(tomlplusplus_warning_guard SYSTEM)
+ endif()
+endif()