MantisBT - CMake
View Issue Details
0015404CMakeCMakepublic2015-02-12 05:172015-07-08 08:57
Gunnar Roth 
Brad King 
normalminoralways
closedfixed 
windows cewindows ceall
CMake 3.1.2 
CMake 3.3CMake 3.3 
0015404: cmake dos not set CMAKE_RC_FLAGS to include the platform defines like WIN32_WCE UNDER_CE etc.
when people use things like
#idef UNDER_CE in the .rc files it is not recognised as being defined
because cmake dos not set CMAKE_RC_FLAGS to include the platform defines like WIN32_WCE UNDER_CE etc.


my proposal is to patch windows-msvc.cmake like this:
   set(_RTC1 "")
   set(_FLAGS_CXX " /GR /EHsc")
   set(CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib")
   set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:oldnames.lib")
-
+ set(CMAKE_RC_FLAGS "${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_C}")
+
   if (MSVC_VERSION LESS 1600)
     set(CMAKE_C_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT} corelibc.lib")
   endif ()


i had the task to report this issue on my list for a very long time now.
finally done.
No tags attached.
related to 0014552closed Brad King testCCompiler for WinCE ARMV4I and NMake generator fails with linker error 
Issue History
2015-02-12 05:17Gunnar RothNew Issue
2015-02-12 13:07Brad KingNote Added: 0037960
2015-02-12 13:11Brad KingNote Added: 0037961
2015-02-12 13:25Gunnar RothNote Added: 0037962
2015-02-13 09:47Brad KingRelationship addedrelated to 0014552
2015-02-25 11:40Brad KingNote Added: 0038068
2015-02-25 11:41Brad KingAssigned To => Brad King
2015-02-25 11:41Brad KingStatusnew => resolved
2015-02-25 11:41Brad KingResolutionopen => fixed
2015-02-25 11:41Brad KingFixed in Version => CMake 3.3
2015-02-25 11:41Brad KingTarget Version => CMake 3.3
2015-07-08 08:57Robert MaynardNote Added: 0039064
2015-07-08 08:57Robert MaynardStatusresolved => closed

Notes
(0037960)
Brad King   
2015-02-12 13:07   
Good catch. Unfortunately this may be a symptom of a larger problem. The CMAKE_<LANG>_FLAGS variables are supposed to be cache entries that the user can set locally. Platform information modules are supposed to initialize them by setting CMAKE_<LANG>_FLAGS_INIT. This is done for C and CXX with the platform definitions. However, the enable_language(RC) call appears before C or CXX is fully enabled or the platform definitions are computed, so CMAKE_RC_FLAGS_INIT has already been used to initialize CMAKE_RC_FLAGS.

Fixing this will require reorganizing the way RC gets auto-enabled by C or CXX to be delayed until after the platform definitions are known.
(0037961)
Brad King   
2015-02-12 13:11   
Re 0015404:0037960: Meanwhile you can work around the problem locally by setting CMAKE_RC_FLAGS in your cache to contain the proper definitions.
(0037962)
Gunnar Roth   
2015-02-12 13:25   
hi brad,
setting this myself would be cumbersome because of many cmake base projects. i also do not want to know the correct values to set, this is cmake task ;-)

actually patching windows-msvc.cmake does the trick, we have cmake icheckin n our scs, and use this to build all the projects, so we can easily maintain patches to cmake module.

i now remember that tried CMAKE_RC_FLAGS_INIT as a natural way to solve the probem, but that did not work for the reason you wrote.

in a wide context this
+ set(CMAKE_RC_FLAGS "${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_C}")
maybe a hack, instead it should be
+ set(CMAKE_RC_FLAGS_INIT "${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_C}")
but i see n harm in doing it like that as it makes cmake unusable for wince because windows ce rc headers for mfc already use the #ifdef UNDER_CE , so get an error compiling rc files saying this is not for the desktop version of windows. when i make a workaround in one project this does not help other user of cmake. they will have some hard hours to figure the problem.

ok so maybe never use cmake with ce and mfc projects besides us...
(0038068)
Brad King   
2015-02-25 11:40   
I've re-ordered things so that CMAKE_RC_FLAGS_INIT can be set properly:

 RC: Drop unused CMAKE_COMPILE_RESOURCE variable setting
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1de4a0fb [^]

 RC: Enable language after C, CXX, or Fortran is enabled
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4300de3e [^]

 RC: Add platform-specific preprocessor definitions
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=772eae44 [^]
(0039064)
Robert Maynard   
2015-07-08 08:57   
Closing resolved issues that have not been updated in more than 4 months.