Browse Source

Treat DirectSound just like any other standard Windows SDK library.

Currently the CMake build system goes through complicated logic to
find the DirectX SDK. This is completely unnecessary, because modern
versions of the Windows SDK include dsound.h and dsound.lib in the
standard paths, so it can be treated just like the other Windows OS
libraries and we can safely assume it is available.

This commit simplifies the logic and will allow the vcpkg portaudio
port to align with portaudio stream, by getting rid of this patch:
  95f9ce56f3/ports/portaudio/find_dsound.patch

I have verified that PortAudio CMake still builds with this commit
with the following toolchains:
 - Windows Visual Studio 2017 native CMake support
 - mingw-w64 on Windows (msys2)
 - mingw-w64 cross-compiling from Debian Unstable
mr/7040151/95e86c307b9cd20180f3c1f52853c3424ce62ae5
Etienne Dechamps 10 months ago
parent
commit
0baa1e2e31
2 changed files with 2 additions and 99 deletions
  1. 2
    11
      CMakeLists.txt
  2. 0
    88
      cmake_support/FindDXSDK.cmake

+ 2
- 11
CMakeLists.txt View File

@@ -169,13 +169,7 @@ IF(WIN32)
SET(DEF_EXCLUDE_ASIO_SYMBOLS ";")
ENDIF()

# Try to find DirectX SDK
FIND_PACKAGE(DXSDK)
IF(DXSDK_FOUND)
OPTION(PA_USE_DS "Enable support for DirectSound" ON)
ELSE()
OPTION(PA_USE_DS "Enable support for DirectSound" OFF)
ENDIF()
OPTION(PA_USE_DS "Enable support for DirectSound" ON)
IF(PA_USE_DS)
IF(MINGW)
MESSAGE(STATUS "DirectSound support will be built with DSound provided by MinGW.")
@@ -187,16 +181,13 @@ IF(WIN32)
IF(PA_USE_DIRECTSOUNDFULLDUPLEXCREATE)
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE)
ENDIF()
SET(PA_PRIVATE_INCLUDE_PATHS ${PA_PRIVATE_INCLUDE_PATHS} ${DXSDK_INCLUDE_DIR})
SET(PA_DS_INCLUDES src/hostapi/dsound/pa_win_ds_dynlink.h)
SET(PA_DS_SOURCES src/hostapi/dsound/pa_win_ds.c src/hostapi/dsound/pa_win_ds_dynlink.c)
SOURCE_GROUP("hostapi\\dsound" FILES ${PA_DS_INCLUDES} ${PA_DS_SOURCES})
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_win_ds.h)
SET(PA_PRIVATE_INCLUDES ${PA_PRIVATE_INCLUDES} ${PA_DS_INCLUDES})
SET(PA_SOURCES ${PA_SOURCES} ${PA_DS_SOURCES})

# If we use DirectSound, we need this for the library to be found (if not in VS project settings)
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ${DXSDK_DSOUND_LIBRARY})
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} dsound)
ENDIF(PA_USE_DS)

OPTION(PA_USE_WMME "Enable support for MME" ON)

+ 0
- 88
cmake_support/FindDXSDK.cmake View File

@@ -1,88 +0,0 @@
# $Id: $
#
# - For MSVC builds try to find the MS DirectX SDK, for MinGW just the
# MinGW dsound library
#
# Once done this will define
#
# DXSDK_FOUND - system has DirectX SDK
# DXSDK_ROOT_DIR - path to the DirectX SDK base directory
# DXSDK_INCLUDE_DIR - the DirectX SDK include directory
# DXSDK_LIBRARY_DIR - DirectX SDK libraries path
#
# DXSDK_DSOUND_LIBRARY - Path to dsound.lib
#
# MinGW builds have to use dsound provided by MinGW, so we need to avoid finding
# the actual MS-DX-SDK in case it is installed on a build system. With MinGW,
# "DXSDK" boils down to just another library and headers in default locations.
# There might be old MinGW distributions without dsound though, so it is good to
# verify its availability.


if(WIN32)
else(WIN32)
message(FATAL_ERROR "FindDXSDK.cmake: Unsupported platform ${CMAKE_SYSTEM_NAME}" )
endif(WIN32)

if(MSVC)

find_path(DXSDK_ROOT_DIR
include/dxsdkver.h
HINTS
$ENV{DXSDK_DIR}
)

find_path(DXSDK_INCLUDE_DIR
dxsdkver.h
PATHS
${DXSDK_ROOT_DIR}/include
)

IF(CMAKE_CL_64)
find_path(DXSDK_LIBRARY_DIR
dsound.lib
PATHS
${DXSDK_ROOT_DIR}/lib/x64
)
ELSE(CMAKE_CL_64)
find_path(DXSDK_LIBRARY_DIR
dsound.lib
PATHS
${DXSDK_ROOT_DIR}/lib/x86
)
ENDIF(CMAKE_CL_64)

find_library(DXSDK_DSOUND_LIBRARY
dsound.lib
PATHS
${DXSDK_LIBRARY_DIR}
)

# handle the QUIETLY and REQUIRED arguments and set DXSDK_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DXSDK DEFAULT_MSG DXSDK_ROOT_DIR DXSDK_INCLUDE_DIR)

ELSEIF(MINGW)

GET_FILENAME_COMPONENT(MINGW_BIN_DIR ${CMAKE_C_COMPILER} DIRECTORY)
GET_FILENAME_COMPONENT(MINGW_SYSROOT ${MINGW_BIN_DIR} DIRECTORY)
# The glob expression below should only return a single folder:
FILE(GLOB MINGW_TOOLCHAIN_FOLDER ${MINGW_SYSROOT}/*mingw32)
find_library(DXSDK_DSOUND_LIBRARY
libdsound.a dsound
HINTS
"${MINGW_TOOLCHAIN_FOLDER}/lib"
"${MINGW_SYSROOT}/lib"
)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DXSDK DEFAULT_MSG DXSDK_DSOUND_LIBRARY)

ENDIF(MSVC)

MARK_AS_ADVANCED(
DXSDK_ROOT_DIR DXSDK_INCLUDE_DIR
DXSDK_LIBRARY_DIR DXSDK_DSOUND_LIBRARY
)

Loading…
Cancel
Save