File CMakeLists.txt changed (mode: 100644) (index 1993ea3..d2bfaae) |
... |
... |
if(JRF_STATIC) |
106 |
106 |
endif() |
endif() |
107 |
107 |
|
|
108 |
108 |
|
|
109 |
|
option(JRF_NATIVE "Enable non-portable compiling optimizations" ON) |
|
110 |
|
if (JRF_NATIVE) |
|
111 |
|
message(NOTICE "JRF_NATIVE is enabled, compiling for native arch.") |
|
112 |
|
endif() |
|
|
109 |
|
# |
|
110 |
|
# COMPILE_OPTIONS |
|
111 |
|
# |
|
112 |
|
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" |
|
113 |
|
AND |
|
114 |
|
NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
|
115 |
|
message("JRF: Unknown compiler ${CMAKE_CXX_COMPILER_ID}\ |
|
116 |
|
, cannot specify compilation flags") |
|
117 |
|
else() |
113 |
118 |
|
|
114 |
|
option(JRF_FORCE_OPTIMIZATIONS |
|
115 |
|
"Enen \"-O3\" even when CMAKE_BUILD_TYPE=\"Debug\"" ON |
|
116 |
|
) |
|
117 |
|
if (NOT JRF_FORCE_OPTIMIZATIONS) |
|
118 |
|
message( |
|
119 |
|
"JRF: WARNING!!" |
|
120 |
|
"Wavefront .obj file importing without optimizations will be very slow." |
|
|
119 |
|
option(JRF_FORCE_OPTIMIZATIONS |
|
120 |
|
"Enen \"-O3\" even when CMAKE_BUILD_TYPE=\"Debug\"" ON |
121 |
121 |
) |
) |
122 |
|
endif() |
|
123 |
|
|
|
124 |
|
set(EXPORT_NAME jrf-${PROJECT_VERSION}) |
|
|
122 |
|
if (NOT JRF_FORCE_OPTIMIZATIONS) |
|
123 |
|
message( |
|
124 |
|
"JRF: WARNING!!" |
|
125 |
|
"Wavefront .obj file importing without optimizations will be very slow." |
|
126 |
|
) |
|
127 |
|
endif() |
125 |
128 |
|
|
126 |
|
foreach(TARGET ${TARGETS}) |
|
127 |
|
target_include_directories(jrf-${TARGET} PUBLIC |
|
128 |
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
|
129 |
|
$<INSTALL_INTERFACE:include/${EXPORT_NAME}> |
|
|
129 |
|
list(APPEND COMPILE_OPTIONS |
|
130 |
|
$<$<CONFIG:DEBUG>:-g3;-ggdb> |
|
131 |
|
$<$<CONFIG:RELWITHDEBINFO>:-g3;-ggdb> |
130 |
132 |
) |
) |
131 |
|
target_link_libraries(jrf-${TARGET} PUBLIC jlib-${TARGET} ${ZIP_LIB}) |
|
132 |
|
set_target_properties(jrf-${TARGET} PROPERTIES OUTPUT_NAME jrf) |
|
133 |
|
|
|
134 |
133 |
if (JRF_FORCE_OPTIMIZATIONS) |
if (JRF_FORCE_OPTIMIZATIONS) |
135 |
|
target_compile_options(jrf-${TARGET} PRIVATE -O3 |
|
136 |
|
$<$<CONFIG:DEBUG>:-g3;-ggdb> |
|
137 |
|
$<$<CONFIG:RELWITHDEBINFO>:-g3;-ggdb> |
|
|
134 |
|
list(APPEND COMPILE_OPTIONS |
|
135 |
|
-O3 |
138 |
136 |
) |
) |
139 |
137 |
else() |
else() |
140 |
|
target_compile_options(jrf-${TARGET} PRIVATE |
|
141 |
|
$<$<CONFIG:DEBUG>:-O0;-g3;-ggdb> |
|
|
138 |
|
list(APPEND COMPILE_OPTIONS |
|
139 |
|
$<$<CONFIG:DEBUG>:-O0> |
142 |
140 |
$<$<CONFIG:RELEASE>:-O3> |
$<$<CONFIG:RELEASE>:-O3> |
143 |
|
$<$<CONFIG:RELWITHDEBINFO>:-O3;-g3;-ggdb> |
|
|
141 |
|
$<$<CONFIG:RELWITHDEBINFO>:-O3> |
144 |
142 |
) |
) |
145 |
143 |
endif() |
endif() |
146 |
|
target_compile_features(jrf-${TARGET} PUBLIC cxx_std_17) |
|
|
144 |
|
# warnings |
147 |
145 |
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
148 |
|
target_compile_options(jrf-${TARGET} PRIVATE |
|
|
146 |
|
list(APPEND COMPILE_OPTIONS |
149 |
147 |
-Weverything |
-Weverything |
150 |
148 |
-Wno-c++98-compat-pedantic |
-Wno-c++98-compat-pedantic |
151 |
149 |
-Wno-c++11-compat-pedantic |
-Wno-c++11-compat-pedantic |
|
... |
... |
foreach(TARGET ${TARGETS}) |
156 |
154 |
) |
) |
157 |
155 |
endif() |
endif() |
158 |
156 |
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
159 |
|
target_compile_options(jrf-${TARGET} PRIVATE -Wall -Wextra) |
|
|
157 |
|
list(APPEND COMPILE_OPTIONS -Wall -Wextra) |
160 |
158 |
endif() |
endif() |
|
159 |
|
|
|
160 |
|
option(JRF_NATIVE "Enable non-portable compiling optimizations" ON) |
161 |
161 |
if (JRF_NATIVE) |
if (JRF_NATIVE) |
162 |
|
target_compile_options(jrf-${TARGET} PRIVATE -march=native) |
|
163 |
|
endif() |
|
164 |
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" |
|
165 |
|
OR |
|
166 |
|
CMAKE_CXX_COMPILER_ID STREQUAL "GCC") |
|
167 |
|
target_compile_options(jrf-${TARGET} |
|
168 |
|
PRIVATE -fno-exceptions -fno-rtti -ffast-math |
|
|
162 |
|
message(STATUS |
|
163 |
|
"JRF_NATIVE=ON - jrf will be compiled with optimizations for current CPU" |
169 |
164 |
) |
) |
|
165 |
|
list(APPEND COMPILE_OPTIONS -march=native) |
170 |
166 |
endif() |
endif() |
171 |
167 |
|
|
|
168 |
|
# disable exceptions, rtti, slow legacy C-math |
|
169 |
|
list(APPEND COMPILE_OPTIONS -fno-exceptions -fno-rtti -ffast-math) |
|
170 |
|
endif() |
|
171 |
|
# |
|
172 |
|
# end COMPILE_OPTIONS |
|
173 |
|
# |
|
174 |
|
|
|
175 |
|
set(EXPORT_NAME jrf-${PROJECT_VERSION}) |
|
176 |
|
|
|
177 |
|
foreach(TARGET ${TARGETS}) |
|
178 |
|
target_include_directories(jrf-${TARGET} PUBLIC |
|
179 |
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
|
180 |
|
$<INSTALL_INTERFACE:include/${EXPORT_NAME}> |
|
181 |
|
) |
|
182 |
|
target_link_libraries(jrf-${TARGET} PUBLIC jlib-${TARGET} ${ZIP_LIB}) |
|
183 |
|
set_target_properties(jrf-${TARGET} PROPERTIES OUTPUT_NAME jrf) |
|
184 |
|
|
|
185 |
|
target_compile_features(jrf-${TARGET} PUBLIC cxx_std_17) |
|
186 |
|
target_compile_options(jrf-${TARGET} PRIVATE ${COMPILE_OPTIONS}) |
|
187 |
|
|
172 |
188 |
if (IS_TOP_LEVEL) |
if (IS_TOP_LEVEL) |
173 |
189 |
install(TARGETS jrf-${TARGET} |
install(TARGETS jrf-${TARGET} |
174 |
190 |
DESTINATION lib |
DESTINATION lib |
|
... |
... |
option(JRF_TOOL "Enable jrftool" ON) |
233 |
249 |
if (JRF_TOOL) |
if (JRF_TOOL) |
234 |
250 |
add_executable(jrftool src/tool.cpp) |
add_executable(jrftool src/tool.cpp) |
235 |
251 |
|
|
236 |
|
option(JRF_TOOL_FORCE_OPTIMIZATIONS |
|
237 |
|
"Enen \"-O3\" even when CMAKE_BUILD_TYPE=\"Debug\"" OFF |
|
238 |
|
) |
|
239 |
|
if (JRF_TOOL_FORCE_OPTIMIZATIONS) |
|
240 |
|
target_compile_options(jrftool PRIVATE -O3 |
|
241 |
|
$<$<CONFIG:DEBUG>:-g3;-ggdb> |
|
242 |
|
$<$<CONFIG:RELWITHDEBINFO>:-g3;-ggdb> |
|
243 |
|
) |
|
244 |
|
else() |
|
245 |
|
target_compile_options(jrftool PRIVATE |
|
246 |
|
$<$<CONFIG:DEBUG>:-O0;-g3;-ggdb> |
|
247 |
|
$<$<CONFIG:RELEASE>:-O3> |
|
248 |
|
$<$<CONFIG:RELWITHDEBINFO>:-O3;-g3;-ggdb> |
|
249 |
|
) |
|
250 |
|
endif() |
|
251 |
|
|
|
252 |
252 |
if (JRF_SHARED) |
if (JRF_SHARED) |
253 |
|
target_link_libraries(jrftool PRIVATE jrf-shared jlib-shared) |
|
|
253 |
|
target_link_libraries(jrftool jrf-shared jlib-shared) |
254 |
254 |
elseif(JRF_STATIC) |
elseif(JRF_STATIC) |
255 |
|
target_link_libraries(jrftool PRIVATE jrf-static jlib-static) |
|
|
255 |
|
target_link_libraries(jrftool jrf-static jlib-static) |
256 |
256 |
endif() |
endif() |
257 |
257 |
|
|
258 |
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
|
259 |
|
target_compile_options(jrftool PRIVATE |
|
260 |
|
-Weverything |
|
261 |
|
-Wno-c++98-compat-pedantic |
|
262 |
|
-Wno-c++11-compat-pedantic |
|
263 |
|
-Wno-c++14-compat-pedantic |
|
264 |
|
-Wno-binary-literal |
|
265 |
|
-Wno-padded |
|
266 |
|
-Wno-switch-enum |
|
267 |
|
) |
|
268 |
|
endif() |
|
269 |
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
|
270 |
|
target_compile_options(jrftool PRIVATE -Wall -Wextra) |
|
271 |
|
endif() |
|
272 |
|
|
|
273 |
|
if (JRT_NATIVE) |
|
274 |
|
target_compile_options(jrftool PRIVATE -march=native) |
|
275 |
|
endif() |
|
276 |
|
|
|
277 |
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" |
|
278 |
|
OR |
|
279 |
|
CMAKE_CXX_COMPILER_ID STREQUAL "GCC") |
|
280 |
|
target_compile_options(jrftool PRIVATE -fno-exceptions -fno-rtti -ffast-math) |
|
281 |
|
elseif() |
|
282 |
|
message(FATAL_ERROR "Unrecognized compiler") |
|
283 |
|
endif() |
|
|
258 |
|
target_compile_features(jrftool PRIVATE cxx_std_17) |
|
259 |
|
target_compile_options(jrftool PRIVATE ${COMPILE_OPTIONS}) |
284 |
260 |
|
|
285 |
261 |
option(JRF_TOOL_LTO "Enable LTO" ON) |
option(JRF_TOOL_LTO "Enable LTO" ON) |
286 |
|
if (JRF_TOOL_LTO AND CMAKE_BUILD_TYPE STREQUAL Release) |
|
|
262 |
|
if (JRF_TOOL_LTO) |
|
263 |
|
message(STATUS |
|
264 |
|
"JRF_TOOL_LTO=ON - build jrftool with link-time optimization" |
|
265 |
|
) |
287 |
266 |
set_property(TARGET jrftool APPEND_STRING PROPERTY LINK_FLAGS -flto) |
set_property(TARGET jrftool APPEND_STRING PROPERTY LINK_FLAGS -flto) |
288 |
267 |
target_compile_options(jrftool PRIVATE -flto) |
target_compile_options(jrftool PRIVATE -flto) |
289 |
|
message(STATUS "LTO is enabled") |
|
290 |
268 |
endif() |
endif() |
291 |
269 |
|
|
292 |
270 |
set_target_properties(jrftool PROPERTIES SUFFIX "-${PROJECT_VERSION}") |
set_target_properties(jrftool PROPERTIES SUFFIX "-${PROJECT_VERSION}") |
293 |
|
set(EXPORT_NAME jrftool-${PROJECT_VERSION}) |
|
294 |
271 |
install(TARGETS jrftool EXPORT jrf-config) |
install(TARGETS jrftool EXPORT jrf-config) |
295 |
272 |
endif() |
endif() |