Skip to content

Commit d03e1c1

Browse files
committed
take into account the new compile features option
1 parent abf7141 commit d03e1c1

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

cmake/LLVMIRUtil.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ function(llvmir_attach_bc_target OUT_TRGT IN_TRGT)
5656
# includes
5757
llvmir_extract_include_dirs_properties(IN_INCLUDES ${IN_TRGT})
5858

59+
# language standards flags
60+
llvmir_extract_standard_flags(IN_STANDARD_FLAGS ${IN_TRGT})
61+
5962
# compile options
6063
llvmir_extract_compile_option_properties(IN_COMPILE_OPTIONS ${IN_TRGT})
6164

@@ -86,8 +89,9 @@ function(llvmir_attach_bc_target OUT_TRGT IN_TRGT)
8689
debug("@llvmir_attach_bc_target ${IN_TRGT} compile flags: \
8790
${CURRENT_COMPILE_FLAGS}")
8891

89-
set(CMD_ARGS "-emit-llvm" ${IN_LANG_FLAGS} ${IN_COMPILE_OPTIONS}
90-
${CURRENT_COMPILE_FLAGS} ${CURRENT_DEFS} ${IN_INCLUDES})
92+
set(CMD_ARGS "-emit-llvm" ${IN_STANDARD_FLAGS} ${IN_LANG_FLAGS}
93+
${IN_COMPILE_OPTIONS} ${CURRENT_COMPILE_FLAGS} ${CURRENT_DEFS}
94+
${IN_INCLUDES})
9195

9296
add_custom_command(OUTPUT ${FULL_OUT_LLVMIR_FILE}
9397
COMMAND ${LLVMIR_COMPILER}

cmake/LLVMIRUtilInternal.cmake

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,49 @@ function(llvmir_extract_lang_flags out_lang_flags lang)
244244
endfunction()
245245

246246

247+
function(llvmir_extract_standard_flags out_standard_flags trgt)
248+
set(standard_flags "")
249+
250+
get_property(std TARGET ${trgt} PROPERTY C_STANDARD)
251+
get_property(req TARGET ${trgt} PROPERTY C_EXTENSIONS)
252+
253+
if(std)
254+
if(req)
255+
set(cflag "gnu")
256+
else()
257+
set(cflag "std")
258+
endif()
259+
260+
set(cflag "${flag}c${std}")
261+
endif()
262+
263+
get_property(std TARGET ${trgt} PROPERTY CXX_STANDARD)
264+
get_property(req TARGET ${trgt} PROPERTY CXX_EXTENSIONS)
265+
266+
if(std)
267+
if(req)
268+
set(cxxflag "gnu")
269+
else()
270+
set(cxxflag "std")
271+
endif()
272+
273+
set(cxxflag "${flag}c++${std}")
274+
endif()
275+
276+
if(cflag)
277+
set(standard_flags "-std=${cflag}")
278+
endif()
279+
280+
if(cxxflag)
281+
set(standard_flags "-std=${cxxflag}")
282+
endif()
283+
284+
debug("@llvmir_extract_standard_flags ${lang}: ${standard_flags}")
285+
286+
set(${out_standard_flags} ${standard_flags} PARENT_SCOPE)
287+
endfunction()
288+
289+
247290
function(llvmir_extract_compile_flags out_compile_flags from)
248291
#message(DEPRECATION "COMPILE_FLAGS property is deprecated.")
249292

0 commit comments

Comments
 (0)