[CMake] CMake, precompiled headers, Apple, gcc and Qt
Dieter Oberkofler
doberkofler.lists at gmail.com
Fri Oct 1 06:26:30 EDT 2010
Hi!
I'm (once again) struggling with the creation of precompiled headers in
conjunction with gcc and Qt on the Apple platform.
When creating my precompiled header I use a code section based on
"PCHSupport_26.cmake" to extract the compile flags as follows:
----------
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
SET(_args ${CMAKE_CXX_FLAGS} ${${_flags_var_name}})
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES ) FOREACH(_item ${DIRINC})
LIST(APPEND _args "-I${_item}")
ENDFOREACH(_item)
GET_DIRECTORY_PROPERTY(_defines_global COMPILE_DEFINITIONS) LIST(APPEND
defines ${_defines_global}) STRING(TOUPPER
"COMPILE_DEFINITIONS_${CMAKE_BUILD_TYPE}" _defines_for_build_name)
GET_DIRECTORY_PROPERTY(defines_build ${_defines_for_build_name}) LIST(APPEND
_defines ${_defines_build}) FOREACH(_item ${_defines})
LIST(APPEND _args "-D${_item}")
ENDFOREACH(_item ${_defines})
LIST(APPEND _args -c ${CMAKE_CURRENT_SOURCE_DIR}/${PRECOMPILED_HEADER} -o
${_gch_filename})
SEPARATE_ARGUMENTS(_args)
----------
Unfortunately the above compiler flags miss two important parameter that
CMake does generate when using the build-in compiler rules:
"-DQT_DEBUG"
and when compiling with the generated precompiled header, I get errors as
follows:
file.h: not used because `QT_DEBUG' is defined.
I would need your help with the following:
1) Is the above way to retrieve the compiler flags correct ?
2) Is there a better, easier, simpler way to do this ?
3) Why does -DQT_DEBUG not show up in COMPILE_DEFINITIONS or
COMPILE_DEFINITIONS_${CMAKE_BUILD_TYPE}
Thank you for your help in advance.
D
More information about the CMake
mailing list