Skip to content

Commit

Permalink
take into account the new compile features option
Browse files Browse the repository at this point in the history
  • Loading branch information
compor committed Apr 25, 2017
1 parent abf7141 commit d03e1c1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmake/LLVMIRUtil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ function(llvmir_attach_bc_target OUT_TRGT IN_TRGT)
# includes
llvmir_extract_include_dirs_properties(IN_INCLUDES ${IN_TRGT})

# language standards flags
llvmir_extract_standard_flags(IN_STANDARD_FLAGS ${IN_TRGT})

# compile options
llvmir_extract_compile_option_properties(IN_COMPILE_OPTIONS ${IN_TRGT})

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

set(CMD_ARGS "-emit-llvm" ${IN_LANG_FLAGS} ${IN_COMPILE_OPTIONS}
${CURRENT_COMPILE_FLAGS} ${CURRENT_DEFS} ${IN_INCLUDES})
set(CMD_ARGS "-emit-llvm" ${IN_STANDARD_FLAGS} ${IN_LANG_FLAGS}
${IN_COMPILE_OPTIONS} ${CURRENT_COMPILE_FLAGS} ${CURRENT_DEFS}
${IN_INCLUDES})

add_custom_command(OUTPUT ${FULL_OUT_LLVMIR_FILE}
COMMAND ${LLVMIR_COMPILER}
Expand Down
43 changes: 43 additions & 0 deletions cmake/LLVMIRUtilInternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,49 @@ function(llvmir_extract_lang_flags out_lang_flags lang)
endfunction()


function(llvmir_extract_standard_flags out_standard_flags trgt)
set(standard_flags "")

get_property(std TARGET ${trgt} PROPERTY C_STANDARD)
get_property(req TARGET ${trgt} PROPERTY C_EXTENSIONS)

if(std)
if(req)
set(cflag "gnu")
else()
set(cflag "std")
endif()

set(cflag "${flag}c${std}")
endif()

get_property(std TARGET ${trgt} PROPERTY CXX_STANDARD)
get_property(req TARGET ${trgt} PROPERTY CXX_EXTENSIONS)

if(std)
if(req)
set(cxxflag "gnu")
else()
set(cxxflag "std")
endif()

set(cxxflag "${flag}c++${std}")
endif()

if(cflag)
set(standard_flags "-std=${cflag}")
endif()

if(cxxflag)
set(standard_flags "-std=${cxxflag}")
endif()

debug("@llvmir_extract_standard_flags ${lang}: ${standard_flags}")

set(${out_standard_flags} ${standard_flags} PARENT_SCOPE)
endfunction()


function(llvmir_extract_compile_flags out_compile_flags from)
#message(DEPRECATION "COMPILE_FLAGS property is deprecated.")

Expand Down

0 comments on commit d03e1c1

Please sign in to comment.