MantisBT - CMake
View Issue Details
0014865CMakeCMakepublic2014-04-07 17:422014-10-06 10:33
Kai Pastor 
Brad King 
normalminoralways
closedfixed 
 
CMake 3.0CMake 3.0 
0014865: CMakeDetermineRCCompiler does not detect windres from "i686-w64-mingw32.shared-windres"
CMakeDetermineRCCompiler.cmake uses the name without ending for identifying windres:

GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_RC_COMPILER} NAME_WE)
IF("${CMAKE_BASE_NAME}" MATCHES "windres")
  SET(CMAKE_BASE_NAME "windres")
ENDIF()

This code fails to detect windres when the filename contains the period in the prefix. This is the case e.g. when using a shared-lib cross compilation toolchain from mxe.cc (development version) where windres is named i686-w64-mingw32.shared-windres.

I see that in general the ending needs to be removed from the filename. However, for detecting windres the full filename should be matched.
No tags attached.
Issue History
2014-04-07 17:42Kai PastorNew Issue
2014-04-08 13:22Brad KingNote Added: 0035657
2014-04-08 15:20Kai PastorNote Added: 0035658
2014-04-08 15:37Brad KingNote Added: 0035659
2014-04-09 16:24Kai PastorNote Added: 0035661
2014-04-10 10:21Brad KingNote Added: 0035665
2014-04-10 10:21Brad KingAssigned To => Brad King
2014-04-10 10:21Brad KingStatusnew => resolved
2014-04-10 10:21Brad KingResolutionopen => fixed
2014-04-10 10:21Brad KingFixed in Version => CMake 3.1
2014-04-10 10:21Brad KingTarget Version => CMake 3.1
2014-04-11 09:14Brad KingNote Added: 0035675
2014-04-11 09:14Brad KingFixed in VersionCMake 3.1 => CMake 3.0
2014-04-11 09:14Brad KingTarget VersionCMake 3.1 => CMake 3.0
2014-10-06 10:33Robert MaynardNote Added: 0036967
2014-10-06 10:33Robert MaynardStatusresolved => closed

Notes
(0035657)
Brad King   
2014-04-08 13:22   
I don't think the extension needs to be stripped at all. It will not interfere with matching "windres" as a regex. Please try:

-GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_RC_COMPILER} NAME_WE)
+GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_RC_COMPILER} NAME)
(0035658)
Kai Pastor   
2014-04-08 15:20   
I'm very sorry but I somehow missed the point when I created and named the ticket.

The critical section is in CMakeRCInformation.cmake (which claims to set the basic flags for the Fortran language in CMake, BTW):

get_filename_component(CMAKE_BASE_NAME ${CMAKE_RC_COMPILER} NAME_WE)
if("${CMAKE_BASE_NAME}" MATCHES "windres")
  set(CMAKE_BASE_NAME "windres")
endif()
set(CMAKE_SYSTEM_AND_RC_COMPILER_INFO_FILE
  ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)

What goes wrong for i686-w64-mingw32.shared-windres is including Platform/Windows-windres.cmake which would set the correct CMAKE_RC_COMPILE_OBJECT.

(The reason why I think you may still want to strip the extension is that there might be some other Platform/Windows-ResourceCompiler.cmake which shall be used for ResourceCompiler.exe CMAKE_RC_COMPILER.)
(0035659)
Brad King   
2014-04-08 15:37   
Okay, here is another quick patch (untested):

-get_filename_component(CMAKE_BASE_NAME ${CMAKE_RC_COMPILER} NAME_WE)
-if("${CMAKE_BASE_NAME}" MATCHES "windres")
- set(CMAKE_BASE_NAME "windres")
-endif()
+if(CMAKE_RC_COMPILER MATCHES "windres[^/]*$")
+ set(CMAKE_BASE_NAME "windres")
+else()
+ get_filename_component(CMAKE_BASE_NAME ${CMAKE_RC_COMPILER} NAME_WE)
+endif()
(0035661)
Kai Pastor   
2014-04-09 16:24   
I tested the proposed change to CMakeRCInformation.cmake, and it solves the problem.

(And again, this file's comments reference Fortran...)
(0035665)
Brad King   
2014-04-10 10:21   
Patches applied:

 CMakeRCInformation: Do not mention 'Fortran' in documentation
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=96bc9ecb [^]

 CMakeRCInformation: Recognize 'windres' tools with '.' in name (0014865)
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=613666e1 [^]
(0035675)
Brad King   
2014-04-11 09:14   
Patches backported on v3.0.0-rc3:

 CMakeRCInformation: Do not mention 'Fortran' in documentation
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=db924e00 [^]

 CMakeRCInformation: Recognize 'windres' tools with '.' in name
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7147ed5c [^]

They will be included in v3.0.0-rc4.
(0036967)
Robert Maynard   
2014-10-06 10:33   
Closing resolved issues that have not been updated in more than 4 months.