summaryrefslogtreecommitdiffstats
path: root/src/seastar/fmt/support/cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/seastar/fmt/support/cmake
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/seastar/fmt/support/cmake')
-rw-r--r--src/seastar/fmt/support/cmake/FindSetEnv.cmake7
-rw-r--r--src/seastar/fmt/support/cmake/cxx14.cmake102
-rw-r--r--src/seastar/fmt/support/cmake/fmt-config.cmake.in4
-rw-r--r--src/seastar/fmt/support/cmake/fmt.pc.in11
-rw-r--r--src/seastar/fmt/support/cmake/run-cmake.bat11
5 files changed, 135 insertions, 0 deletions
diff --git a/src/seastar/fmt/support/cmake/FindSetEnv.cmake b/src/seastar/fmt/support/cmake/FindSetEnv.cmake
new file mode 100644
index 00000000..4e2da540
--- /dev/null
+++ b/src/seastar/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/seastar/fmt/support/cmake/cxx14.cmake b/src/seastar/fmt/support/cmake/cxx14.cmake
new file mode 100644
index 00000000..6aa9e21d
--- /dev/null
+++ b/src/seastar/fmt/support/cmake/cxx14.cmake
@@ -0,0 +1,102 @@
+# C++14 feature support detection
+
+include(CheckCXXSourceCompiles)
+include(CheckCXXCompilerFlag)
+
+if (CMAKE_CXX_STANDARD)
+ message(STATUS "CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
+elseif (CMAKE_CXX_FLAGS MATCHES "-std=(c|gnu)\\+\\+")
+ string(REGEX MATCH "-std=(c|gnu)\\+\\+[^ ]+" CXX_STANDARD_FLAG "${CMAKE_CXX_FLAGS}")
+ message(STATUS "CXX_STANDARD_FLAG: ${CXX_STANDARD_FLAG}")
+else()
+ set(CMAKE_CXX_STANDARD 11)
+ message(STATUS "CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
+endif()
+
+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 variadic templates are working and not affected by GCC bug 39653:
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39653
+check_cxx_source_compiles("
+ template <class T, class ...Types>
+ struct S { typedef typename S<Types...>::type type; };
+ int main() {}" SUPPORTS_VARIADIC_TEMPLATES)
+if (NOT SUPPORTS_VARIADIC_TEMPLATES)
+ set (SUPPORTS_VARIADIC_TEMPLATES OFF)
+endif ()
+
+# Check if initializer lists are supported.
+check_cxx_source_compiles("
+ #include <initializer_list>
+ int main() {}" SUPPORTS_INITIALIZER_LIST)
+if (NOT SUPPORTS_INITIALIZER_LIST)
+ set (SUPPORTS_INITIALIZER_LIST OFF)
+endif ()
+
+# Check if enum bases are available
+check_cxx_source_compiles("
+ enum C : char {A};
+ int main() {}"
+ SUPPORTS_ENUM_BASE)
+if (NOT SUPPORTS_ENUM_BASE)
+ set (SUPPORTS_ENUM_BASE OFF)
+endif ()
+
+# Check if type traits are available
+check_cxx_source_compiles("
+ #include <type_traits>
+ class C { void operator=(const C&); };
+ int main() { static_assert(!std::is_copy_assignable<C>::value, \"\"); }"
+ SUPPORTS_TYPE_TRAITS)
+if (NOT SUPPORTS_TYPE_TRAITS)
+ set (SUPPORTS_TYPE_TRAITS OFF)
+endif ()
+
+# 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 ()
+
+set(CMAKE_REQUIRED_FLAGS )
diff --git a/src/seastar/fmt/support/cmake/fmt-config.cmake.in b/src/seastar/fmt/support/cmake/fmt-config.cmake.in
new file mode 100644
index 00000000..71e30286
--- /dev/null
+++ b/src/seastar/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/seastar/fmt/support/cmake/fmt.pc.in b/src/seastar/fmt/support/cmake/fmt.pc.in
new file mode 100644
index 00000000..79de0b6d
--- /dev/null
+++ b/src/seastar/fmt/support/cmake/fmt.pc.in
@@ -0,0 +1,11 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
+
+Name: fmt
+Description: A modern formatting library
+Version: @FMT_VERSION@
+Libs: -L${libdir} -lfmt
+Cflags: -I${includedir}
+
diff --git a/src/seastar/fmt/support/cmake/run-cmake.bat b/src/seastar/fmt/support/cmake/run-cmake.bat
new file mode 100644
index 00000000..f18bb055
--- /dev/null
+++ b/src/seastar/fmt/support/cmake/run-cmake.bat
@@ -0,0 +1,11 @@
+@echo on
+rem This scripts configures build environment and runs CMake.
+rem Use it instead of running CMake directly when building with
+rem the Microsoft SDK toolchain rather than Visual Studio.
+rem It is used in the same way as cmake, for example:
+rem
+rem run-cmake -G "Visual Studio 10 Win64" .
+
+for /F "delims=" %%i IN ('cmake "-DPRINT_PATH=1" -P %~dp0/FindSetEnv.cmake') DO set setenv=%%i
+if NOT "%setenv%" == "" call "%setenv%"
+cmake %*