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.cmake54
-rw-r--r--src/fmt/support/cmake/fmt-config.cmake.in7
-rw-r--r--src/fmt/support/cmake/fmt.pc.in11
5 files changed, 105 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..deb1e26fb
--- /dev/null
+++ b/src/fmt/support/cmake/cxx14.cmake
@@ -0,0 +1,54 @@
+# C++14 feature support detection
+
+include(CheckCXXCompilerFlag)
+function (fmt_check_cxx_compiler_flag flag result)
+ if (NOT MSVC)
+ check_cxx_compiler_flag("${flag}" ${result})
+ endif ()
+endfunction ()
+
+if (NOT CMAKE_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD 11)
+endif()
+message(STATUS "CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
+
+if (CMAKE_CXX_STANDARD EQUAL 20)
+ fmt_check_cxx_compiler_flag(-std=c++20 has_std_20_flag)
+ fmt_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)
+ fmt_check_cxx_compiler_flag(-std=c++17 has_std_17_flag)
+ fmt_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)
+ fmt_check_cxx_compiler_flag(-std=c++14 has_std_14_flag)
+ fmt_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)
+ fmt_check_cxx_compiler_flag(-std=c++11 has_std_11_flag)
+ fmt_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 ()
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..bc1684f24
--- /dev/null
+++ b/src/fmt/support/cmake/fmt-config.cmake.in
@@ -0,0 +1,7 @@
+@PACKAGE_INIT@
+
+if (NOT TARGET fmt::fmt)
+ include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake)
+endif ()
+
+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}
+