Browse Source

VS: Make DetermineCompilerId working with WinCE too

Add a dummy mainCRTStartup() function, since the linker searches for
it instead of main() and set the CMAKE_SYSTEM_* variables depending
on the MSVC_C_ARCHITECTURE_ID and CMAKE_VS_WINCE_VERSION variables.
Patrick Gansterer 13 years ago
parent
commit
40c36c9f7b

+ 4 - 0
Modules/CMakeCCompilerId.c.in

@@ -228,3 +228,7 @@ int main(int argc, char* argv[])
   return require;
 }
 #endif
+
+#ifdef ADD_MAINCRTSTARTUP
+void mainCRTStartup() {}
+#endif

+ 4 - 0
Modules/CMakeCXXCompilerId.cpp.in

@@ -210,3 +210,7 @@ int main(int argc, char* argv[])
   (void)argv;
   return require;
 }
+
+#ifdef ADD_MAINCRTSTARTUP
+extern "C" void mainCRTStartup() {}
+#endif

+ 3 - 0
Modules/CMakeDetermineCompilerId.cmake

@@ -140,6 +140,9 @@ Id flags: ${testflags}
     else()
       set(id_toolset "")
     endif()
+    if(CMAKE_VS_WINCE_VERSION)
+      set(id_definitions "ADD_MAINCRTSTARTUP")
+    endif()
     if("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Bb][Uu][Ii][Ll][Dd]")
       set(build /p:Configuration=Debug /p:Platform=@id_arch@ /p:VisualStudioVersion=${vs_version}.0)
     elseif("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Dd][Ee][Vv]")

+ 6 - 0
Modules/CMakeDetermineSystem.cmake

@@ -106,6 +106,12 @@ if(CMAKE_SYSTEM_NAME)
     set(CMAKE_CROSSCOMPILING TRUE)
   endif()
   set(PRESET_CMAKE_SYSTEM_NAME TRUE)
+elseif(CMAKE_VS_WINCE_VERSION)
+  set(CMAKE_SYSTEM_NAME      "WindowsCE")
+  set(CMAKE_SYSTEM_VERSION   "${CMAKE_VS_WINCE_VERSION}")
+  set(CMAKE_SYSTEM_PROCESSOR "${MSVC_C_ARCHITECTURE_ID}")
+  set(CMAKE_CROSSCOMPILING TRUE)
+  set(PRESET_CMAKE_SYSTEM_NAME TRUE)
 else()
   set(CMAKE_SYSTEM_NAME      "${CMAKE_HOST_SYSTEM_NAME}")
   set(CMAKE_SYSTEM_VERSION   "${CMAKE_HOST_SYSTEM_VERSION}")

+ 1 - 1
Modules/CompilerId/VS-7.vcproj.in

@@ -24,7 +24,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				PreprocessorDefinitions=""
+				PreprocessorDefinitions="@id_definitions@"
 				MinimalRebuild="false"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"

+ 6 - 0
Source/cmGlobalVisualStudio8Generator.cxx

@@ -143,6 +143,12 @@ void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf)
 {
   cmGlobalVisualStudio71Generator::AddPlatformDefinitions(mf);
   mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName());
+
+  if(this->TargetsWindowsCE())
+  {
+    mf->AddDefinition("CMAKE_VS_WINCE_VERSION",
+      this->WindowsCEVersion.c_str());
+  }
 }
 
 //----------------------------------------------------------------------------