|
Notes |
|
|
(0021816)
|
|
Clinton Stimpson
|
|
2010-08-18 19:41
|
|
Can you provide a way to reproduce that doesn't happen "occasionally" ??
I don't see this problem. |
|
|
|
(0021889)
|
|
dyle
|
|
2010-08-23 05:10
|
|
Well, in this example it fails always on all MOC files. But I can't send you the sources since the are IPR of my company.
OTOH: I may insert some "message" statements in Qt4Macros.cmake to show up the content of some variables which might help. Which and where? |
|
|
|
(0021916)
|
|
dyle
|
|
2010-08-24 08:27
|
|
Ok. I've added
message(STATUS "_moc_outfile_dir: ${_moc_outfile_dir}")
message(STATUS "_moc_working_dir: ${_moc_working_dir}")
to the Qt4Macros.cmake. Now the QT4_CREATE_MOC_COMMAND looks like this:
# helper macro to set up a moc rule
MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options)
# For Windows, create a parameters file to work around command line length limit
IF (WIN32)
# Pass the parameters in a file. Set the working directory to
# be that containing the parameters file and reference it by
# just the file name. This is necessary because the moc tool on
# MinGW builds does not seem to handle spaces in the path to the
# file given with the @ syntax.
GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME)
GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH)
IF(_moc_outfile_dir)
SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
ENDIF(_moc_outfile_dir)
message(STATUS "_moc_outfile_dir: ${_moc_outfile_dir}")
message(STATUS "_moc_working_dir: ${_moc_working_dir}")
SET (_moc_parameters_file ${outfile}_parameters)
SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
FILE (REMOVE ${_moc_parameters_file})
FOREACH(arg ${_moc_parameters})
FILE (APPEND ${_moc_parameters_file} "${arg}\n")
ENDFOREACH(arg)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
DEPENDS ${infile}
${_moc_working_dir}
VERBATIM)
ELSE (WIN32)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
DEPENDS ${infile})
ENDIF (WIN32)
ENDMACRO (QT4_CREATE_MOC_COMMAND)
This gives, having 3 files to moc:
-- Looking for Q_WS_MAC - not found.
-- Found Qt-Version 4.6.3 (using C:/Qt/2010.04/qt/bin/qmake.exe)
-- _moc_outfile_dir:
-- _moc_working_dir:
-- _moc_outfile_dir:
-- _moc_working_dir:
-- _moc_outfile_dir:
-- _moc_working_dir:
-- Configuring done
-- Generating done
-- Build files have been written to: C:/data/smanbe/src/pc/build
C:\data\smanbe\src\pc\build>dir ../bin
Parameter format not correct - "bin".
C:\data\smanbe\src\pc\build>dir ..\bin
Volume in drive C has no label.
Volume Serial Number is 38F2-3666
Directory of C:\data\smanbe\src\pc\bin
24.08.2010 13:09 <DIR> .
24.08.2010 13:09 <DIR> ..
24.08.2010 12:56 1.743 CMakeLists.txt
24.08.2010 12:56 <DIR> core
24.08.2010 12:56 4.238 Environment.cpp
24.08.2010 12:56 1.516 Environment.h
24.08.2010 12:56 <DIR> gui
24.08.2010 12:56 1.500 main.cpp
24.08.2010 13:09 476 MainWidget_moc.cpp_parameters
24.08.2010 13:09 476 MainWindow_moc.cpp_parameters
24.08.2010 13:09 480 ZoomerWidget_moc.cpp_parameters
7 File(s) 10.429 bytes
4 Dir(s) 11.809.521.664 bytes free
Note the 3 files: MainWidget_moc.cpp_parameters, MainWindow_moc.cpp_parameters and ZoomerWidget_moc.cpp_parameters in the source folder (../bin). |
|
|
|
(0021919)
|
|
Clinton Stimpson
|
|
2010-08-24 13:19
|
|
Are you using QT4_GENERATE_MOC without giving it an absolute path for the outfile.
In other words, are you doing something like this
qt4_generate_moc(myfile.h myfile.moc)
instead of
qt4_generate_moc(myfile.h ${CMAKE_CURRENT_BINARY_DIR}/myfile.moc)
unless you specify absolute paths, files are relative to the source dir. |
|
|
|
(0021920)
|
|
Clinton Stimpson
|
|
2010-08-24 13:25
|
|
|
For further debugging, can you print out ${outfile} and ${CMAKE_CURRENT_BINARY_DIR}? |
|
|
|
(0021921)
|
|
dyle
|
|
2010-08-24 13:30
|
|
Well, the CMakeLists.txt for this particular part is
--- 8< ---
# ------------------------------------------------------------
# CMakeLists.txt
#
# make: smanbe-pc/bin
# desc: project root
#
# Author: Oliver Maurhart <oliver.maurhart@ait.ac.at>
#
# Copyright (C) 2010, AIT Austrian Institute of Technology
# ------------------------------------------------------------
# ------------------------------------------------------------
# sources and linkage
# define all necessary project include folders
include_directories(
.
..
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
)
# define the sources
set(SMANBE_PC_SRC
core/AbsoluteFilter.cpp
core/BlackWhiteFilter.cpp
core/CopyFilter.cpp
core/DiskBlurFilter.cpp
core/EdgeDetectionFilter.cpp
core/Filter.cpp
core/FilterChain.cpp
core/GaussBlurFilter.cpp
core/LookupTable.cpp
core/MeanBoxBlurFilter.cpp
core/Pixel.cpp
core/PixelMatrix.cpp
core/PointDetectionFilter.cpp
core/PrewittFilter.cpp
core/Smanbe.cpp
core/crc32.c
gui/MainWidget.cpp
gui/MainWindow.cpp
gui/ZoomerWidget.cpp
Environment.cpp
main.cpp
)
# invoke moc
QT4_GENERATE_MOC(gui/MainWidget.h MainWidget_moc.cpp)
QT4_GENERATE_MOC(gui/MainWindow.h MainWindow_moc.cpp)
QT4_GENERATE_MOC(gui/ZoomerWidget.h ZoomerWidget_moc.cpp)
set(SMANBE_PC_MOC
MainWidget_moc.cpp
MainWindow_moc.cpp
ZoomerWidget_moc.cpp
)
# ------------------------------------------------------------
# binary
add_executable(smanbe ${SMANBE_PC_SRC} ${SMANBE_PC_MOC})
set_target_properties(smanbe PROPERTIES VERSION ${VERSION})
target_link_libraries(smanbe ${CMAKE_REQUIRED_LIBRARIES} ${QT_LIBRARIES})
install(TARGETS smanbe RUNTIME DESTINATION bin)
--- >8 ---
As far I understand the QT4_GENERATE_MOC statements I use above should create the files in the BINARY folder and not in the SOURCE folder, shouldn't they?
Further debug follows ... mom ... |
|
|
|
(0021922)
|
|
dyle
|
|
2010-08-24 13:46
|
|
Ok, I've added output with
It gives:
...
-- Found Qt-Version 4.6.3 (using C:/Qt/2010.04/qt/bin/qmake.exe)
-- _moc_outfile_dir:
-- _moc_working_dir:
-- outfile: MainWidget_moc.cpp
-- CMAKE_CURRENT_BINARY_DIR: C:/data/smanbe/src/pc/build/bin
-- _moc_outfile_dir:
-- _moc_working_dir:
-- outfile: MainWindow_moc.cpp
-- CMAKE_CURRENT_BINARY_DIR: C:/data/smanbe/src/pc/build/bin
-- _moc_outfile_dir:
-- _moc_working_dir:
-- outfile: ZoomerWidget_moc.cpp
-- CMAKE_CURRENT_BINARY_DIR: C:/data/smanbe/src/pc/build/bin
-- Configuring done
-- Generating done
-- Build files have been written to: C:/data/smanbe/src/pc/build
Obviously the CMAKE_CURRENT_BINARY_DIR is correct. But the moc here uses a parameter file, and this one is created in the CMAKE_CURRENT_SOURCE_DIR. Also: it is created during the call to 'cmake -G "MinGW Makefiles" ..' in the build folder and not during "make" itself.
Running now "make" presents the error above:
C:\data\smanbe\src\pc\build>make
[ 3%] Generating ZoomerWidget_moc.cpp
moc: Cannot open options file specified with @
Usage: moc [options] <header-file>
-o<file> write output to file rather than stdout
-I<dir> add dir to the include path for header files
-E preprocess only; do not generate meta object code
-D<macro>[=<def>] define macro, with optional definition
-U<macro> undefine macro
-i do not generate an #include statement
-p<path> path prefix for included file
-f[<file>] force #include, optional file name
-nw do not display warnings
@<file> read additional options from file
-v display version of moc
make[2]: *** [bin/ZoomerWidget_moc.cpp] Error 1
make[1]: *** [bin/CMakeFiles/smanbe.dir/all] Error 2
make: *** [all] Error 2
Moving these parameters files into build/bin (BINARY) resolves the issue:
C:\data\smanbe\src\pc\build>make
[ 3%] Generating ZoomerWidget_moc.cpp
[ 7%] Generating MainWidget_moc.cpp
[ 11%] Generating MainWindow_moc.cpp
Scanning dependencies of target smanbe
[ 14%] Building CXX object bin/CMakeFiles/smanbe.dir/core/AbsoluteFilter.cpp.obj
[ 18%] Building CXX object bin/CMakeFiles/smanbe.dir/core/BlackWhiteFilter.cpp.obj
...
But it is not after this moving step the final *_moc.cpp files are created. Well these final *_moc.cpp files are created just fine. On the very correct location. No error with that. It's these *_parameters files which are placed at the very wrong location. |
|
|
|
(0021923)
|
|
Clinton Stimpson
|
|
2010-08-24 13:48
|
|
You can work around this issue by doing
QT4_GENERATE_MOC(gui/MainWidget.h ${CMAKE_CURRENT_BINARY_DIR}/MainWidget_moc.cpp)
instead of
QT4_GENERATE_MOC(gui/MainWidget.h MainWidget_moc.cpp)
I'll work on fixing it so you can do either one. |
|
|
|
(0021924)
|
|
dyle
|
|
2010-08-24 13:49
|
|
To clarify:
It's
- MainWidget_moc.cpp_parameters
- MainWindow_moc.cpp_parameters
- ZoomerWidget_moc.cpp_parameters
Which are created during the "cmake .." step in the SOURCE folder.
- MainWidget_moc.cpp
- MainWindow_moc.cpp
- ZoomerWidget_moc.cpp
Created and compiled in the "make" step are fine. But this won't go in the first place, since the Qt moc is run in the BINARY folder and doesn't find those *_moc.cpp_parameters files. |
|
|
|
(0021925)
|
|
dyle
|
|
2010-08-24 13:52
|
|
Oh,
QT4_GENERATE_MOC(gui/MainWidget.h ${CMAKE_CURRENT_BINARY_DIR}/MainWidget_moc.cpp)
worked. Good.
But I wonder what differs? Since the _moc.cpp has been correctly created in this folder before. o.O |
|
|
|
(0021926)
|
|
Clinton Stimpson
|
|
2010-08-24 13:55
|
|
Yes. I know that and was able to reproduce.
Feel free to try the workaround until it is fixed. |
|
|
|
(0021927)
|
|
Clinton Stimpson
|
|
2010-08-24 13:57
|
|
|
The _moc.cpp is created correctly because add_custom_command handles relative paths for an output file, whereas qt4_generate_moc doesn't when it creates the parameters file. |
|
|
|
(0021928)
|
|
dyle
|
|
2010-08-24 14:12
|
|
Ah, ok.
One thing to add/mention: this occurs only on Windows machines. The very same code on Linux doesn't have this issue. There the moc creation works out-of-the-box. |
|
|
|
(0021930)
|
|
Clinton Stimpson
|
|
2010-08-24 14:43
|
|
|