[Development] How to get all compile flags / definitions / include_directories of target?
Loaden
loaden at gmail.com
Tue Sep 4 05:41:31 CEST 2012
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120904/6a28b8c4/attachment.html>
More information about the Development
mailing list