diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeDetermineCompiler.cmake | 13 | ||||
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 48 | ||||
-rw-r--r-- | Modules/CMakeUnixFindMake.cmake | 10 | ||||
-rw-r--r-- | Modules/CompilerId/VS-10.vcxproj.in | 15 | ||||
-rw-r--r-- | Modules/CompilerId/VS-6.dsp.in | 6 | ||||
-rw-r--r-- | Modules/CompilerId/VS-7.vcproj.in | 4 | ||||
-rw-r--r-- | Modules/Platform/Darwin.cmake | 6 | ||||
-rw-r--r-- | Modules/Platform/Windows-MSVC.cmake | 13 |
8 files changed, 79 insertions, 36 deletions
diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index 2d12c07578..f522c4408f 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -69,4 +69,17 @@ macro(_cmake_find_compiler lang) endif() unset(_${lang}_COMPILER_HINTS) unset(_languages) + + # Look for a make tool provided by Xcode + if(CMAKE_${lang}_COMPILER STREQUAL "CMAKE_${lang}_COMPILER-NOTFOUND" AND CMAKE_HOST_APPLE) + foreach(comp ${CMAKE_${lang}_COMPILER_LIST}) + execute_process(COMMAND xcrun --find ${comp} + OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _xcrun_err) + if(_xcrun_out) + set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${_xcrun_out}") + break() + endif() + endforeach() + endif() endmacro() diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index ae91a296a4..ebd9ce0b9c 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -109,12 +109,9 @@ Id flags: ${testflags} # Compile the compiler identification source. if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)") set(vs_version ${CMAKE_MATCH_1}) - set(id_arch ${CMAKE_VS_PLATFORM_NAME}) + set(id_platform ${CMAKE_VS_PLATFORM_NAME}) set(id_lang "${lang}") set(id_cl cl.exe) - if(NOT id_arch) - set(id_arch Win32) - endif() if(NOT "${vs_version}" VERSION_LESS 10) set(v 10) set(ext vcxproj) @@ -126,16 +123,8 @@ Id flags: ${testflags} set(v 6) set(ext dsp) endif() - if("${id_arch}" STREQUAL "x64") - set(id_machine_10 MachineX64) - elseif("${id_arch}" STREQUAL "Itanium") - set(id_machine_10 MachineIA64) - set(id_arch ia64) - elseif("${id_arch}" STREQUAL "ARM") - set(id_machine_10 MachineARM) - else() - set(id_machine_6 x86) - set(id_machine_10 MachineX86) + if("${id_platform}" STREQUAL "Itanium") + set(id_platform ia64) endif() if(CMAKE_VS_PLATFORM_TOOLSET) set(id_toolset "<PlatformToolset>${CMAKE_VS_PLATFORM_TOOLSET}</PlatformToolset>") @@ -149,7 +138,7 @@ Id flags: ${testflags} set(id_subsystem 1) 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) + set(build /p:Configuration=Debug /p:Platform=@id_platform@ /p:VisualStudioVersion=${vs_version}.0) elseif("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Dd][Ee][Vv]") set(build /make) else() @@ -341,6 +330,35 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) endif() endforeach() + # Detect the exact architecture from the PE header. + if(WIN32) + # The offset to the PE signature is stored at 0x3c. + file(READ ${file} peoffsethex LIMIT 1 OFFSET 60 HEX) + string(SUBSTRING "${peoffsethex}" 0 1 peoffsethex1) + string(SUBSTRING "${peoffsethex}" 1 1 peoffsethex2) + set(peoffsetexpression "${peoffsethex1} * 16 + ${peoffsethex2}") + string(REPLACE "a" "10" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "b" "11" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "c" "12" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "d" "13" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "e" "14" peoffsetexpression "${peoffsetexpression}") + string(REPLACE "f" "15" peoffsetexpression "${peoffsetexpression}") + math(EXPR peoffset "${peoffsetexpression}") + + file(READ ${file} peheader LIMIT 6 OFFSET ${peoffset} HEX) + if(peheader STREQUAL "50450000a201") + set(ARCHITECTURE_ID "SH3") + elseif(peheader STREQUAL "50450000a301") + set(ARCHITECTURE_ID "SH3DSP") + elseif(peheader STREQUAL "50450000a601") + set(ARCHITECTURE_ID "SH4") + elseif(peheader STREQUAL "50450000a801") + set(ARCHITECTURE_ID "SH5") + elseif(peheader STREQUAL "50450000c201") + set(ARCHITECTURE_ID "THUMB") + endif() + endif() + # Check if a valid compiler and platform were found. if(COMPILER_ID AND NOT COMPILER_ID_TWICE) set(CMAKE_${lang}_COMPILER_ID "${COMPILER_ID}") diff --git a/Modules/CMakeUnixFindMake.cmake b/Modules/CMakeUnixFindMake.cmake index c75cf7cbc9..3714926570 100644 --- a/Modules/CMakeUnixFindMake.cmake +++ b/Modules/CMakeUnixFindMake.cmake @@ -14,3 +14,13 @@ find_program(CMAKE_MAKE_PROGRAM NAMES gmake make smake) mark_as_advanced(CMAKE_MAKE_PROGRAM) + +# Look for a make tool provided by Xcode +if(NOT CMAKE_MAKE_PROGRAM AND CMAKE_HOST_APPLE) + execute_process(COMMAND xcrun --find make + OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _xcrun_err) + if(_xcrun_out) + set_property(CACHE CMAKE_MAKE_PROGRAM PROPERTY VALUE "${_xcrun_out}") + endif() +endif() diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in index ab4705fa38..1a7a539429 100644 --- a/Modules/CompilerId/VS-10.vcxproj.in +++ b/Modules/CompilerId/VS-10.vcxproj.in @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|@id_arch@"> + <ProjectConfiguration Include="Debug|@id_platform@"> <Configuration>Debug</Configuration> - <Platform>@id_arch@</Platform> + <Platform>@id_platform@</Platform> </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> @@ -12,7 +12,7 @@ <Keyword>Win32Proj</Keyword> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'" Label="Configuration"> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> @id_toolset@ <CharacterSet>MultiByte</CharacterSet> @@ -20,11 +20,11 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <PropertyGroup> <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'">.\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'">$(Configuration)\</IntDir> - <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">.\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">false</LinkIncremental> </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'"> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'"> <ClCompile> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions> @@ -40,7 +40,6 @@ <Link> <GenerateDebugInformation>false</GenerateDebugInformation> <SubSystem>Console</SubSystem> - <TargetMachine>@id_machine_10@</TargetMachine> </Link> <PostBuildEvent> <Command>for %%i in (@id_cl@) do %40echo CMAKE_@id_lang@_COMPILER=%%~$PATH:i</Command> diff --git a/Modules/CompilerId/VS-6.dsp.in b/Modules/CompilerId/VS-6.dsp.in index 4f7e676135..48c9a236ba 100644 --- a/Modules/CompilerId/VS-6.dsp.in +++ b/Modules/CompilerId/VS-6.dsp.in @@ -1,7 +1,7 @@ # Microsoft Developer Studio Project File - Name="CompilerId@id_lang@" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 -# TARGTYPE "Win32 (@id_machine_6@) Application" 0x0101 +# TARGTYPE "Win32 (x86) Application" 0x0101 CFG=CompilerId@id_lang@ - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, @@ -16,7 +16,7 @@ CFG=CompilerId@id_lang@ - Win32 Debug !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE -!MESSAGE "CompilerId@id_lang@ - Win32 Debug" (based on "Win32 (@id_machine_6@) Application") +!MESSAGE "CompilerId@id_lang@ - Win32 Debug" (based on "Win32 (x86) Application") !MESSAGE # Begin Project @@ -29,7 +29,7 @@ CPP=cl.exe # PROP Target_Dir "" # ADD CPP /nologo /MDd /c LINK32=link.exe -# ADD LINK32 /nologo /version:0.0 /subsystem:console /machine:@id_machine_6@ /out:"CompilerId@id_lang@.exe" /IGNORE:4089 +# ADD LINK32 /nologo /version:0.0 /subsystem:console /machine:x86 /out:"CompilerId@id_lang@.exe" /IGNORE:4089 # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Cmds=for %%i in (@id_cl@) do @echo CMAKE_@id_lang@_COMPILER=%%~$PATH:i diff --git a/Modules/CompilerId/VS-7.vcproj.in b/Modules/CompilerId/VS-7.vcproj.in index fa48cadb3f..9e3c3c3ced 100644 --- a/Modules/CompilerId/VS-7.vcproj.in +++ b/Modules/CompilerId/VS-7.vcproj.in @@ -10,12 +10,12 @@ > <Platforms> <Platform - Name="@id_arch@" + Name="@id_platform@" /> </Platforms> <Configurations> <Configuration - Name="Debug|@id_arch@" + Name="Debug|@id_platform@" OutputDirectory="." IntermediateDirectory="$(ConfigurationName)" ConfigurationType="1" diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 865cc8e6de..db8c7ef8b2 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -326,6 +326,12 @@ set(CMAKE_SYSTEM_APPBUNDLE_PATH unset(_apps_paths) include(Platform/UnixPaths) +if(_CMAKE_OSX_SYSROOT_PATH AND EXISTS ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) + list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_CMAKE_OSX_SYSROOT_PATH}/usr) + foreach(lang C CXX) + list(APPEND CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) + endforeach() +endif() list(APPEND CMAKE_SYSTEM_PREFIX_PATH /sw # Fink /opt/local # MacPorts diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 9f97570589..685638a462 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -141,8 +141,12 @@ if(WINCE) set(_RTC1 "") set(_FLAGS_CXX " /GR /EHsc") - set(CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib") + 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") + + if (MSVC_VERSION LESS 1500) + set(CMAKE_C_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT} corelibc.lib") + endif () else() set(_PLATFORM_DEFINES "/DWIN32") @@ -171,13 +175,6 @@ set(_MACHINE_ARCH_FLAG ${MSVC_C_ARCHITECTURE_ID}) if(NOT _MACHINE_ARCH_FLAG) set(_MACHINE_ARCH_FLAG ${MSVC_CXX_ARCHITECTURE_ID}) endif() -if(WINCE) - if(_MACHINE_ARCH_FLAG MATCHES "ARM") - set(_MACHINE_ARCH_FLAG "THUMB") - elseif(_MACHINE_ARCH_FLAG MATCHES "SH") - set(_MACHINE_ARCH_FLAG "SH4") - endif() -endif() set (CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} /machine:${_MACHINE_ARCH_FLAG}") |