Define _WIN32_WINNT during compilation (#871)

This commit is contained in:
Tom M 2021-05-07 09:45:17 +02:00 committed by GitHub
parent f88f27c0da
commit 4231645fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 23 deletions

View File

@ -4,25 +4,23 @@
# https://docs.microsoft.com/azure/devops/pipelines/apps/c-cpp/gcc # https://docs.microsoft.com/azure/devops/pipelines/apps/c-cpp/gcc
jobs: jobs:
- job: Windows - job: WindowsXP
variables:
toolset: v141_xp
strategy: strategy:
matrix: matrix:
XP_x86: x86:
platform: Win32 platform: Win32
toolset: v141_xp
gtk-bundle: $(gtk-bundle-x86) gtk-bundle: $(gtk-bundle-x86)
libsndfile-url: $(libsndfile-url-x86) libsndfile-url: $(libsndfile-url-x86)
artifact-prefix: "fluidsynth" artifact-prefix: "fluidsynth"
imageName: 'windows-2019' x64:
XP_x64:
platform: x64 platform: x64
toolset: v141_xp
gtk-bundle: $(gtk-bundle-x64) gtk-bundle: $(gtk-bundle-x64)
libsndfile-url: $(libsndfile-url-x64) libsndfile-url: $(libsndfile-url-x64)
artifact-prefix: "fluidsynth" artifact-prefix: "fluidsynth"
imageName: 'windows-2019'
pool: pool:
vmImage: $(imageName) vmImage: 'windows-2019'
steps: steps:
- task: DownloadBuildArtifacts@0 - task: DownloadBuildArtifacts@0
inputs: inputs:
@ -56,7 +54,7 @@ jobs:
SET "PATH=d:\deps\bin;%PATH%" SET "PATH=d:\deps\bin;%PATH%"
pkg-config --list-all pkg-config --list-all
mkdir build && cd build || exit -1 mkdir build && cd build || exit -1
cmake -Werror=dev -A $(platform) -T $(toolset) -DCMAKE_INSTALL_PREFIX=$(Build.ArtifactStagingDirectory) -Denable-readline=0 -Denable-floats=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_VERBOSE_MAKEFILE=1 -DNO_GUI=1 .. || exit -1 cmake -Werror=dev -A $(platform) -T $(toolset) -DCMAKE_INSTALL_PREFIX=$(Build.ArtifactStagingDirectory) -Denable-readline=0 -Denable-floats=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_VERBOSE_MAKEFILE=1 -DNO_GUI=1 -Dwindows-version=0x0501 .. || exit -1
cmake --build . --config Release || exit -1 cmake --build . --config Release || exit -1
displayName: 'Compile fluidsynth' displayName: 'Compile fluidsynth'
- script: | - script: |
@ -81,34 +79,28 @@ jobs:
pathtoPublish: $(Build.ArtifactStagingDirectory) pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: $(artifact-prefix)-$(platform) artifactName: $(artifact-prefix)-$(platform)
- job: WindowsCI - job: Windows10
variables:
toolset: v142
gtk-bundle: $(gtk-bundle-x64)
libsndfile-url: $(libsndfile-url-x64)
strategy: strategy:
matrix: matrix:
default: default:
CMAKE_FLAGS: CMAKE_FLAGS:
CMAKE_CONFIG: Release CMAKE_CONFIG: Release
gtk-bundle: $(gtk-bundle-x64)
libsndfile-url: $(libsndfile-url-x64)
debug_prof: debug_prof:
CMAKE_FLAGS: -Denable-profiling=1 -Denable-trap-on-fpe=1 -Denable-fpe-check=1 CMAKE_FLAGS: -Denable-profiling=1 -Denable-trap-on-fpe=1 -Denable-fpe-check=1
CMAKE_CONFIG: Debug CMAKE_CONFIG: Debug
gtk-bundle: $(gtk-bundle-x64)
libsndfile-url: $(libsndfile-url-x64)
no_network: no_network:
CMAKE_FLAGS: -Denable-network=0 CMAKE_FLAGS: -Denable-network=0
CMAKE_CONFIG: Release CMAKE_CONFIG: Release
gtk-bundle: $(gtk-bundle-x64)
libsndfile-url: $(libsndfile-url-x64)
static_lib: static_lib:
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=0 CMAKE_FLAGS: -DBUILD_SHARED_LIBS=0
CMAKE_CONFIG: Release CMAKE_CONFIG: Release
gtk-bundle: $(gtk-bundle-x64)
libsndfile-url: $(libsndfile-url-x64)
minimal: minimal:
CMAKE_FLAGS: -Denable-ipv6=0 -Denable-network=0 -Denable-aufile=0 -Denable-dbus=0 -Denable-threads=0 -Denable-winmidi=0 -Denable-waveout=0 -Denable-dsound=0 -Denable-libsndfile=0 -Denable-floats=1 CMAKE_FLAGS: -Denable-ipv6=0 -Denable-network=0 -Denable-aufile=0 -Denable-dbus=0 -Denable-threads=0 -Denable-winmidi=0 -Denable-waveout=0 -Denable-dsound=0 -Denable-libsndfile=0 -Denable-floats=1
CMAKE_CONFIG: Release CMAKE_CONFIG: Release
gtk-bundle: $(gtk-bundle-x64)
libsndfile-url: $(libsndfile-url-x64)
pool: pool:
vmImage: 'windows-2019' vmImage: 'windows-2019'
steps: steps:
@ -129,7 +121,7 @@ jobs:
@ECHO ON @ECHO ON
SET "PATH=d:\deps\bin;%PATH%" SET "PATH=d:\deps\bin;%PATH%"
mkdir build && cd build || exit -1 mkdir build && cd build || exit -1
cmake -Werror=dev -A x64 -DCMAKE_BUILD_TYPE=$(CMAKE_CONFIG) -DCMAKE_VERBOSE_MAKEFILE=1 $(CMAKE_FLAGS) -DNO_GUI=1 .. || exit -1 cmake -Werror=dev -A x64 -T $(toolset) -DCMAKE_BUILD_TYPE=$(CMAKE_CONFIG) -DCMAKE_VERBOSE_MAKEFILE=1 $(CMAKE_FLAGS) -DNO_GUI=1 -Dwindows-version=0x0A00 .. || exit -1
cmake --build . --config $(CMAKE_CONFIG) || exit -1 cmake --build . --config $(CMAKE_CONFIG) || exit -1
displayName: 'Compile fluidsynth' displayName: 'Compile fluidsynth'
- script: | - script: |
@ -140,6 +132,8 @@ jobs:
displayName: 'Execute Unittests' displayName: 'Execute Unittests'
- job: WindowsMinGW - job: WindowsMinGW
variables:
artifact-prefix: "fluidsynth-mingw"
strategy: strategy:
matrix: matrix:
x86: x86:
@ -148,14 +142,12 @@ jobs:
gtk-bundle: $(gtk-bundle-x86) gtk-bundle: $(gtk-bundle-x86)
libsndfile-url: $(libsndfile-url-x86) libsndfile-url: $(libsndfile-url-x86)
mingw-url: $(mingw-url-x86) mingw-url: $(mingw-url-x86)
artifact-prefix: "fluidsynth-mingw"
x64: x64:
CMAKE_FLAGS: CMAKE_FLAGS:
platform: x64 platform: x64
gtk-bundle: $(gtk-bundle-x64) gtk-bundle: $(gtk-bundle-x64)
libsndfile-url: $(libsndfile-url-x64) libsndfile-url: $(libsndfile-url-x64)
mingw-url: $(mingw-url-x64) mingw-url: $(mingw-url-x64)
artifact-prefix: "fluidsynth-mingw"
pool: pool:
vmImage: 'windows-2019' vmImage: 'windows-2019'
steps: steps:

View File

@ -263,6 +263,32 @@ unset ( MINGW32 CACHE )
if ( WIN32 ) if ( WIN32 )
include ( CheckIncludeFiles ) include ( CheckIncludeFiles )
# We have to set _WIN32_WINNT to make sure CMake gets correct results when probing for functions.
# windows-version is supposed to be non-official variable that can be used to tweak the Windows target version.
# Its value defaults to the Windows Version we are compiling for.
if ( NOT windows-version )
if(${CMAKE_SYSTEM_VERSION} EQUAL 10) # Windows 10
set ( windows-version "0x0A00" )
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.3) # Windows 8.1
set ( windows-version "0x0603" )
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.2) # Windows 8
set ( windows-version "0x0602" )
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.1) # Windows 7
set ( windows-version "0x0601" )
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.0) # Windows Vista
set ( windows-version "0x0600" )
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 5.1) # Windows XP
set ( windows-version "0x0501" )
else()
set ( windows-version "0x0400" )
endif()
endif ()
message ( STATUS "Targetting Windows Version ${windows-version}" )
add_definitions ( -D _WIN32_WINNT=${windows-version} )
add_definitions ( -D WINVER=${windows-version} )
list ( APPEND CMAKE_REQUIRED_DEFINITIONS "-DWINVER=${windows-version}" )
list ( APPEND CMAKE_REQUIRED_DEFINITIONS "-D_WIN32_WINNT=${windows-version}" )
# Check presence of MS include files # Check presence of MS include files
check_include_file ( windows.h HAVE_WINDOWS_H ) check_include_file ( windows.h HAVE_WINDOWS_H )
check_include_file ( io.h HAVE_IO_H ) check_include_file ( io.h HAVE_IO_H )