Skip to content

Commit

Permalink
cmake: detect if compiler supports std::format when USE_LIBFMT is OFF
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Aug 29, 2023
1 parent d0928b5 commit 4b99d9d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,27 @@ if (USE_LTO)
endif()
endif(USE_LTO)

if (NOT USE_LIBFMT)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(CheckCXXSourceCompiles)

check_cxx_source_compiles("
#include <format>
int main(void)
{
std::string str = std::format(\"number: {}\", 10);
return 0;
}" HAVE_STDFORMAT)

# fallback to libfmt if std::format
# isn't supported in the compiler
if (NOT HAVE_STDFORMAT)
set(USE_LIBFMT ON)
endif(NOT HAVE_STDFORMAT)
endif(NOT USE_LIBFMT)

if (NOT PORTABLE_INSTALL AND (WIN32 OR MSYS))
message(WARNING "Not-Portable build not supported on windows, re-enabling PORTABLE_INSTALL!")
set(PORTABLE_INSTALL ON)
Expand Down

0 comments on commit 4b99d9d

Please sign in to comment.