Browse Source

Merge branch 'winbuild' into 'master'

Improvements to CMake build system on Windows

Merged-on: https://assembla.com/code/portaudio/git/merge_requests/7040151
mr/new/76e31c2a24eebfa95a704f711dd707a2635af77e
Etienne Dechamps 10 months ago
parent
commit
76e31c2a24
2 changed files with 5 additions and 102 deletions
  1. 5
    14
      CMakeLists.txt
  2. 0
    88
      cmake_support/FindDXSDK.cmake

+ 5
- 14
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,23 +181,20 @@ 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_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_win_ds.h include/pa_win_waveformat.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)
IF(PA_USE_WMME)
SET(PA_WMME_SOURCES src/hostapi/wmme/pa_win_wmme.c)
SOURCE_GROUP("hostapi\\wmme" FILES ${PA_WMME_SOURCES})
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_win_wmme.h)
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_win_wmme.h include/pa_win_waveformat.h)
SET(PA_SOURCES ${PA_SOURCES} ${PA_WMME_SOURCES})
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ole32 uuid)
ENDIF()
@@ -215,7 +206,7 @@ IF(WIN32)
IF(PA_USE_WASAPI)
SET(PA_WASAPI_SOURCES src/hostapi/wasapi/pa_win_wasapi.c)
SOURCE_GROUP("hostapi\\wasapi" FILES ${PA_WASAPI_SOURCES})
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_win_wasapi.h)
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_win_wasapi.h include/pa_win_waveformat.h)
SET(PA_SOURCES ${PA_SOURCES} ${PA_WASAPI_SOURCES})
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ole32 uuid)
ELSE()

+ 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