fmt/test
Richard Musil 3b2fc033d1 Making CUDA test work with CMAKE_MSVC_RUNTIME_LIBRARY
CMake 3.15 introduced a new way of handling MSVC CRT type definition for
the build: CMAKE_MSVC_RUNTIME_LIBRARY variable.
(https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)

This is supposed to be the way to go with MSVC CRT selection in new
projects. Using this method however breaks the current CMake script for
CUDA test. The reason is the CUDA test uses "FindCUDA" CMake module to
detect and set up CUDA support in CMake, which is deprecated since CMake
version 3.10, and which does not support CMAKE_MSVC_RUNTIME_LIBRARY
selector correctly (i.e. it does not propagate the compiler option
related to the CRT).

I did not find a way to "patch" in the correct compiler options, so
(while knowing this feature is only available from CMake 3.15 on) I
decided to change also the way CUDA is handled and instead of using
FindCUDA, used enable_language. Apart from having some nice additional
side-effects, it also fixed the problem with CRT selection.

However, the propagation of the compiler options (and in particular the
options related to C++ standard selection) is still a bit flaky on
Windows+MSVC platform, so it had to be done manually.

The patch makes two things in parallel:

1) Introduces MSVC_BUILD_STATIC, which, together with CMake version >=
3.15, allows building static version of the 'fmt' lib (and all the
tests).

2) At the same time, for CMake >= 3.15 it switches handling of CUDA
support from (old) FindCUDA to (new) enable_language, to fix the
problems which the old method has with the new CRT selector for MSVC in
a new CMake.

Added a check for CUDA before enabling it.

Using VERSION_LESS instead of VERSION_GREATER_EQUAL

Since apparently VERSION_GREATER_EQUAL exists only from CMake 3.7, while
Android is using CMake 3.6.

Removed MSVC_RUNTIME_LIBRARY logic from the CMake file.

The static build can be set on the command line with CMake >= 3.15
by defining the policy and the CMAKE_MSVC_RUNTIME_LIBARY this way:

cmake -G <gen> <options>
    -DCMAKE_POLICY_DEFAULT_CMP0091=NEW
    -DMSVC_BUILD_STATIC=ON
    -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>"

When MSVC_BUILD_DEBUG is set the test 'posix-mock-test' is skipped as it
does not build with the static runtime.
2019-09-25 06:46:11 -07:00
..
add-subdirectory-test Add more compilers to CI and increase FMT_PEDANTIC warning levels (#736) 2018-06-06 15:57:59 +02:00
compile-error-test prepare -> compile 2019-07-25 19:39:41 +03:00
cuda-test Making CUDA test work with CMAKE_MSVC_RUNTIME_LIBRARY 2019-09-25 06:46:11 -07:00
find-package-test Add more compilers to CI and increase FMT_PEDANTIC warning levels (#736) 2018-06-06 15:57:59 +02:00
fuzzing Apply clang format and other minor formatting tweaks 2019-06-30 08:52:15 -07:00
gmock Add more compilers to CI and increase FMT_PEDANTIC warning levels (#736) 2018-06-06 15:57:59 +02:00
gtest Fix error on MinGW 2017-03-09 06:09:43 -08:00
assert-test.cc Fix EXPECT_DEBUG_DEATH_IF_SUPPORTED (#1214) 2019-07-04 07:55:36 -07:00
chrono-test.cc add oss-fuzz support 2019-06-30 06:10:07 -07:00
CMakeLists.txt Making CUDA test work with CMAKE_MSVC_RUNTIME_LIBRARY 2019-09-25 06:46:11 -07:00
color-test.cc Fix format overload that takes text_style (#1305) 2019-09-08 18:41:02 -07:00
compile-test.cc add test for multiple compilation types 2019-09-24 06:25:21 -07:00
core-test.cc get_type -> mapped_type_constant 2019-06-11 07:23:39 -07:00
custom-formatter-test.cc Make buffer_range public and update custom formatting docs (#1281) 2019-08-28 06:50:20 -07:00
format Remove unused code and refactor 2019-09-01 13:08:53 -07:00
format-impl-test.cc Add max_value 2019-09-08 09:21:30 -07:00
format-test.cc Add max_value 2019-09-08 09:21:30 -07:00
gmock-gtest-all.cc Format the code using clang-format 2019-01-13 06:58:20 -08:00
grisu-test.cc Fix small number rounding with fixed precision in grisu 2019-07-04 07:11:40 -07:00
gtest-extra-test.cc FMT_EXPLICIT -> explicit, FMT_NULL -> nullptr 2019-05-30 07:42:36 -07:00
gtest-extra.cc Format the code using clang-format 2019-01-13 06:58:20 -08:00
gtest-extra.h FMT_EXPLICIT -> explicit, FMT_NULL -> nullptr 2019-05-30 07:42:36 -07:00
header-only-test2.cc Add a lightweight header for the core API 2017-12-06 07:42:42 -08:00
header-only-test.cc Add a lightweight header for the core API 2017-12-06 07:42:42 -08:00
locale-test.cc Workaround a broken C locale on Windows 2019-07-25 12:55:23 +03:00
mock-allocator.h Cleanup 2019-06-15 09:44:51 -07:00
ostream-test.cc Disable integral operator<< (#1316) 2019-09-23 20:34:08 -07:00
posix-mock-test.cc typedef -> using 2019-07-07 17:14:26 -07:00
posix-mock.h Format the code using clang-format 2019-01-13 06:58:20 -08:00
posix-test.cc Remove redundant and nonportable test (#1313) 2019-09-23 13:36:12 -07:00
printf-test.cc Add max_value 2019-09-08 09:21:30 -07:00
ranges-test.cc Workaround an issue with std::filesystem::path being an infinitely deep range (#1268) 2019-08-21 11:22:59 -07:00
scan-test.cc Add preliminary user-defined type support 2019-06-08 09:04:46 -07:00
scan.h Fix a warning 2019-08-11 11:38:16 -07:00
std-format-test.cc Make numeric alignment optional 2019-09-06 09:43:53 -07:00
test-assert.h Format the code using clang-format 2019-01-13 06:58:20 -08:00
test-main.cc Format the code using clang-format 2019-01-13 06:58:20 -08:00
util.cc Format the code using clang-format 2019-01-13 06:58:20 -08:00
util.h FMT_EXPLICIT -> explicit, FMT_NULL -> nullptr 2019-05-30 07:42:36 -07:00