<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'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 "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" name)<br> set(flags "${${name}} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILER_ARG1}")<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 "-D${item}")<br> endforeach()<br> endif()<br> STRING(TOUPPER "COMPILE_DEFINITIONS_${CMAKE_BUILD_TYPE}" name)<br> get_target_property(value ${target} ${name})<br>
if (value)<br> foreach(item ${value})<br> list(APPEND flags "-D${item}")<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 "-I${item}")<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>