mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-07-15 05:17:11 +02:00
.github
bin
module
vendor
CPR
CivetWeb
ConcurrentQueue
Fmt
doc
include
src
support
test
add-subdirectory-test
compile-error-test
CMakeLists.txt
cuda-test
find-package-test
fuzzing
gtest
static-export-test
CMakeLists.txt
args-test.cc
assert-test.cc
chrono-test.cc
color-test.cc
compile-test.cc
core-test.cc
enforce-checks-test.cc
format
format-impl-test.cc
format-test.cc
gtest-extra-test.cc
gtest-extra.cc
gtest-extra.h
header-only-test.cc
mock-allocator.h
module-test.cc
os-test.cc
ostream-test.cc
posix-mock-test.cc
posix-mock.h
printf-test.cc
ranges-test.cc
scan-test.cc
scan.h
std-format-test.cc
test-assert.h
test-main.cc
unicode-test.cc
util.cc
util.h
xchar-test.cc
CMakeLists.txt
CONTRIBUTING.md
ChangeLog.rst
LICENSE.rst
README.rst
MDBC
MaxmindDB
POCO
PUGIXML
SAJSON
SimpleIni
Squirrel
TinyDir
UTF8
ZMQ
xxHash
CMakeLists.txt
.gitignore
.gitmodules
CMakeLists.txt
LICENSE
README.md
80 lines
2.3 KiB
CMake
80 lines
2.3 KiB
CMake
# Test if compile errors are produced where necessary.
|
|
|
|
cmake_minimum_required(VERSION 3.1...3.18)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
|
|
set(CMAKE_REQUIRED_FLAGS ${CXX_STANDARD_FLAG} ${PEDANTIC_COMPILE_FLAGS})
|
|
|
|
function (generate_source result fragment)
|
|
set(${result} "
|
|
#define FMT_HEADER_ONLY 1
|
|
#include \"fmt/format.h\"
|
|
int main() {
|
|
${fragment}
|
|
}
|
|
" PARENT_SCOPE)
|
|
endfunction ()
|
|
|
|
function (expect_compile code)
|
|
generate_source(source "${code}")
|
|
check_cxx_source_compiles("${source}" compiles)
|
|
if (NOT compiles)
|
|
set(error_msg "Compile error for: ${code}")
|
|
endif ()
|
|
# Unset the CMake cache variable compiles. Otherwise the compile test will
|
|
# just use cached information next time it runs.
|
|
unset(compiles CACHE)
|
|
if (error_msg)
|
|
message(FATAL_ERROR ${error_msg})
|
|
endif ()
|
|
endfunction ()
|
|
|
|
function (expect_compile_error code)
|
|
generate_source(source "${code}")
|
|
check_cxx_source_compiles("${source}" compiles)
|
|
if (compiles)
|
|
set(error_msg "No compile error for: ${code}")
|
|
endif ()
|
|
# Unset the CMake cache variable compiles. Otherwise the compile test will
|
|
# just use cached information next time it runs.
|
|
unset(compiles CACHE)
|
|
if (error_msg)
|
|
message(FATAL_ERROR ${error_msg})
|
|
endif ()
|
|
endfunction ()
|
|
|
|
# check if the source file skeleton compiles
|
|
expect_compile("")
|
|
|
|
# Formatting a wide character with a narrow format string is forbidden.
|
|
expect_compile_error("fmt::format(\"{}\", L'a');")
|
|
|
|
# Formatting a wide string with a narrow format string is forbidden.
|
|
expect_compile_error("fmt::format(\"{}\", L\"foo\");")
|
|
|
|
# Formatting a narrow string with a wide format string is forbidden because
|
|
# mixing UTF-8 with UTF-16/32 can result in an invalid output.
|
|
expect_compile_error("fmt::format(L\"{}\", \"foo\");")
|
|
|
|
# Formatting a wide string with a narrow format string is forbidden.
|
|
expect_compile_error("
|
|
struct S {
|
|
operator std::string() const { return std::string(); }
|
|
};
|
|
fmt::format(\"{}\", S());
|
|
")
|
|
|
|
# Make sure that compiler features detected in the header
|
|
# match the features detected in CMake.
|
|
if (SUPPORTS_USER_DEFINED_LITERALS)
|
|
set(supports_udl 1)
|
|
else ()
|
|
set(supports_udl 0)
|
|
endif ()
|
|
expect_compile("#if FMT_USE_USER_DEFINED_LITERALS != ${supports_udl}
|
|
# error
|
|
#endif")
|