View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0011120 | CMake | Modules | public | 2010-08-12 04:39 | 2010-11-09 22:57 | ||||
Reporter | dyle | ||||||||
Assigned To | Clinton Stimpson | ||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | closed | Resolution | fixed | ||||||
Platform | OS | OS Version | |||||||
Product Version | CMake-2-8 | ||||||||
Target Version | CMake 2.8.3 | Fixed in Version | CMake 2.8.3 | ||||||
Summary | 0011120: QT4_GENERATE_MOC creates option file in SOURCE folder, resulting in an error: "moc: Cannot open options file specified with @" | ||||||||
Description | This is CMake 2.8.2 running on Windows XP using MinGW. Occasionally the MOC file creation when building a Qt4 project fails with the line "moc: Cannot open options file specified with @". This is due to the fact, that the option files, which are the original source files appended an "_parameters" suffix, are placed in the SOURCE folder and not in the current building folder. Moc can't find them then and bails out. Sample: [code] C:\data\smanbe\build>make VERBOSE=1 "C:\Program Files\CMake 2.8\bin\cmake.exe" -HC:\data\smanbe -BC:\data\smanbe\build --check-build-system CMakeFiles\Makefile.cmake 0 "C:\Program Files\CMake 2.8\bin\cmake.exe" -E cmake_progress_start C:\data\smanbe\build\CMakeFiles C:\data\smanbe\build\CMakeFiles\progress.marks make -f CMakeFiles\Makefile2 all make[1]: Entering directory `C:/data/smanbe/build' make -f bin\CMakeFiles\smanbe.dir\build.make bin/CMakeFiles/smanbe.dir/depend make[2]: Entering directory `C:/data/smanbe/build' "C:\Program Files\CMake 2.8\bin\cmake.exe" -E cmake_progress_report C:\data\smanbe\build\CMakeFiles 28 [ 3%] Generating ZoomerWidget_moc.cpp cd C:\data\smanbe\build\bin && C:\Qt\2010.04\qt\bin\moc.exe @ZoomerWidget_moc.cpp_parameters 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[2]: Leaving directory `C:/data/smanbe/build' make[1]: *** [bin/CMakeFiles/smanbe.dir/all] Error 2 make[1]: Leaving directory `C:/data/smanbe/build' make: *** [all] Error 2 [/code] However the requested file "ZoomerWidget_moc.cpp_parameter" is created at the corresponding SOURCE folder: [code] C:\data\smanbe\build>dir ..\bin\*_parameters Volume in drive C has no label. Volume Serial Number is 38F2-3666 Directory of C:\data\smanbe\bin 12.08.2010 10:23 427 MainWidget_moc.cpp_parameters 12.08.2010 10:23 427 MainWindow_moc.cpp_parameters 12.08.2010 10:23 431 ZoomerWidget_moc.cpp_parameters 3 File(s) 1.285 bytes 0 Dir(s) 11.522.555.904 bytes free [/code] Please fix the macro definition of QT4_GENERATE_MOC in Qt4Macros.cmake | ||||||||
Additional Information | Workaround: manually move those parameters into the corresponding build folder. Them moc is happy again. | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0021816) Clinton Stimpson (developer) 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 (reporter) 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 (reporter) 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 (developer) 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 (developer) 2010-08-24 13:25 |
For further debugging, can you print out ${outfile} and ${CMAKE_CURRENT_BINARY_DIR}? |
(0021921) dyle (reporter) 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 (reporter) 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 (developer) 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 (reporter) 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 (reporter) 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 (developer) 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 (developer) 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 (reporter) 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 (developer) 2010-08-24 14:43 |
Fixed in f11b4dc |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2010-08-12 04:39 | dyle | New Issue | |
2010-08-18 19:41 | Clinton Stimpson | Note Added: 0021816 | |
2010-08-19 15:32 | Alex Neundorf | Category | CMake => Modules |
2010-08-23 05:10 | dyle | Note Added: 0021889 | |
2010-08-24 08:27 | dyle | Note Added: 0021916 | |
2010-08-24 13:19 | Clinton Stimpson | Note Added: 0021919 | |
2010-08-24 13:25 | Clinton Stimpson | Note Added: 0021920 | |
2010-08-24 13:30 | dyle | Note Added: 0021921 | |
2010-08-24 13:46 | dyle | Note Added: 0021922 | |
2010-08-24 13:48 | Clinton Stimpson | Note Added: 0021923 | |
2010-08-24 13:49 | dyle | Note Added: 0021924 | |
2010-08-24 13:52 | dyle | Note Added: 0021925 | |
2010-08-24 13:55 | Clinton Stimpson | Note Added: 0021926 | |
2010-08-24 13:57 | Clinton Stimpson | Note Added: 0021927 | |
2010-08-24 14:12 | dyle | Note Added: 0021928 | |
2010-08-24 14:42 | Clinton Stimpson | Status | new => assigned |
2010-08-24 14:42 | Clinton Stimpson | Assigned To | => Clinton Stimpson |
2010-08-24 14:43 | Clinton Stimpson | Note Added: 0021930 | |
2010-08-24 14:43 | Clinton Stimpson | Status | assigned => resolved |
2010-08-24 14:43 | Clinton Stimpson | Resolution | open => fixed |
2010-09-10 00:11 | David Cole | Fixed in Version | => CMake 2.8.3 |
2010-09-10 00:11 | David Cole | Target Version | => CMake 2.8.3 |
2010-11-09 22:57 | Philip Lowman | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |