MantisBT - CMake
View Issue Details
0015088CMakeCMakepublic2014-08-14 17:452016-06-10 14:31
Frank Miller 
Kitware Robot 
normalminoralways
closedmoved 
Windows7
CMake 3.0.1 
 
0015088: Ninja generator makes an invalid RC_COMPILER rule
When the project() command is used without C language support as in project(myproj CXX), the ninja generator will create a rules.ninja file with an empty string where cmcldeps.exe should be. Something like the following:

    rule RC_COMPILER
      depfile = $DEP_FILE
      deps = gcc
      command = "" RC $in "$DEP_FILE" $out "Note: including file: " "c:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe" c:\PROGRA~2\WI3CF2~1\8.1\bin\x86\rc.exe $FLAGS $DEFINES /fo$out $in
      description = Building RC object $out

The following patch will cause the MFC test to fail

diff --git a/Tests/MFC/CMakeLists.txt.in b/Tests/MFC/CMakeLists.txt.in
index e6bfabd..c1d0754 100644
--- a/Tests/MFC/CMakeLists.txt.in
+++ b/Tests/MFC/CMakeLists.txt.in
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 2.8)
-project(mfc1)
+project(mfc1 CXX)

 macro(replace_flags var these those)
   if("${${var}}" MATCHES "${these}")
This used to work in cmake 2.8.
No tags attached.
has duplicate 0015711closed  Ninja cannot build resource file 
Issue History
2014-08-14 17:45Frank MillerNew Issue
2015-08-26 09:38A. KlitzingNote Added: 0039329
2015-08-27 09:03Brad KingRelationship addedhas duplicate 0015711
2015-08-27 09:04Brad KingNote Added: 0039335
2015-08-27 10:39Brad KingNote Added: 0039338
2016-03-03 15:30Beom KohNote Added: 0040593
2016-03-03 16:00Beom KohNote Added: 0040594
2016-03-07 11:11Brad KingNote Added: 0040636
2016-06-10 14:29Kitware RobotNote Added: 0042608
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0039329)
A. Klitzing   
2015-08-26 09:38   
I had the same problem...

http://public.kitware.com/Bug/view.php?id=15711 [^]
(0039335)
Brad King   
2015-08-27 09:04   
For reference, see 0015711:0039328 in a duplicate of this issue for an explanation.
(0039338)
Brad King   
2015-08-27 10:39   
From 0015711:0039328:
> Ok, I found the problem.
>
> http://www.cmake.org/gitweb?p=cmake.git;a=blob_plain;f=Modules/CMakeClDeps.cmake [^]
>
> It will check and use CMAKE_C_COMPILER only. But there is no
> CMAKE_C_COMPILER for a CXX project. If I change it here in
> CMakeClDeps to CMAKE_CXX_COMPILER it works! Of course... it must
> work for both. ;-)

The CMakeClDeps module is included by "Modules/CMakeDetermine{C,CXX}Compiler.cmake" but hard-codes CMAKE_C_COMPILER as you point out. It needs to be refactored to run once for either C or CXX depending on which is enabled first.
(0040593)
Beom Koh   
2016-03-03 15:30   
Is there a plan to address this issue?
(0040594)
Beom Koh   
2016-03-03 16:00   
I just found that my cmcldeps.exe is generating the resource file in the source tree not the binary tree. Also it has a wrong name. (generated resource file is called "FILENAME.RES" but ninja is failing with the following error "LINK : fatal error LNK1181: cannot open input file 'sft\Mod1\utils\CMakeFiles\Moud1UtilGUI.dir\DiagGui\res\FILENAME.rc.res'"

If I copy "FILENAME.RES" manually to the above folder from source tree with renaming it to "FILENAME.rc.res", the build works.
(0040636)
Brad King   
2016-03-07 11:11   
The problem described in 0015088:0039338 has been addressed as of CMake 3.4 with changes linked in 0015596:0039440. As of 3.5.0-rc3 the MFC test passes for me even with the hack listed in the description here:

  -project(mfc1)
  +project(mfc1 CXX)

I also see the .res file in the right place.

Re 0015088:0040594: What version of CMake are you running and observing the file in the wrong place?
(0042608)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.