<div>Hi, list!</div>
<div>I want write a PrecompiledHeader.cmake to support PCH for QtCreator.</div>
<div>For now, It works well use MSVC, see: <a href="https://codereview.qt-project.org/#change,34052">https://codereview.qt-project.org/#change,34052</a><br clear="all">I have some trouble with how to get GCC&#39;s compile flags / definitions / include_directories.</div>


<div>My way (does not work yet):</div>
<div> </div>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
<div>macro(get_gcc_compile_flags target flags)<br>    string(TOUPPER &quot;CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}&quot; name)<br>    set(flags &quot;${${name}} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILER_ARG1}&quot;)<br>    get_target_property(value ${target} COMPILE_FLAGS)<br>

    if (value)<br>        list(APPEND flags ${value})<br>    endif()<br>    get_target_property(value ${target} TYPE)<br>    get_target_property(value ${target} COMPILE_DEFINITIONS)<br>    if (value)<br>        foreach(item ${value})<br>

            list(APPEND flags &quot;-D${item}&quot;)<br>        endforeach()<br>    endif()<br>    STRING(TOUPPER &quot;COMPILE_DEFINITIONS_${CMAKE_BUILD_TYPE}&quot; name)<br>    get_target_property(value ${target} ${name})<br>

    if (value)<br>        foreach(item ${value})<br>            list(APPEND flags &quot;-D${item}&quot;)<br>        endforeach()<br>    endif()<br>    get_directory_property(value DEFINITIONS)<br>    if (value)<br>        list(APPEND flags ${value})<br>

    endif()<br>    get_directory_property(value INCLUDE_DIRECTORIES)<br>    if (value)<br>        foreach(item ${value})<br>            list(APPEND flags &quot;-I${item}&quot;)<br>        endforeach()<br>    endif()<br>    #separate_arguments(flags)<br>

endmacro()</div></blockquote>
<div> </div>
<div>Any help or comments are welcome!</div>
<div>Thanks!</div>
<div><br>-- <br>Best Regards</div>
<div>Yuchen</div><br>