From f3890089a4417271c00e6ab8dbc3521784138662 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Sat, 23 Mar 2024 15:44:55 +0800 Subject: [PATCH] feat update --- 3party/fmt/support/cmake/FindSetEnv.cmake | 7 ++ 3party/fmt/support/cmake/cxx11.cmake | 85 ++++++++++++++++++++ 3party/fmt/support/cmake/fmt-config.cmake.in | 4 + 3party/fmt/support/cmake/run-cmake.bat | 11 +++ 4 files changed, 107 insertions(+) create mode 100644 3party/fmt/support/cmake/FindSetEnv.cmake create mode 100644 3party/fmt/support/cmake/cxx11.cmake create mode 100644 3party/fmt/support/cmake/fmt-config.cmake.in create mode 100644 3party/fmt/support/cmake/run-cmake.bat diff --git a/3party/fmt/support/cmake/FindSetEnv.cmake b/3party/fmt/support/cmake/FindSetEnv.cmake new file mode 100644 index 0000000..4e2da54 --- /dev/null +++ b/3party/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/3party/fmt/support/cmake/cxx11.cmake b/3party/fmt/support/cmake/cxx11.cmake new file mode 100644 index 0000000..21d1254 --- /dev/null +++ b/3party/fmt/support/cmake/cxx11.cmake @@ -0,0 +1,85 @@ +# C++11 feature support detection + +if (NOT FMT_USE_CPP11) + return() +endif () + +include(CheckCXXCompilerFlag) + +if (FMT_USE_CPP11) + check_cxx_compiler_flag(-std=c++11 HAVE_STD_CPP11_FLAG) + if (HAVE_STD_CPP11_FLAG) + # Check if including cmath works with -std=c++11 and -O3. + # It may not in MinGW due to bug http://ehc.ac/p/mingw/bugs/2250/. + set(CMAKE_REQUIRED_FLAGS "-std=c++11 -O3") + check_cxx_source_compiles(" + #include + int main() {}" FMT_CPP11_CMATH) + # Check if including works with -std=c++11. + # It may not in MinGW due to bug http://sourceforge.net/p/mingw/bugs/2024/. + check_cxx_source_compiles(" + #include + int main() {}" FMT_CPP11_UNISTD_H) + # Check if snprintf works with -std=c++11. It may not in MinGW. + check_cxx_source_compiles(" + #include + int main() { + char buffer[10]; + snprintf(buffer, 10, \"foo\"); + }" FMT_CPP11_SNPRINTF) + if (FMT_CPP11_CMATH AND FMT_CPP11_UNISTD_H AND FMT_CPP11_SNPRINTF) + set(CPP11_FLAG -std=c++11) + else () + check_cxx_compiler_flag(-std=gnu++11 HAVE_STD_GNUPP11_FLAG) + if (HAVE_STD_CPP11_FLAG) + set(CPP11_FLAG -std=gnu++11) + endif () + endif () + set(CMAKE_REQUIRED_FLAGS ) + else () + check_cxx_compiler_flag(-std=c++0x HAVE_STD_CPP0X_FLAG) + if (HAVE_STD_CPP0X_FLAG) + set(CPP11_FLAG -std=c++0x) + endif () + endif () +endif () + +if (CMAKE_CXX_STANDARD) + # Don't use -std compiler flag if CMAKE_CXX_STANDARD is specified. + set(CPP11_FLAG ) +endif () + +set(CMAKE_REQUIRED_FLAGS ${CPP11_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 + struct S { typedef typename S::type type; }; + int main() {}" SUPPORTS_VARIADIC_TEMPLATES) + +# Check if initializer lists are supported. +check_cxx_source_compiles(" + #include + int main() {}" SUPPORTS_INITIALIZER_LIST) + +# Check if enum bases are available +check_cxx_source_compiles(" + enum C : char {A}; + int main() {}" + SUPPORTS_ENUM_BASE) + +# Check if type traits are available +check_cxx_source_compiles(" + #include + class C { void operator=(const C&); }; + int main() { static_assert(!std::is_copy_assignable::value, \"\"); }" + SUPPORTS_TYPE_TRAITS) + +# Check if user-defined literals are available +check_cxx_source_compiles(" + void operator\"\" _udl(long double); + int main() {}" + SUPPORTS_USER_DEFINED_LITERALS) + +set(CMAKE_REQUIRED_FLAGS ) diff --git a/3party/fmt/support/cmake/fmt-config.cmake.in b/3party/fmt/support/cmake/fmt-config.cmake.in new file mode 100644 index 0000000..71e3028 --- /dev/null +++ b/3party/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/3party/fmt/support/cmake/run-cmake.bat b/3party/fmt/support/cmake/run-cmake.bat new file mode 100644 index 0000000..f18bb05 --- /dev/null +++ b/3party/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 %*