View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0010503 | CMake | CMake | public | 2010-04-01 19:14 | 2010-04-09 20:18 | ||||
Reporter | Conrad | ||||||||
Assigned To | |||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | closed | Resolution | fixed | ||||||
Platform | OS | OS Version | |||||||
Product Version | CMake-2-8 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0010503: In Visual Studio 2010 custom rules need absolute paths, not relative | ||||||||
Description | Perhaps something has changed in Visual Studio 2010 - I added clear std::cout statements in cmake.cxx's cmakeCheckStampFile() and cmakeCheckStampList() functions to show the current directory, and sometimes custom rules get executed from within a directory other than the main directory in which the .vcxproj file resides. Custom targets often fail because CMake generates rules that assume that the commands are being executed from within the .vcxproj directory. (We use Qt and we have project files that pull in source files from other directories. The custom build rules generated by FindQt4.cmake / UseQt.cmake first cd to the location of the file and then run moc/uic. Sometimes these commands fail, and perhaps Visual Studio doesn't reset the current directory before moving on to the next command?) The fix is to generate custom commands that use absolute paths. Change one line in cmLocalVisualStudioGenerator::ConstructScript() from: script += this->Convert(workingDirectory, START_OUTPUT, SHELL); to: script += this->Convert(workingDirectory, FULL, SHELL); and change one line in cmLocalVisualStudio7Generator::CreateVCProjBuildRule() from: commandLine.push_back(stampName.c_str()); to: std::string stampFilename = this->Convert(stampName.c_str(), FULL, SHELL); commandLine.push_back(stampFilename.c_str()); This solves the problem. | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | ![]() ![]() | ||||||||
Relationships | |
Relationships |
Notes | |
(0020060) Brad King (manager) 2010-04-02 09:26 |
Interesting. If one were using a stand-alone .vcxproj file distributed with the source tree, how would one write custom commands that work wherever the user extracts the source tarball? This looks like a fairly significant bug in VS to me. Can you reproduce it in a small stand-alone .vcxproj file? |
(0020062) Conrad (reporter) 2010-04-02 13:07 |
(Argh, I typed a long comment, then uploaded a file, now my comment is gone. This time I'll be more concise...) - Unzip CMakeVS2010DirectoryTest.zip - CMake it for VS 2010 - Open it in VS 2010 - Look at "CMake Rules" -- Note they start with "cd someCode; ..." (cd to relative directory) - Build Solution - Get errors like this: 1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Debug Win32 ------ 1> Checking Build System 1> CMake does not need to re-run because CMakeFiles/generate.stamp is up-to-date. 2>------ Rebuild All started: Project: CMakeVS2010DirectoryTest, Configuration: Debug Win32 ------ 2> Generating ui_someCode.h 2> Generating ui_someMoreCode.h 2> Generating someCode/moc_someCode.cxx 2>E:/Stellar/Controlled/CMakeVS2010DirectoryTest/someCode/someCode.h : warning : No relevant classes found. No output generated. 2> Generating someMoreCode/moc_someMoreCode.cxx 2> The system cannot find the path specified. 2> moc: Cannot open options file specified with @ 2> Usage: moc [options] <header-file> 2> -o<file> write output to file rather than stdout 2> -I<dir> add dir to the include path for header files 2> -E preprocess only; do not generate meta object code 2> -D<macro>[=<def>] define macro, with optional definition 2> -U<macro> undefine macro 2> -i do not generate an #include statement 2> -p<path> path prefix for included file 2> -f[<file>] force #include, optional file name 2> -nw do not display warnings 2> @<file> read additional options from file 2> -v display version of moc 2> Building Custom Rule E:/Stellar/Controlled/CMakeVS2010DirectoryTest/CMakeLists.txt 2> CMake is re-running because CMakeFiles/generate.stamp dependency file is missing. 2> -- Configuring done 2> -- Generating done 2> -- Build files have been written to: E:/Stellar/Controlled/CMakeVS2010DirectoryTest-BuildArea 2> main.cpp 2> moc_someCode.cxx 2> moc_someMoreCode.cxx 2>c1xx : fatal error C1083: Cannot open source file: 'someMoreCode\moc_someMoreCode.cxx': No such file or directory 2> Generating Code... 3>------ Skipped Rebuild All: Project: ALL_BUILD, Configuration: Debug Win32 ------ 3>Project not selected to build for this solution configuration ========== Rebuild All: 1 succeeded, 1 failed, 1 skipped ========== ========== Rebuild All: 1 succeeded, 1 failed, 1 skipped ========== - If you keep building multiple times, eventually it will work as all the derived files get built - So to test it again, make sure you "Rebuild Solution" or "Clean Solution" first Sometimes CMake regenerates the project unnecessarily. To debug what / why, I enhanced some existing CMake std::cout statements to show the current directory and path to the file that forced the rebuild. I find it handy and it suggest adding it to CMake as well. It's in: 0001-Improve-clarity-of-messages-that-get-printed-when-CM.patch However, you only want the cmake.cxx part of that patch. (The cmSystemTools.cxx part of the patch was broken at the time and has since been improved... Basically that tweak causes RenameFile to keep .bak versions of every file so I can diff them - that helped me see why Visual Studio kept forcing me to reload projects... Probably not something you want permanently in CMake however.) Thanks for looking into this! |
(0020063) Bill Hoffman (manager) 2010-04-02 14:19 |
The full path change fixes two tests that have been failing on VS 2010 since the RC came out. I have committed to master. |
(0020116) Bill Hoffman (manager) 2010-04-09 20:18 |
This is in master now, thanks. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2010-04-01 19:14 | Conrad | New Issue | |
2010-04-02 09:26 | Brad King | Note Added: 0020060 | |
2010-04-02 12:39 | Conrad | File Added: CMakeVS2010DirectoryTest.zip | |
2010-04-02 12:55 | Conrad | File Added: 0001-Improve-clarity-of-messages-that-get-printed-when-CM.patch | |
2010-04-02 13:07 | Conrad | Note Added: 0020062 | |
2010-04-02 14:19 | Bill Hoffman | Note Added: 0020063 | |
2010-04-09 20:18 | Bill Hoffman | Note Added: 0020116 | |
2010-04-09 20:18 | Bill Hoffman | Status | new => closed |
2010-04-09 20:18 | Bill Hoffman | Resolution | open => fixed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |