summaryrefslogtreecommitdiffstats
path: root/src/fmt/support/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/fmt/support/cmake')
-rw-r--r--src/fmt/support/cmake/FindSetEnv.cmake7
-rw-r--r--src/fmt/support/cmake/JoinPaths.cmake26
-rw-r--r--src/fmt/support/cmake/cxx14.cmake70
-rw-r--r--src/fmt/support/cmake/fmt-config.cmake.in4
-rw-r--r--src/fmt/support/cmake/fmt.pc.in11
5 files changed, 118 insertions, 0 deletions
diff --git a/src/fmt/support/cmake/FindSetEnv.cmake b/src/fmt/support/cmake/FindSetEnv.cmake
new file mode 100644
index 000000000..4e2da5408
--- /dev/null
+++ b/src/fmt/support/cmake/FindSetEnv.cmake
@@ -0,0 +1,7 @@
+# A CMake script to find SetEnv.cmd.
+
+find_program(WINSDK_SETENV NAMES SetEnv.cmd
+ PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]/bin")
+if (WINSDK_SETENV AND PRINT_PATH)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${WINSDK_SETENV}")
+endif ()
diff --git a/src/fmt/support/cmake/JoinPaths.cmake b/src/fmt/support/cmake/JoinPaths.cmake
new file mode 100644
index 000000000..32d6d6685
--- /dev/null
+++ b/src/fmt/support/cmake/JoinPaths.cmake
@@ -0,0 +1,26 @@
+# This module provides function for joining paths
+# known from from most languages
+#
+# Original license:
+# SPDX-License-Identifier: (MIT OR CC0-1.0)
+# Explicit permission given to distribute this module under
+# the terms of the project as described in /LICENSE.rst.
+# Copyright 2020 Jan Tojnar
+# https://github.com/jtojnar/cmake-snips
+#
+# Modelled after Python’s os.path.join
+# https://docs.python.org/3.7/library/os.path.html#os.path.join
+# Windows not supported
+function(join_paths joined_path first_path_segment)
+ set(temp_path "${first_path_segment}")
+ foreach(current_segment IN LISTS ARGN)
+ if(NOT ("${current_segment}" STREQUAL ""))
+ if(IS_ABSOLUTE "${current_segment}")
+ set(temp_path "${current_segment}")
+ else()
+ set(temp_path "${temp_path}/${current_segment}")
+ endif()
+ endif()
+ endforeach()
+ set(${joined_path} "${temp_path}" PARENT_SCOPE)
+endfunction()
diff --git a/src/fmt/support/cmake/cxx14.cmake b/src/fmt/support/cmake/cxx14.cmake
new file mode 100644
index 000000000..16ff57541
--- /dev/null
+++ b/src/fmt/support/cmake/cxx14.cmake
@@ -0,0 +1,70 @@
+# C++14 feature support detection
+
+include(CheckCXXSourceCompiles)
+include(CheckCXXCompilerFlag)
+
+if (NOT CMAKE_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD 11)
+endif()
+message(STATUS "CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
+
+if (CMAKE_CXX_STANDARD EQUAL 20)
+ check_cxx_compiler_flag(-std=c++20 has_std_20_flag)
+ check_cxx_compiler_flag(-std=c++2a has_std_2a_flag)
+
+ if (has_std_20_flag)
+ set(CXX_STANDARD_FLAG -std=c++20)
+ elseif (has_std_2a_flag)
+ set(CXX_STANDARD_FLAG -std=c++2a)
+ endif ()
+elseif (CMAKE_CXX_STANDARD EQUAL 17)
+ check_cxx_compiler_flag(-std=c++17 has_std_17_flag)
+ check_cxx_compiler_flag(-std=c++1z has_std_1z_flag)
+
+ if (has_std_17_flag)
+ set(CXX_STANDARD_FLAG -std=c++17)
+ elseif (has_std_1z_flag)
+ set(CXX_STANDARD_FLAG -std=c++1z)
+ endif ()
+elseif (CMAKE_CXX_STANDARD EQUAL 14)
+ check_cxx_compiler_flag(-std=c++14 has_std_14_flag)
+ check_cxx_compiler_flag(-std=c++1y has_std_1y_flag)
+
+ if (has_std_14_flag)
+ set(CXX_STANDARD_FLAG -std=c++14)
+ elseif (has_std_1y_flag)
+ set(CXX_STANDARD_FLAG -std=c++1y)
+ endif ()
+elseif (CMAKE_CXX_STANDARD EQUAL 11)
+ check_cxx_compiler_flag(-std=c++11 has_std_11_flag)
+ check_cxx_compiler_flag(-std=c++0x has_std_0x_flag)
+
+ if (has_std_11_flag)
+ set(CXX_STANDARD_FLAG -std=c++11)
+ elseif (has_std_0x_flag)
+ set(CXX_STANDARD_FLAG -std=c++0x)
+ endif ()
+endif ()
+
+set(CMAKE_REQUIRED_FLAGS ${CXX_STANDARD_FLAG})
+
+# Check if user-defined literals are available
+check_cxx_source_compiles("
+ void operator\"\" _udl(long double);
+ int main() {}"
+ SUPPORTS_USER_DEFINED_LITERALS)
+if (NOT SUPPORTS_USER_DEFINED_LITERALS)
+ set (SUPPORTS_USER_DEFINED_LITERALS OFF)
+endif ()
+
+# Check if <variant> is available
+set(CMAKE_REQUIRED_FLAGS -std=c++1z)
+check_cxx_source_compiles("
+ #include <variant>
+ int main() {}"
+ FMT_HAS_VARIANT)
+if (NOT FMT_HAS_VARIANT)
+ set (FMT_HAS_VARIANT OFF)
+endif ()
+
+set(CMAKE_REQUIRED_FLAGS )
diff --git a/src/fmt/support/cmake/fmt-config.cmake.in b/src/fmt/support/cmake/fmt-config.cmake.in
new file mode 100644
index 000000000..71e302860
--- /dev/null
+++ b/src/fmt/support/cmake/fmt-config.cmake.in
@@ -0,0 +1,4 @@
+@PACKAGE_INIT@
+
+include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake)
+check_required_components(fmt)
diff --git a/src/fmt/support/cmake/fmt.pc.in b/src/fmt/support/cmake/fmt.pc.in
new file mode 100644
index 000000000..29976a8af
--- /dev/null
+++ b/src/fmt/support/cmake/fmt.pc.in
@@ -0,0 +1,11 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@libdir_for_pc_file@
+includedir=@includedir_for_pc_file@
+
+Name: fmt
+Description: A modern formatting library
+Version: @FMT_VERSION@
+Libs: -L${libdir} -l@FMT_LIB_NAME@
+Cflags: -I${includedir}
+