From: Etienne Dechamps Date: Sun, 25 Nov 2018 10:28:56 +0000 (+0000) Subject: Treat DirectSound just like any other standard Windows SDK library. X-Git-Tag: v19.7.0~128^2~1 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=0baa1e2e31f37bac2883ea59e50b76037271426d;p=portaudio 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: https://github.com/Microsoft/vcpkg/blob/95f9ce56f32618cceda97d54af16e3d6c57fc4b3/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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b1832f..16a47df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake_support/FindDXSDK.cmake b/cmake_support/FindDXSDK.cmake deleted file mode 100644 index e487537..0000000 --- a/cmake_support/FindDXSDK.cmake +++ /dev/null @@ -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 -)