Skip to content

Commit 8b805e1

Browse files
authored
Merge pull request sakura-editor#1044 from berryzplus/feature/use_windows10_sdk
プロジェクトのビルドにWindows10 SDKを使う
2 parents 897bab3 + 9afa0ae commit 8b805e1

File tree

4 files changed

+60
-52
lines changed

4 files changed

+60
-52
lines changed

tests/googletest.build.cmd

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,24 @@ set CONFIGURATION=%~3
55
set VCVARSALL_PATH=%4
66
set VCVARS_ARCH=%~5
77

8-
if not defined CMD_GIT call %~dp0..\tools\find-tools.bat
9-
if not defined CMD_GIT (
10-
echo git.exe was not found.
11-
endlocal && exit /b 1
12-
)
13-
14-
if not exist "%~dp0googletest\CMakeLists.txt" (
15-
"%CMD_GIT%" submodule init %~dp0googletest || endlocal && exit /b 1
16-
"%CMD_GIT%" submodule update %~dp0googletest || endlocal && exit /b 1
17-
)
18-
198
@rem call vcvasall.bat when we run in the Visual Studio IDE.
209
if defined VCVARSALL_PATH (
2110
call %VCVARSALL_PATH% %VCVARS_ARCH% || endlocal && exit /b 1
2211
)
2312

13+
if not exist CMakeCache.txt (
14+
call :run_cmake_configure
15+
)
16+
17+
cmake --build . --config %CONFIGURATION% || endlocal && exit /b 1
18+
19+
endlocal && exit /b 0
20+
21+
:run_cmake_configure
2422
where ninja.exe > NUL 2>&1
2523
if not errorlevel 1 (
2624
set GENERATOR=Ninja
25+
set GENERATOR_OPTS=-DCMAKE_BUILD_TYPE=%CONFIGURATION%
2726
)
2827

2928
@rem find cl.exe in the PATH
@@ -35,7 +34,7 @@ if not defined CMD_CL (
3534
)
3635
set CMD_CL=%CMD_CL:\=/%
3736

38-
cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
37+
cmake -G "%GENERATOR%" %GENERATOR_OPTS% ^
3938
"-DCMAKE_C_COMPILER=%CMD_CL%" ^
4039
"-DCMAKE_CXX_COMPILER=%CMD_CL%" ^
4140
-DBUILD_GMOCK=OFF ^
@@ -44,9 +43,8 @@ cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
4443
%SOURCE_DIR% ^
4544
|| endlocal && exit /b 1
4645

47-
cmake --build . --config %CONFIGURATION% || endlocal && exit /b 1
46+
goto :EOF
4847

49-
endlocal && exit /b 0
5048

5149
:find_cl_exe
5250
for /f "usebackq delims=" %%a in (`where cl.exe`) do (

tests/googletest.targets

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,67 @@
11
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup Label="GoogleTest">
33
<GoogleTestSourceDir>$(MSBuildThisFileDirectory)googletest\</GoogleTestSourceDir>
4-
<GoogleTestBuildDir>$(MSBuildThisFileDirectory)build\$(Platform)\$(Configuration)\googletest\</GoogleTestBuildDir>
4+
<GoogleTestBuildDir>$(MSBuildThisFileDirectory)build\$(Platform)\$(Configuration)\googletest</GoogleTestBuildDir>
55
<IncludePath>$(GoogleTestSourceDir)googletest\include;$(IncludePath)</IncludePath>
66
<LibraryPath>$(GoogleTestBuildDir)\lib;$(GoogleTestBuildDir)\lib\$(Configuration);$(LibraryPath)</LibraryPath>
7+
<NameSuffix Condition="'$(Configuration)' == 'Debug'">d</NameSuffix>
8+
<NameSuffix Condition="'$(Configuration)' == 'Release'"></NameSuffix>
79
</PropertyGroup>
810
<ItemDefinitionGroup Label="GoogleTest.Requirements">
911
<ClCompile>
1012
<PreprocessorDefinitions>_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
1113
</ClCompile>
1214
</ItemDefinitionGroup>
13-
<ItemDefinitionGroup Label="GoogleTest.Libs" Condition="'$(Configuration)' == 'Debug'">
15+
<ItemDefinitionGroup Label="GoogleTest.Libs">
1416
<Link>
15-
<AdditionalDependencies>gtestd.lib;%(AdditionalDependencies)</AdditionalDependencies>
16-
<AdditionalDependencies>gtest_maind.lib;%(AdditionalDependencies)</AdditionalDependencies>
17+
<AdditionalDependencies>gtest$(NameSuffix).lib;%(AdditionalDependencies)</AdditionalDependencies>
18+
<AdditionalDependencies>gtest_main$(NameSuffix).lib;%(AdditionalDependencies)</AdditionalDependencies>
1719
</Link>
1820
</ItemDefinitionGroup>
19-
<ItemDefinitionGroup Label="GoogleTest.Libs" Condition="'$(Configuration)' == 'Release'">
20-
<Link>
21-
<AdditionalDependencies>gtest.lib;%(AdditionalDependencies)</AdditionalDependencies>
22-
<AdditionalDependencies>gtest_main.lib;%(AdditionalDependencies)</AdditionalDependencies>
23-
</Link>
24-
</ItemDefinitionGroup>
25-
<ItemGroup Label="GoogleTest.Pdbs" Condition="'$(Configuration)' == 'Debug'">
26-
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtestd.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtestd.pdb')" />
27-
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest_maind.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtest_maind.pdb')" />
28-
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtestd.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtestd.pdb')" />
29-
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_maind.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_maind.pdb')" />
30-
</ItemGroup>
31-
<ItemGroup Label="GoogleTest.Pdbs" Condition="'$(Configuration)' == 'Release'">
32-
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtest.pdb')" />
33-
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest_main.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtest_main.pdb')" />
34-
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtest.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtest.pdb')" />
35-
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_main.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_main.pdb')" />
36-
</ItemGroup>
37-
<Target Name="BuildGoogleTest" BeforeTargets="ClCompile">
21+
<Target Name="FindGit" Condition="'$(GitCmd)' == ''">
22+
<Message Text="Checking Git for Windows" Importance="high" />
23+
<Exec Command="where &quot;$(PATH);$(ProgramW6432)\Git\Cmd;$(ProgramFiles)\Git\Cmd:git&quot;" ConsoleToMSBuild="true">
24+
<Output TaskParameter="ConsoleOutput" PropertyName="GitCmd" />
25+
</Exec>
26+
<PropertyGroup>
27+
<GitCmd>$([System.Text.RegularExpressions.Regex]::Replace('$(GitCmd)', '^([^;]+);.*', '$1'))</GitCmd>
28+
</PropertyGroup>
29+
</Target>
30+
<Target Name="UpdateGoogleTest" DependsOnTargets="FindGit" Condition="!Exists('$(GoogleTestSourceDir)\CMakeLists.txt')">
31+
<Exec Command="&quot;$(GitCmd)&quot; submodule init" WorkingDirectory="$(GoogleTestSourceDir)" />
32+
<Exec Command="&quot;$(GitCmd)&quot; submodule update" WorkingDirectory="$(GoogleTestSourceDir)" />
33+
</Target>
34+
<Target Name="MakeGoogleTestBuildDir" Condition="!Exists('$(GoogleTestBuildDir)')">
35+
<MakeDir Directories="$(GoogleTestBuildDir)" />
36+
</Target>
37+
<Target Name="BuildGoogleTest" DependsOnTargets="UpdateGoogleTest;MakeGoogleTestBuildDir" BeforeTargets="ClCompile">
3838
<PropertyGroup>
3939
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'x86' And '$(PlatformTarget)' == 'x86'">x86</VcVarsArchitecture>
4040
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'x86' And '$(PlatformTarget)' == 'x64'">x86_amd64</VcVarsArchitecture>
4141
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'AMD64' And '$(PlatformTarget)' == 'x86'">amd64_x86</VcVarsArchitecture>
4242
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'AMD64' And '$(PlatformTarget)' == 'x64'">amd64</VcVarsArchitecture>
4343
<NumVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(VisualStudioVersion)', '^(\d+).*', '$1'))</NumVersion>
44-
<NextVersion>$([MSBuild]::Add($(NumVersion), 1))</NextVersion>
44+
<ProductLineVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(VisualStudioEdition)', '^.* (\d+).*', '$1'))</ProductLineVersion>
4545
<GeneratorSuffix Condition="'$(PlatformTarget)' == 'x86'"></GeneratorSuffix>
4646
<GeneratorSuffix Condition="'$(PlatformTarget)' == 'x64'"> Win64</GeneratorSuffix>
47+
<VsGeneratorName>Visual Studio $(NumVersion) $(ProductLineVersion)$(GeneratorSuffix)</VsGeneratorName>
4748
</PropertyGroup>
48-
<MakeDir Condition="!Exists('$(GoogleTestBuildDir)')" Directories="$(GoogleTestBuildDir)" />
49-
<Message Text="Cheking product line version of the Visual Studio." Importance="high" />
50-
<Exec Command="&quot;$(VSInstallDir)..\..\Installer\vswhere.exe&quot; -version [$(NumVersion),$(NextVersion)] -property catalog_productLineVersion" ConsoleToMSBuild="true">
51-
<Output TaskParameter="ConsoleOutput" PropertyName="ProductLineVersion" />
52-
</Exec>
53-
<Exec Command="$(MSBuildThisFileDirectory)googletest.build.cmd $(GoogleTestSourceDir) &quot;Visual Studio $(NumVersion) $(ProductLineVersion)$(GeneratorSuffix)&quot; $(Configuration) &quot;$(VSInstallRoot)/VC/Auxiliary/Build/vcvarsall.bat&quot; $(VcVarsArchitecture)" WorkingDirectory="$(GoogleTestBuildDir)" />
49+
<Exec Command="$(MSBuildThisFileDirectory)googletest.build.cmd $(GoogleTestSourceDir) &quot;$(VsGeneratorName)&quot; $(Configuration) &quot;$(VSInstallRoot)/VC/Auxiliary/Build/vcvarsall.bat&quot; $(VcVarsArchitecture)" WorkingDirectory="$(GoogleTestBuildDir)" />
50+
</Target>
51+
<Target Name="CopyGoogleTestPdb" AfterTargets="BuildGoogleTest">
52+
<ItemGroup>
53+
<GoogleTestPdb Include="$(GoogleTestBuildDir)\bin\gtest$(NameSuffix).pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtest$(NameSuffix).pdb')" />
54+
<GoogleTestPdb Include="$(GoogleTestBuildDir)\bin\gtest_main$(NameSuffix).pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtest_main$(NameSuffix).pdb')" />
55+
<GoogleTestPdb Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtest$(NameSuffix).pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtest$(NameSuffix).pdb')" />
56+
<GoogleTestPdb Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_main$(NameSuffix).pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_main$(NameSuffix).pdb')" />
57+
</ItemGroup>
58+
<Copy SourceFiles="@(GoogleTestPdbFound)" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />
5459
</Target>
5560
<Target Name="AppendCleanTargets" BeforeTargets="CoreClean">
5661
<!-- Add files to @Clean just before running CoreClean. -->
5762
<ItemGroup>
58-
<Clean Include="$(OutDir)gtestd.pdb" />
59-
<Clean Include="$(OutDir)gtest_maind.pdb" />
60-
<Clean Include="$(OutDir)gtest.pdb" />
61-
<Clean Include="$(OutDir)gtest_main.pdb" />
63+
<Clean Include="$(OutDir)gtest$(NameSuffix).pdb" />
64+
<Clean Include="$(OutDir)gtest_main$(NameSuffix).pdb" />
6265
</ItemGroup>
6366
<RemoveDir Directories="$(GoogleTestBuildDir)" />
6467
</Target>

tests/unittests/tests1.vcxproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121
<PropertyGroup Label="Globals">
2222
<ProjectGuid>{701e3407-ec27-49f7-adc7-520cf2b4b438}</ProjectGuid>
2323
<Keyword>Win32Proj</Keyword>
24-
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
24+
</PropertyGroup>
25+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
26+
<Import Project="$(ProjectDir)..\..\vcx-props\vcxcompat.props" />
27+
<PropertyGroup Label="Configuration">
2528
<ConfigurationType>Application</ConfigurationType>
26-
<PlatformToolset>v141</PlatformToolset>
29+
<UseOfMfc>false</UseOfMfc>
2730
<CharacterSet>Unicode</CharacterSet>
2831
</PropertyGroup>
29-
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
3032
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
31-
<Import Project="$(ProjectDir)..\..\vcx-props\vcxcompat.props" />
3233
<ImportGroup Label="ExtensionSettings" />
3334
<ImportGroup Label="Shared" />
3435
<ImportGroup Label="PropertySheets">

vcx-props/vcxcompat.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Label="Globals" Condition="'$(VisualStudioVersion)' == '15.0'">
4+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
5+
</PropertyGroup>
6+
<PropertyGroup Label="Globals" Condition="'$(VisualStudioVersion)' == '16.0'">
7+
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
8+
</PropertyGroup>
39
<PropertyGroup Label="Configuration" Condition="'$(VisualStudioVersion)' == '15.0'">
410
<PlatformToolset>v141</PlatformToolset>
511
</PropertyGroup>

0 commit comments

Comments
 (0)