MantisBT - CMake
View Issue Details
0012644CMakeModulespublic2011-12-31 09:172012-09-03 16:01
Bernd Lörwald 
Clinton Stimpson 
normalminoralways
closedfixed 
AppleMac OSX10.7.2
CMake 2.8.6 
CMake 2.8.8CMake 2.8.8 
0012644: Modules/Qt4Macros.cmake: qt4_create_translation: missing include paths
The macro does not give lupdate the include paths given in the makefile, therefore lupdate produces warnings like "Qualifying with unknown namespace/class ::Foo" and possibly bad files. lupdate needs the class definition to not throw these warnings.
As found in the attachment:

./CMakeLists.txt
./src/foo.cpp
./src/foo.h

CMakeLists:
...
include_directories (${CMAKE_CURRENT_SOURCE_DIR}) # ./

qt4_create_translation (QM_FILES ${SOURCE} ${TRANSLATIONS})
qt4_add_translation (QM ${TRANSLATIONS})
...

src/foo.cpp:
#include <src/foo.h>
...
void Foo::greet() const
{
 qDebug() << tr ("greeting");
}
...

[ 20%] Generating ../translation.ts
src/foo.cpp:8: Qualifying with unknown namespace/class ::Foo
The macro uses an temporary .pro file "CMakeFiles/translation_lupdate.pro". This includes only "SOURCES=../src/foo.cpp", while it should also include "INCLUDEPATH=..".

To fix this, do:
- FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}")
+ # TODO: get paths into ${include_paths}
+ SET(_pro_includes)
+ FOREACH(_pro_include ${include_paths})
+ GET_FILENAME_COMPONENT(_abs_include "${CMAKE_BINARY_DIR}/${_pro_include}" ABSOLUTE)
+ SET(_pro_includes "${_pro_includes} \"${_abs_include}\"")
+ ENDFOREACH(_pro_include ${CMAKE_CXX_INCLUDE_PATH})
+ FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}\nINCLUDEPATH = ${_pro_includes}\n")

I do not know how to get the include paths though. That's for you to fix.
qt
zip lupdate_example.zip (2,477) 2011-12-31 09:17
https://public.kitware.com/Bug/file/4152/lupdate_example.zip
Issue History
2011-12-31 09:17Bernd LörwaldNew Issue
2011-12-31 09:17Bernd LörwaldFile Added: lupdate_example.zip
2011-12-31 09:20Bernd LörwaldTag Attached: qt
2011-12-31 09:26Bernd LörwaldNote Added: 0028080
2012-01-02 13:24Brad KingAssigned To => Clinton Stimpson
2012-01-02 13:24Brad KingStatusnew => assigned
2012-02-08 21:02Clinton StimpsonNote Added: 0028536
2012-02-08 21:02Clinton StimpsonStatusassigned => resolved
2012-02-08 21:02Clinton StimpsonResolutionopen => fixed
2012-04-19 15:43David ColeFixed in Version => CMake 2.8.8
2012-04-19 15:43David ColeTarget Version => CMake 2.8.8
2012-09-03 16:01David ColeNote Added: 0030871
2012-09-03 16:01David ColeStatusresolved => closed

Notes
(0028080)
Bernd Lörwald   
2011-12-31 09:26   
Still present in 2.8.7.
(0028536)
Clinton Stimpson   
2012-02-08 21:02   
7a6d279 FindQt4: Add include directories for lupdate.
(0030871)
David Cole   
2012-09-03 16:01   
Closing resolved issues that have not been updated in more than 4 months.