@@ -56,11 +56,19 @@ if (CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
56
56
set (PEDANTIC_COMPILE_FLAGS -Wall -Wextra -Wno-long-long -Wno-variadic-macros )
57
57
endif ()
58
58
59
+ function (add_fmt_executable name )
60
+ add_executable (${name} ${ARGN} )
61
+ if (MINGW)
62
+ target_link_libraries (${name} -static -libgcc -static -libstdc++)
63
+ endif ()
64
+ endfunction ()
65
+
59
66
# Adds a test.
60
67
# Usage: add_fmt_test(name srcs...)
61
68
function (add_fmt_test name )
62
- add_executable (${name} ${name} .cc ${ARGN} )
69
+ add_fmt_executable (${name} ${name} .cc ${ARGN} )
63
70
target_link_libraries (${name} test -main)
71
+
64
72
# define if certain c++ features can be used
65
73
target_compile_definitions (${name} PRIVATE
66
74
FMT_USE_TYPE_TRAITS=$<BOOL :${SUPPORTS_TYPE_TRAITS} >
@@ -89,7 +97,7 @@ if (FMT_PEDANTIC AND MSVC)
89
97
endif ()
90
98
91
99
if (HAVE_OPEN)
92
- add_executable (posix-mock-test
100
+ add_fmt_executable (posix-mock-test
93
101
posix-mock-test .cc ../fmt/format.cc ${TEST_MAIN_SRC} )
94
102
target_include_directories (posix-mock-test PRIVATE ${PROJECT_SOURCE_DIR} )
95
103
target_compile_definitions (posix-mock-test PRIVATE FMT_USE_FILE_DESCRIPTORS=1)
@@ -98,7 +106,7 @@ if (HAVE_OPEN)
98
106
add_fmt_test(posix-test )
99
107
endif ()
100
108
101
- add_executable (header-only-test
109
+ add_fmt_executable (header-only-test
102
110
header-only-test .cc header-only-test2.cc test -main.cc)
103
111
target_link_libraries (header-only-test gmock)
104
112
if (TARGET fmt-header-only)
0 commit comments