<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>Hi,</div>
<div> </div>
<div>I'm using the following function to setup precompiled headers for unix. The goal is to extract all flags and definitions from the current target and add them to the command line for compiling the precompiled header.</div>
<div> </div>
<div>function(export_all_flags _filename)<br/>
set(_include_directories "$<TARGET_PROPERTY:${_target},INCLUDE_DIRECTORIES>")<br/>
set(_compile_definitions "$<TARGET_PROPERTY:${_target},COMPILE_DEFINITIONS>")<br/>
set(_compile_flags "$<TARGET_PROPERTY:${_target},COMPILE_FLAGS>")<br/>
set(_compile_options "$<TARGET_PROPERTY:${_target},COMPILE_OPTIONS>")<br/>
set(_include_directories "$<$<BOOL:${_include_directories}>:-I$<JOIN:${_include_directories},\n-I>\n>")<br/>
set(_compile_definitions "$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions},\n-D>\n>")<br/>
set(_compile_flags "$<$<BOOL:${_compile_flags}>:$<JOIN:${_compile_flags},\n>\n>")<br/>
set(_compile_options "$<$<BOOL:${_compile_options}>:$<JOIN:${_compile_options},\n>\n>")<br/>
file(GENERATE OUTPUT "${_filename}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}\n")<br/>
endfunction()</div>
<div> </div>
<div>The problem is, I set CMAKE_CXX_STANDARD to sth above 11 which will result in -std=gnu++11 being set in any of my target's compilation units. However the appropriate flag isn't captured by the above function. It seems like the flag is added after the function runs (I call it after add_executable or add_library) or not being visible to query on the target at all. What's an appropriate solution here?</div>
<div> </div>
<div>Thanks</div></div></body></html>