git repos / blockattack-game

blame: source/misc/embedded_libs/fmt-11.0.2/test/CMakeLists.txt

normal view · raw

a0630906 Poul Sander 2022-01-15 13:59 1
add_subdirectory(gtest)
a0630906 Poul Sander 2022-01-15 13:59 2
47fd5c32 Poul Sander 2024-10-05 08:44 3
include(CheckSymbolExists)
47fd5c32 Poul Sander 2024-10-05 08:44 4
a0630906 Poul Sander 2022-01-15 13:59 5
set(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc)
a0630906 Poul Sander 2022-01-15 13:59 6
add_library(test-main STATIC ${TEST_MAIN_SRC})
a0630906 Poul Sander 2022-01-15 13:59 7
target_include_directories(test-main PUBLIC
a0630906 Poul Sander 2022-01-15 13:59 8
  $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
47fd5c32 Poul Sander 2024-10-05 08:44 9
target_link_libraries(test-main gtest fmt)
a0630906 Poul Sander 2022-01-15 13:59 10
a0630906 Poul Sander 2022-01-15 13:59 11
function(add_fmt_executable name)
a0630906 Poul Sander 2022-01-15 13:59 12
  add_executable(${name} ${ARGN})
a0630906 Poul Sander 2022-01-15 13:59 13
  # (Wstringop-overflow) - [meta-bug] bogus/missing -Wstringop-overflow warnings
a0630906 Poul Sander 2022-01-15 13:59 14
  #   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
a0630906 Poul Sander 2022-01-15 13:59 15
  # Bogus -Wstringop-overflow warning
a0630906 Poul Sander 2022-01-15 13:59 16
  #   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100395
a0630906 Poul Sander 2022-01-15 13:59 17
  # [10 Regression] spurious -Wstringop-overflow writing to a trailing array plus offset
a0630906 Poul Sander 2022-01-15 13:59 18
  #   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95353
a0630906 Poul Sander 2022-01-15 13:59 19
  if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
a0630906 Poul Sander 2022-01-15 13:59 20
      NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
47fd5c32 Poul Sander 2024-10-05 08:44 21
    target_compile_options(${name} PRIVATE -Wno-stringop-overflow)
47fd5c32 Poul Sander 2024-10-05 08:44 22
    # The linker flag is needed for LTO.
a0630906 Poul Sander 2022-01-15 13:59 23
    target_link_libraries(${name} -Wno-stringop-overflow)
a0630906 Poul Sander 2022-01-15 13:59 24
  endif ()
a0630906 Poul Sander 2022-01-15 13:59 25
endfunction()
a0630906 Poul Sander 2022-01-15 13:59 26
a0630906 Poul Sander 2022-01-15 13:59 27
# Adds a test.
a0630906 Poul Sander 2022-01-15 13:59 28
# Usage: add_fmt_test(name srcs...)
a0630906 Poul Sander 2022-01-15 13:59 29
function(add_fmt_test name)
a0630906 Poul Sander 2022-01-15 13:59 30
  cmake_parse_arguments(ADD_FMT_TEST "HEADER_ONLY;MODULE" "" "" ${ARGN})
a0630906 Poul Sander 2022-01-15 13:59 31
a0630906 Poul Sander 2022-01-15 13:59 32
  set(sources ${name}.cc ${ADD_FMT_TEST_UNPARSED_ARGUMENTS})
a0630906 Poul Sander 2022-01-15 13:59 33
  if (ADD_FMT_TEST_HEADER_ONLY)
a0630906 Poul Sander 2022-01-15 13:59 34
    set(sources ${sources} ${TEST_MAIN_SRC} ../src/os.cc)
a0630906 Poul Sander 2022-01-15 13:59 35
    set(libs gtest fmt-header-only)
a0630906 Poul Sander 2022-01-15 13:59 36
    if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
a0630906 Poul Sander 2022-01-15 13:59 37
      set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wno-weak-vtables)
a0630906 Poul Sander 2022-01-15 13:59 38
    endif ()
a0630906 Poul Sander 2022-01-15 13:59 39
  elseif (ADD_FMT_TEST_MODULE)
47fd5c32 Poul Sander 2024-10-05 08:44 40
    set(libs test-main test-module)
a0630906 Poul Sander 2022-01-15 13:59 41
    set_source_files_properties(${name}.cc PROPERTIES OBJECT_DEPENDS test-module)
a0630906 Poul Sander 2022-01-15 13:59 42
  else ()
a0630906 Poul Sander 2022-01-15 13:59 43
    set(libs test-main fmt)
a0630906 Poul Sander 2022-01-15 13:59 44
  endif ()
a0630906 Poul Sander 2022-01-15 13:59 45
  add_fmt_executable(${name} ${sources})
a0630906 Poul Sander 2022-01-15 13:59 46
  target_link_libraries(${name} ${libs})
a0630906 Poul Sander 2022-01-15 13:59 47
47fd5c32 Poul Sander 2024-10-05 08:44 48
  if (ADD_FMT_TEST_HEADER_ONLY AND NOT FMT_UNICODE)
47fd5c32 Poul Sander 2024-10-05 08:44 49
    target_compile_definitions(${name} PUBLIC FMT_UNICODE=0)
47fd5c32 Poul Sander 2024-10-05 08:44 50
  endif ()
47fd5c32 Poul Sander 2024-10-05 08:44 51
a0630906 Poul Sander 2022-01-15 13:59 52
  # Define if certain C++ features can be used.
a0630906 Poul Sander 2022-01-15 13:59 53
  if (FMT_PEDANTIC)
a0630906 Poul Sander 2022-01-15 13:59 54
    target_compile_options(${name} PRIVATE ${PEDANTIC_COMPILE_FLAGS})
a0630906 Poul Sander 2022-01-15 13:59 55
  endif ()
a0630906 Poul Sander 2022-01-15 13:59 56
  if (FMT_WERROR)
a0630906 Poul Sander 2022-01-15 13:59 57
    target_compile_options(${name} PRIVATE ${WERROR_FLAG})
a0630906 Poul Sander 2022-01-15 13:59 58
  endif ()
a0630906 Poul Sander 2022-01-15 13:59 59
  add_test(NAME ${name} COMMAND ${name})
a0630906 Poul Sander 2022-01-15 13:59 60
endfunction()
a0630906 Poul Sander 2022-01-15 13:59 61
47fd5c32 Poul Sander 2024-10-05 08:44 62
if (FMT_MODULE)
47fd5c32 Poul Sander 2024-10-05 08:44 63
  return ()
47fd5c32 Poul Sander 2024-10-05 08:44 64
endif ()
47fd5c32 Poul Sander 2024-10-05 08:44 65
a0630906 Poul Sander 2022-01-15 13:59 66
add_fmt_test(args-test)
47fd5c32 Poul Sander 2024-10-05 08:44 67
add_fmt_test(base-test)
a0630906 Poul Sander 2022-01-15 13:59 68
add_fmt_test(assert-test)
a0630906 Poul Sander 2022-01-15 13:59 69
add_fmt_test(chrono-test)
a0630906 Poul Sander 2022-01-15 13:59 70
add_fmt_test(color-test)
a0630906 Poul Sander 2022-01-15 13:59 71
add_fmt_test(gtest-extra-test)
a0630906 Poul Sander 2022-01-15 13:59 72
add_fmt_test(format-test mock-allocator.h)
a0630906 Poul Sander 2022-01-15 13:59 73
if (MSVC)
a0630906 Poul Sander 2022-01-15 13:59 74
  target_compile_options(format-test PRIVATE /bigobj)
a0630906 Poul Sander 2022-01-15 13:59 75
endif ()
a0630906 Poul Sander 2022-01-15 13:59 76
if (NOT (MSVC AND BUILD_SHARED_LIBS))
a0630906 Poul Sander 2022-01-15 13:59 77
  add_fmt_test(format-impl-test HEADER_ONLY header-only-test.cc)
a0630906 Poul Sander 2022-01-15 13:59 78
endif ()
a0630906 Poul Sander 2022-01-15 13:59 79
add_fmt_test(ostream-test)
a0630906 Poul Sander 2022-01-15 13:59 80
add_fmt_test(compile-test)
a0630906 Poul Sander 2022-01-15 13:59 81
add_fmt_test(compile-fp-test HEADER_ONLY)
a0630906 Poul Sander 2022-01-15 13:59 82
if (MSVC)
a0630906 Poul Sander 2022-01-15 13:59 83
  # Without this option, MSVC returns 199711L for the __cplusplus macro.
a0630906 Poul Sander 2022-01-15 13:59 84
  target_compile_options(compile-fp-test PRIVATE /Zc:__cplusplus)
a0630906 Poul Sander 2022-01-15 13:59 85
endif()
a0630906 Poul Sander 2022-01-15 13:59 86
add_fmt_test(printf-test)
a0630906 Poul Sander 2022-01-15 13:59 87
add_fmt_test(ranges-test ranges-odr-test.cc)
47fd5c32 Poul Sander 2024-10-05 08:44 88
47fd5c32 Poul Sander 2024-10-05 08:44 89
add_fmt_test(scan-test HEADER_ONLY)
47fd5c32 Poul Sander 2024-10-05 08:44 90
check_symbol_exists(strptime "time.h" HAVE_STRPTIME)
47fd5c32 Poul Sander 2024-10-05 08:44 91
if (HAVE_STRPTIME)
47fd5c32 Poul Sander 2024-10-05 08:44 92
  target_compile_definitions(scan-test PRIVATE FMT_HAVE_STRPTIME)
47fd5c32 Poul Sander 2024-10-05 08:44 93
endif ()
47fd5c32 Poul Sander 2024-10-05 08:44 94
47fd5c32 Poul Sander 2024-10-05 08:44 95
add_fmt_test(std-test)
47fd5c32 Poul Sander 2024-10-05 08:44 96
try_compile(compile_result_unused
47fd5c32 Poul Sander 2024-10-05 08:44 97
            ${CMAKE_CURRENT_BINARY_DIR}
47fd5c32 Poul Sander 2024-10-05 08:44 98
            SOURCES ${CMAKE_CURRENT_LIST_DIR}/detect-stdfs.cc
47fd5c32 Poul Sander 2024-10-05 08:44 99
            OUTPUT_VARIABLE RAWOUTPUT)
47fd5c32 Poul Sander 2024-10-05 08:44 100
string(REGEX REPLACE ".*libfound \"([^\"]*)\".*" "\\1" STDLIBFS "${RAWOUTPUT}")
47fd5c32 Poul Sander 2024-10-05 08:44 101
if (STDLIBFS)
47fd5c32 Poul Sander 2024-10-05 08:44 102
  target_link_libraries(std-test ${STDLIBFS})
47fd5c32 Poul Sander 2024-10-05 08:44 103
endif ()
a0630906 Poul Sander 2022-01-15 13:59 104
add_fmt_test(unicode-test HEADER_ONLY)
a0630906 Poul Sander 2022-01-15 13:59 105
if (MSVC)
a0630906 Poul Sander 2022-01-15 13:59 106
  target_compile_options(unicode-test PRIVATE /utf-8)
a0630906 Poul Sander 2022-01-15 13:59 107
endif ()
a0630906 Poul Sander 2022-01-15 13:59 108
add_fmt_test(xchar-test)
a0630906 Poul Sander 2022-01-15 13:59 109
add_fmt_test(enforce-checks-test)
a0630906 Poul Sander 2022-01-15 13:59 110
target_compile_definitions(enforce-checks-test PRIVATE
a0630906 Poul Sander 2022-01-15 13:59 111
                           -DFMT_ENFORCE_COMPILE_STRING)
a0630906 Poul Sander 2022-01-15 13:59 112
47fd5c32 Poul Sander 2024-10-05 08:44 113
add_executable(perf-sanity perf-sanity.cc)
47fd5c32 Poul Sander 2024-10-05 08:44 114
target_link_libraries(perf-sanity fmt::fmt)
47fd5c32 Poul Sander 2024-10-05 08:44 115
47fd5c32 Poul Sander 2024-10-05 08:44 116
if (FMT_MODULE)
a0630906 Poul Sander 2022-01-15 13:59 117
  # The tests need {fmt} to be compiled as traditional library
a0630906 Poul Sander 2022-01-15 13:59 118
  # because of visibility of implementation details.
a0630906 Poul Sander 2022-01-15 13:59 119
  # If module support is present the module tests require a
a0630906 Poul Sander 2022-01-15 13:59 120
  # test-only module to be built from {fmt}
a0630906 Poul Sander 2022-01-15 13:59 121
  add_library(test-module OBJECT ${CMAKE_SOURCE_DIR}/src/fmt.cc)
47fd5c32 Poul Sander 2024-10-05 08:44 122
  target_compile_features(test-module PUBLIC cxx_std_11)
a0630906 Poul Sander 2022-01-15 13:59 123
  target_include_directories(test-module PUBLIC
a0630906 Poul Sander 2022-01-15 13:59 124
    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
a0630906 Poul Sander 2022-01-15 13:59 125
  enable_module(test-module)
a0630906 Poul Sander 2022-01-15 13:59 126
a0630906 Poul Sander 2022-01-15 13:59 127
  add_fmt_test(module-test MODULE test-main.cc)
a0630906 Poul Sander 2022-01-15 13:59 128
  if (MSVC)
a0630906 Poul Sander 2022-01-15 13:59 129
    target_compile_options(test-module PRIVATE /utf-8 /Zc:__cplusplus
a0630906 Poul Sander 2022-01-15 13:59 130
                           /Zc:externConstexpr /Zc:inline)
a0630906 Poul Sander 2022-01-15 13:59 131
    target_compile_options(module-test PRIVATE /utf-8 /Zc:__cplusplus
a0630906 Poul Sander 2022-01-15 13:59 132
                           /Zc:externConstexpr /Zc:inline)
a0630906 Poul Sander 2022-01-15 13:59 133
  endif ()
a0630906 Poul Sander 2022-01-15 13:59 134
endif ()
a0630906 Poul Sander 2022-01-15 13:59 135
a0630906 Poul Sander 2022-01-15 13:59 136
if (NOT DEFINED MSVC_STATIC_RUNTIME AND MSVC)
a0630906 Poul Sander 2022-01-15 13:59 137
  foreach (flag_var
a0630906 Poul Sander 2022-01-15 13:59 138
			 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
a0630906 Poul Sander 2022-01-15 13:59 139
			 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
a0630906 Poul Sander 2022-01-15 13:59 140
	if (${flag_var} MATCHES "^(/|-)(MT|MTd)")
a0630906 Poul Sander 2022-01-15 13:59 141
	  set(MSVC_STATIC_RUNTIME ON)
a0630906 Poul Sander 2022-01-15 13:59 142
	  break()
a0630906 Poul Sander 2022-01-15 13:59 143
	endif()
a0630906 Poul Sander 2022-01-15 13:59 144
  endforeach()
a0630906 Poul Sander 2022-01-15 13:59 145
endif()
a0630906 Poul Sander 2022-01-15 13:59 146
a0630906 Poul Sander 2022-01-15 13:59 147
if (NOT MSVC_STATIC_RUNTIME)
a0630906 Poul Sander 2022-01-15 13:59 148
  add_fmt_executable(posix-mock-test
a0630906 Poul Sander 2022-01-15 13:59 149
    posix-mock-test.cc ../src/format.cc ${TEST_MAIN_SRC})
a0630906 Poul Sander 2022-01-15 13:59 150
  target_include_directories(
a0630906 Poul Sander 2022-01-15 13:59 151
    posix-mock-test PRIVATE ${PROJECT_SOURCE_DIR}/include)
a0630906 Poul Sander 2022-01-15 13:59 152
  target_link_libraries(posix-mock-test gtest)
a0630906 Poul Sander 2022-01-15 13:59 153
  if (FMT_PEDANTIC)
a0630906 Poul Sander 2022-01-15 13:59 154
    target_compile_options(posix-mock-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})
a0630906 Poul Sander 2022-01-15 13:59 155
  endif ()
47fd5c32 Poul Sander 2024-10-05 08:44 156
  if (MSVC)
47fd5c32 Poul Sander 2024-10-05 08:44 157
    target_compile_options(posix-mock-test PRIVATE /utf-8)
a0630906 Poul Sander 2022-01-15 13:59 158
  endif ()
a0630906 Poul Sander 2022-01-15 13:59 159
  add_test(NAME posix-mock-test COMMAND posix-mock-test)
a0630906 Poul Sander 2022-01-15 13:59 160
  add_fmt_test(os-test)
a0630906 Poul Sander 2022-01-15 13:59 161
endif ()
a0630906 Poul Sander 2022-01-15 13:59 162
a0630906 Poul Sander 2022-01-15 13:59 163
message(STATUS "FMT_PEDANTIC: ${FMT_PEDANTIC}")
a0630906 Poul Sander 2022-01-15 13:59 164
a0630906 Poul Sander 2022-01-15 13:59 165
if (FMT_PEDANTIC)
a0630906 Poul Sander 2022-01-15 13:59 166
  # Test that the library can be compiled with exceptions disabled.
a0630906 Poul Sander 2022-01-15 13:59 167
  # -fno-exception is broken in icc: https://github.com/fmtlib/fmt/issues/822.
a0630906 Poul Sander 2022-01-15 13:59 168
  if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
a0630906 Poul Sander 2022-01-15 13:59 169
    check_cxx_compiler_flag(-fno-exceptions HAVE_FNO_EXCEPTIONS_FLAG)
a0630906 Poul Sander 2022-01-15 13:59 170
  endif ()
a0630906 Poul Sander 2022-01-15 13:59 171
  if (HAVE_FNO_EXCEPTIONS_FLAG)
a0630906 Poul Sander 2022-01-15 13:59 172
    add_library(noexception-test ../src/format.cc noexception-test.cc)
a0630906 Poul Sander 2022-01-15 13:59 173
    target_include_directories(
a0630906 Poul Sander 2022-01-15 13:59 174
      noexception-test PRIVATE ${PROJECT_SOURCE_DIR}/include)
a0630906 Poul Sander 2022-01-15 13:59 175
    target_compile_options(noexception-test PRIVATE -fno-exceptions)
47fd5c32 Poul Sander 2024-10-05 08:44 176
    target_compile_options(noexception-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})
a0630906 Poul Sander 2022-01-15 13:59 177
  endif ()
a0630906 Poul Sander 2022-01-15 13:59 178
a0630906 Poul Sander 2022-01-15 13:59 179
  # Test that the library compiles without locale.
a0630906 Poul Sander 2022-01-15 13:59 180
  add_library(nolocale-test ../src/format.cc)
a0630906 Poul Sander 2022-01-15 13:59 181
  target_include_directories(
a0630906 Poul Sander 2022-01-15 13:59 182
    nolocale-test PRIVATE ${PROJECT_SOURCE_DIR}/include)
a0630906 Poul Sander 2022-01-15 13:59 183
  target_compile_definitions(
a0630906 Poul Sander 2022-01-15 13:59 184
    nolocale-test PRIVATE FMT_STATIC_THOUSANDS_SEPARATOR=1)
a0630906 Poul Sander 2022-01-15 13:59 185
endif ()
a0630906 Poul Sander 2022-01-15 13:59 186
a0630906 Poul Sander 2022-01-15 13:59 187
# These tests are disabled on Windows because they take too long.
47fd5c32 Poul Sander 2024-10-05 08:44 188
# They are disabled on GCC < 4.9 because it can not parse UDLs without
47fd5c32 Poul Sander 2024-10-05 08:44 189
# a space after `operator""` but that is an incorrect syntax for any more
47fd5c32 Poul Sander 2024-10-05 08:44 190
# modern compiler.
47fd5c32 Poul Sander 2024-10-05 08:44 191
if (FMT_PEDANTIC AND NOT WIN32 AND NOT (
47fd5c32 Poul Sander 2024-10-05 08:44 192
    CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
47fd5c32 Poul Sander 2024-10-05 08:44 193
    CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9))
a0630906 Poul Sander 2022-01-15 13:59 194
  # Test if incorrect API usages produce compilation error.
a0630906 Poul Sander 2022-01-15 13:59 195
  add_test(compile-error-test ${CMAKE_CTEST_COMMAND}
a0630906 Poul Sander 2022-01-15 13:59 196
    --build-and-test
a0630906 Poul Sander 2022-01-15 13:59 197
    "${CMAKE_CURRENT_SOURCE_DIR}/compile-error-test"
a0630906 Poul Sander 2022-01-15 13:59 198
    "${CMAKE_CURRENT_BINARY_DIR}/compile-error-test"
a0630906 Poul Sander 2022-01-15 13:59 199
    --build-generator ${CMAKE_GENERATOR}
a0630906 Poul Sander 2022-01-15 13:59 200
    --build-makeprogram ${CMAKE_MAKE_PROGRAM}
a0630906 Poul Sander 2022-01-15 13:59 201
    --build-options
a0630906 Poul Sander 2022-01-15 13:59 202
    "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
a0630906 Poul Sander 2022-01-15 13:59 203
    "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
a0630906 Poul Sander 2022-01-15 13:59 204
    "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
47fd5c32 Poul Sander 2024-10-05 08:44 205
    "-DCXX_STANDARD_FLAG=${CXX_STANDARD_FLAG}"
47fd5c32 Poul Sander 2024-10-05 08:44 206
    "-DFMT_DIR=${CMAKE_SOURCE_DIR}")
a0630906 Poul Sander 2022-01-15 13:59 207
a0630906 Poul Sander 2022-01-15 13:59 208
  # Test if the targets are found from the build directory.
a0630906 Poul Sander 2022-01-15 13:59 209
  add_test(find-package-test ${CMAKE_CTEST_COMMAND}
a0630906 Poul Sander 2022-01-15 13:59 210
    -C ${CMAKE_BUILD_TYPE}
a0630906 Poul Sander 2022-01-15 13:59 211
    --build-and-test
a0630906 Poul Sander 2022-01-15 13:59 212
    "${CMAKE_CURRENT_SOURCE_DIR}/find-package-test"
a0630906 Poul Sander 2022-01-15 13:59 213
    "${CMAKE_CURRENT_BINARY_DIR}/find-package-test"
a0630906 Poul Sander 2022-01-15 13:59 214
    --build-generator ${CMAKE_GENERATOR}
a0630906 Poul Sander 2022-01-15 13:59 215
    --build-makeprogram ${CMAKE_MAKE_PROGRAM}
a0630906 Poul Sander 2022-01-15 13:59 216
    --build-options
a0630906 Poul Sander 2022-01-15 13:59 217
    "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
a0630906 Poul Sander 2022-01-15 13:59 218
    "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
a0630906 Poul Sander 2022-01-15 13:59 219
    "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
a0630906 Poul Sander 2022-01-15 13:59 220
    "-DFMT_DIR=${PROJECT_BINARY_DIR}"
a0630906 Poul Sander 2022-01-15 13:59 221
    "-DPEDANTIC_COMPILE_FLAGS=${PEDANTIC_COMPILE_FLAGS}"
a0630906 Poul Sander 2022-01-15 13:59 222
    "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
a0630906 Poul Sander 2022-01-15 13:59 223
a0630906 Poul Sander 2022-01-15 13:59 224
  # Test if the targets are found when add_subdirectory is used.
a0630906 Poul Sander 2022-01-15 13:59 225
  add_test(add-subdirectory-test ${CMAKE_CTEST_COMMAND}
a0630906 Poul Sander 2022-01-15 13:59 226
    -C ${CMAKE_BUILD_TYPE}
a0630906 Poul Sander 2022-01-15 13:59 227
    --build-and-test
a0630906 Poul Sander 2022-01-15 13:59 228
    "${CMAKE_CURRENT_SOURCE_DIR}/add-subdirectory-test"
a0630906 Poul Sander 2022-01-15 13:59 229
    "${CMAKE_CURRENT_BINARY_DIR}/add-subdirectory-test"
a0630906 Poul Sander 2022-01-15 13:59 230
    --build-generator ${CMAKE_GENERATOR}
a0630906 Poul Sander 2022-01-15 13:59 231
    --build-makeprogram ${CMAKE_MAKE_PROGRAM}
a0630906 Poul Sander 2022-01-15 13:59 232
    --build-options
a0630906 Poul Sander 2022-01-15 13:59 233
    "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
a0630906 Poul Sander 2022-01-15 13:59 234
    "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
a0630906 Poul Sander 2022-01-15 13:59 235
    "-DPEDANTIC_COMPILE_FLAGS=${PEDANTIC_COMPILE_FLAGS}"
a0630906 Poul Sander 2022-01-15 13:59 236
    "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
a0630906 Poul Sander 2022-01-15 13:59 237
endif ()
a0630906 Poul Sander 2022-01-15 13:59 238
47fd5c32 Poul Sander 2024-10-05 08:44 239
# This test is disabled on Windows because it is POSIX-specific.
a0630906 Poul Sander 2022-01-15 13:59 240
if (FMT_PEDANTIC AND NOT WIN32)
a0630906 Poul Sander 2022-01-15 13:59 241
  add_test(static-export-test ${CMAKE_CTEST_COMMAND}
a0630906 Poul Sander 2022-01-15 13:59 242
    -C ${CMAKE_BUILD_TYPE}
a0630906 Poul Sander 2022-01-15 13:59 243
    --build-and-test
a0630906 Poul Sander 2022-01-15 13:59 244
    "${CMAKE_CURRENT_SOURCE_DIR}/static-export-test"
a0630906 Poul Sander 2022-01-15 13:59 245
    "${CMAKE_CURRENT_BINARY_DIR}/static-export-test"
a0630906 Poul Sander 2022-01-15 13:59 246
    --build-generator ${CMAKE_GENERATOR}
a0630906 Poul Sander 2022-01-15 13:59 247
    --build-makeprogram ${CMAKE_MAKE_PROGRAM}
a0630906 Poul Sander 2022-01-15 13:59 248
    --build-options
a0630906 Poul Sander 2022-01-15 13:59 249
    "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
a0630906 Poul Sander 2022-01-15 13:59 250
    "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
a0630906 Poul Sander 2022-01-15 13:59 251
    "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
a0630906 Poul Sander 2022-01-15 13:59 252
endif ()
a0630906 Poul Sander 2022-01-15 13:59 253
a0630906 Poul Sander 2022-01-15 13:59 254
# Activate optional CUDA tests if CUDA is found. For version selection see
a0630906 Poul Sander 2022-01-15 13:59 255
# https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#cpp14-language-features
a0630906 Poul Sander 2022-01-15 13:59 256
if (FMT_CUDA_TEST)
a0630906 Poul Sander 2022-01-15 13:59 257
  if (${CMAKE_VERSION} VERSION_LESS 3.15)
a0630906 Poul Sander 2022-01-15 13:59 258
    find_package(CUDA 9.0)
a0630906 Poul Sander 2022-01-15 13:59 259
  else ()
a0630906 Poul Sander 2022-01-15 13:59 260
    include(CheckLanguage)
a0630906 Poul Sander 2022-01-15 13:59 261
    check_language(CUDA)
a0630906 Poul Sander 2022-01-15 13:59 262
    if (CMAKE_CUDA_COMPILER)
a0630906 Poul Sander 2022-01-15 13:59 263
      enable_language(CUDA OPTIONAL)
a0630906 Poul Sander 2022-01-15 13:59 264
      set(CUDA_FOUND TRUE)
a0630906 Poul Sander 2022-01-15 13:59 265
    endif ()
a0630906 Poul Sander 2022-01-15 13:59 266
  endif ()
a0630906 Poul Sander 2022-01-15 13:59 267
a0630906 Poul Sander 2022-01-15 13:59 268
  if (CUDA_FOUND)
a0630906 Poul Sander 2022-01-15 13:59 269
    add_subdirectory(cuda-test)
a0630906 Poul Sander 2022-01-15 13:59 270
    add_test(NAME cuda-test COMMAND fmt-in-cuda-test)
a0630906 Poul Sander 2022-01-15 13:59 271
  endif ()
a0630906 Poul Sander 2022-01-15 13:59 272
endif ()
1970-01-01 00:00 273