MantisBT - CMake
View Issue Details
0015013CMakeCMakepublic2014-07-10 12:052016-06-06 16:40
Gunnar Roth 
Brad King 
urgentmajoralways
closedfixed 
wec2013wec20138.00
CMake 3.0 
CMake 3.1CMake 3.1 
0015013: subsystem windowsce is not set for dll only for exes, this makes dll not loadable on wec2013 (wince8)
the subsystem switch for the linker is only set for executables but not for dlls.
this was no problem for ce < wec2013. but wec2013 checks for correct subsystem. you can see this informations using depends.exe from dependancywalker.com
compile a project containg a dll with a wec2013 sdk. this dll will not be loaded on wec2013.
this problem can be fixed with this simple patch:

--- a\share\cmake-3.0\Modules/Platform/Windows-MSVC.cmake
+++ b\share\cmake-3.0\Modules/Platform/Windows-MSVC.cmake
@@ -37,12 +37,13 @@
 endif()
 
 set(WIN32 1)
 
 if(CMAKE_SYSTEM_NAME MATCHES "WindowsCE")
- set(CMAKE_CREATE_WIN32_EXE "/subsystem:windowsce /entry:WinMainCRTStartup")
- set(CMAKE_CREATE_CONSOLE_EXE "/subsystem:windowsce /entry:mainACRTStartup")
+ set(CMAKE_CREATE_WIN32_EXE "/entry:WinMainCRTStartup")
+ set(CMAKE_CREATE_CONSOLE_EXE "/entry:mainACRTStartup")
+ set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} /subsystem:windowsce")
   set(WINCE 1)
 else()
   set(CMAKE_CREATE_WIN32_EXE "/subsystem:windows")
   set(CMAKE_CREATE_CONSOLE_EXE "/subsystem:console")
 endif()


CMAKE_EXE_LINKER_FLAGS_INIT is inherited by the dll settings but CMAKE_CREATE_WIN32_EXE or CMAKE_CREATE_CONSOLE_EXE is of course not.
No tags attached.
patch 0001-MSVC-Fix-linking-of-DLLs-on-WinCE-15013.patch (3,350) 2014-07-10 15:13
https://public.kitware.com/Bug/file/5189/0001-MSVC-Fix-linking-of-DLLs-on-WinCE-15013.patch
Issue History
2014-07-10 12:05Gunnar RothNew Issue
2014-07-10 15:13Brad KingFile Added: 0001-MSVC-Fix-linking-of-DLLs-on-WinCE-15013.patch
2014-07-10 15:14Brad KingNote Added: 0036346
2014-07-10 15:14Brad KingAssigned To => Brad King
2014-07-10 15:14Brad KingStatusnew => assigned
2014-07-10 15:14Brad KingTarget Version => CMake 3.1
2014-07-10 16:00Gunnar RothNote Added: 0036349
2014-07-10 16:17Brad KingNote Added: 0036351
2014-07-10 16:19Brad KingNote Added: 0036352
2014-07-14 09:40Brad KingStatusassigned => resolved
2014-07-14 09:40Brad KingFixed in Version => CMake 3.1
2015-01-05 08:39Robert MaynardNote Added: 0037583
2015-01-05 08:39Robert MaynardStatusresolved => closed
2016-06-06 16:40Brad KingResolutionopen => fixed

Notes
(0036346)
Brad King   
2014-07-10 15:14   
Thanks. Placing it in CMAKE_EXE_LINKER_FLAGS will break existing build trees whose cache entry does not already contain it. Since we must pass the flag to all linker calls we should just do so directly. Please try the attached "0001-MSVC-Fix-linking-of-DLLs-on-WinCE-15013.patch".
(0036349)
Gunnar Roth   
2014-07-10 16:00   
OK this should also work.
I did not know cmake needs to support existing build trees when upgrading the cmake version. This is a hard to test feature methinks. Would it not be easier to Check version of the used cake in the build tree and on mismatch, trigger a complete regeneration? That seems more reliable to me.
(0036351)
Brad King   
2014-07-10 16:17   
I've applied the patch here:

 MSVC: Fix linking of DLLs on WinCE
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7e1283e4 [^]
(0036352)
Brad King   
2014-07-10 16:19   
Re 0015013:0036349: The language init and compiler detection is re-run for each new CMake version. However, we cannot overwrite or wipe out CMakeCache.txt entries that can be user-specified. CMAKE_EXE_LINKER_FLAGS is among those. There is no reason to let users modify/break addition of the subsystem flag for MSVC/WinCE anyway.
(0037583)
Robert Maynard   
2015-01-05 08:39   
Closing resolved issues that have not been updated in more than 4 months