Hi, list!
I want write a PrecompiledHeader.cmake to support PCH for QtCreator.
For now, It works well use MSVC, see:
https://codereview.qt-project.org/#change,34052
I have some trouble with how to get GCC's compile flags / definitions /
include_directories.
My way (does not work yet):


> macro(get_gcc_compile_flags target flags)
>     string(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" name)
>     set(flags "${${name}} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILER_ARG1}")
>     get_target_property(value ${target} COMPILE_FLAGS)
>     if (value)
>         list(APPEND flags ${value})
>     endif()
>     get_target_property(value ${target} TYPE)
>     get_target_property(value ${target} COMPILE_DEFINITIONS)
>     if (value)
>         foreach(item ${value})
>             list(APPEND flags "-D${item}")
>         endforeach()
>     endif()
>     STRING(TOUPPER "COMPILE_DEFINITIONS_${CMAKE_BUILD_TYPE}" name)
>     get_target_property(value ${target} ${name})
>     if (value)
>         foreach(item ${value})
>             list(APPEND flags "-D${item}")
>         endforeach()
>     endif()
>     get_directory_property(value DEFINITIONS)
>     if (value)
>         list(APPEND flags ${value})
>     endif()
>     get_directory_property(value INCLUDE_DIRECTORIES)
>     if (value)
>         foreach(item ${value})
>             list(APPEND flags "-I${item}")
>         endforeach()
>     endif()
>     #separate_arguments(flags)
> endmacro()
>

Any help or comments are welcome!
Thanks!

-- 
Best Regards
Yuchen
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to