@@ -17,12 +17,6 @@ function(join result_var)
17
17
set (${result_var} "${result} " PARENT_SCOPE)
18
18
endfunction ()
19
19
20
- set (FMT_USE_CMAKE_MODULES FALSE )
21
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND
22
- CMAKE_GENERATOR STREQUAL "Ninja" )
23
- set (FMT_USE_CMAKE_MODULES TRUE )
24
- endif ()
25
-
26
20
include (CMakeParseArguments)
27
21
28
22
project (ALSOFT_FMT CXX)
@@ -42,10 +36,6 @@ message(STATUS "{fmt} version: ${FMT_VERSION}")
42
36
43
37
message (STATUS "Build type: ${CMAKE_BUILD_TYPE} " )
44
38
45
- if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY )
46
- set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /bin)
47
- endif ()
48
-
49
39
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
50
40
"${CMAKE_CURRENT_SOURCE_DIR} /support/cmake" )
51
41
@@ -60,6 +50,8 @@ function(add_headers VAR)
60
50
set (${VAR} ${headers} PARENT_SCOPE)
61
51
endfunction ()
62
52
53
+ set (ALSOFT_FMT_DEBUG_POSTFIX d CACHE STRING "Debug library postfix." )
54
+
63
55
# Define the fmt library, its includes and the needed defines.
64
56
add_headers(FMT_HEADERS args.h base.h chrono.h color.h compile.h core.h format.h
65
57
format-inl.h os.h ostream.h printf.h ranges.h std.h
@@ -78,15 +70,13 @@ endif ()
78
70
target_include_directories (alsoft.fmt PUBLIC
79
71
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR} /include >)
80
72
81
- set (ALSOFT_FMT_DEBUG_POSTFIX d CACHE STRING "Debug library postfix." )
82
-
83
73
set_target_properties (alsoft.fmt PROPERTIES ${ALSOFT_STD_VERSION_PROPS}
84
74
VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}
85
- PUBLIC_HEADER "${FMT_HEADERS} "
86
75
DEBUG_POSTFIX "${ALSOFT_FMT_DEBUG_POSTFIX} "
87
76
POSITION_INDEPENDENT_CODE TRUE
88
77
C_VISIBILITY_PRESET hidden
89
78
CXX_VISIBILITY_PRESET hidden
79
+ EXCLUDE_FROM_ALL TRUE
90
80
91
81
# Workaround for Visual Studio 2017:
92
82
# Ensure the .pdb is created with the same name and in the same directory
@@ -96,12 +86,35 @@ set_target_properties(alsoft.fmt PROPERTIES ${ALSOFT_STD_VERSION_PROPS}
96
86
COMPILE_PDB_NAME "fmt"
97
87
COMPILE_PDB_NAME_DEBUG "fmt${ALSOFT_FMT_DEBUG_POSTFIX} " )
98
88
99
- add_library (alsoft.fmt-header-only INTERFACE )
89
+
90
+
91
+ add_library (alsoft.fmt-objects OBJECT ${FMT_SOURCES} ${FMT_HEADERS} README.md ChangeLog.md )
92
+ add_library (alsoft::fmt-objects ALIAS alsoft.fmt-objects)
93
+
94
+ if (cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
95
+ target_compile_features (alsoft.fmt-objects PUBLIC cxx_std_11)
96
+ else ()
97
+ message (WARNING "Feature cxx_std_11 is unknown for the CXX compiler" )
98
+ endif ()
99
+
100
+ target_include_directories (alsoft.fmt-objects PUBLIC
101
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR} /include >)
102
+
103
+ set_target_properties (alsoft.fmt-objects PROPERTIES ${ALSOFT_STD_VERSION_PROPS}
104
+ POSITION_INDEPENDENT_CODE TRUE
105
+ C_VISIBILITY_PRESET hidden
106
+ CXX_VISIBILITY_PRESET hidden
107
+ EXCLUDE_FROM_ALL TRUE )
108
+
109
+
110
+
111
+ add_library (alsoft.fmt-header-only INTERFACE EXCLUDE_FROM_ALL )
100
112
add_library (alsoft::fmt-header-only ALIAS alsoft.fmt-header-only)
101
113
102
114
if (MSVC )
103
115
# Unicode support requires compiling with /utf-8.
104
116
target_compile_options (alsoft.fmt PUBLIC $<$<COMPILE_LANGUAGE:CXX>:/utf-8>)
117
+ target_compile_options (alsoft.fmt-objects PUBLIC $<$<COMPILE_LANGUAGE:CXX>:/utf-8>)
105
118
target_compile_options (alsoft.fmt-header-only INTERFACE $<$<COMPILE_LANGUAGE:CXX>:/utf-8>)
106
119
endif ()
107
120
0 commit comments