Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making some tweaks that would make me happy as a vcpkg maintainer #382

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ option(BUILD_SHARED_LIBS "Build shared libraries instead of static." ON)
option(STEAMAUDIO_BUILD_TESTS "Build unit tests." ON)
option(STEAMAUDIO_BUILD_BENCHMARKS "Build benchmarks." ON)
option(STEAMAUDIO_BUILD_SAMPLES "Build samples." ON)
option(STEAMAUDIO_EXPORT "Export the project for use by downstream. Requires that required dependencies are found via Config mode." OFF)
option(STEAMAUDIO_CLOSED_SOURCE_DEPS "Use closed source libraries. Otherwise attempt to skip" ON)

if (IPL_OS_WINDOWS AND IPL_CPU_X64)
option(STEAMAUDIO_BUILD_ITESTS "Build interactive tests." ON)
Expand Down Expand Up @@ -192,8 +194,13 @@ endif()

# macOS flags
if (IPL_OS_MACOS)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
# Allow project invoker to override OSX settings
if(NOT CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
endif()
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
endif()
add_compile_options(-Wno-extern-c-compat) # Suppress warning about empty API structs.
add_compile_options(-Wno-unknown-attributes) # Suppress warning in FlatBuffers.
endif()
Expand Down Expand Up @@ -240,7 +247,11 @@ if (STEAMAUDIO_ENABLE_FFTS)
endif()

if (NOT FFT_LIBRARY)
find_package(PFFFT REQUIRED)
if(STEAMAUDIO_EXPORT)
find_package(PFFFT CONFIG REQUIRED)
else()
find_package(PFFFT REQUIRED)
endif()
set(FFT_LIBRARY PFFFT)
endif()

Expand All @@ -252,10 +263,15 @@ if (STEAMAUDIO_ENABLE_MKL)
endif()
endif()

find_package(MySOFA REQUIRED)
find_package(FlatBuffers REQUIRED)
if(STEAMAUDIO_EXPORT)
find_package(MySOFA CONFIG REQUIRED)
find_package(FlatBuffers CONFIG REQUIRED)
else()
find_package(MySOFA REQUIRED)
find_package(FlatBuffers REQUIRED)
endif()

if (STEAMAUDIO_ENABLE_EMBREE)
if (STEAMAUDIO_ENABLE_EMBREE AND STEAMAUDIO_CLOSED_SOURCE_DEPS)
find_package(ISPC 1.12 EXACT)
find_package(Embree 2.17 EXACT)
if (NOT ISPC_FOUND OR NOT Embree_FOUND)
Expand All @@ -264,7 +280,7 @@ if (STEAMAUDIO_ENABLE_EMBREE)
endif()
endif()

if (STEAMAUDIO_ENABLE_RADEONRAYS)
if (STEAMAUDIO_ENABLE_RADEONRAYS AND STEAMAUDIO_CLOSED_SOURCE_DEPS)
find_package(Python COMPONENTS Interpreter)
find_package(RadeonRays)
if (NOT Python_FOUND OR NOT RadeonRays_FOUND)
Expand All @@ -273,7 +289,7 @@ if (STEAMAUDIO_ENABLE_RADEONRAYS)
endif()
endif()

if (STEAMAUDIO_ENABLE_TRUEAUDIONEXT)
if (STEAMAUDIO_ENABLE_TRUEAUDIONEXT AND STEAMAUDIO_CLOSED_SOURCE_DEPS)
find_package(TrueAudioNext)
if (NOT TrueAudioNext_FOUND)
message(STATUS "Disabling TrueAudioNext")
Expand Down
54 changes: 40 additions & 14 deletions core/src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ endif()
#

add_library(hrtf OBJECT hrtf.cpp)
target_include_directories(hrtf PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(hrtf PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")


#
Expand Down Expand Up @@ -582,7 +582,7 @@ if (STEAMAUDIO_BUILD_CSHARP_BINDINGS)
endif()

# This is needed so we can include generated headers
target_include_directories(core PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(core PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")

if (IPL_OS_WINDOWS)
target_link_libraries(core PUBLIC delayimp)
Expand Down Expand Up @@ -639,7 +639,7 @@ source_group("OpenCL Files" FILES ${CL_SOURCE})

target_compile_definitions(core PRIVATE STEAMAUDIO_BUILDING_CORE)

target_precompile_headers(core PUBLIC pch.h)
target_precompile_headers(core PRIVATE pch.h)


#
Expand Down Expand Up @@ -670,7 +670,7 @@ if (IPL_OS_LINUX)
target_link_options(phonon PRIVATE -Wl,--exclude-libs,ALL)
endif()

if (IPL_OS_WINDOWS AND IPL_CPU_X64 AND BUILD_SHARED_LIBS)
if (IPL_OS_WINDOWS AND IPL_CPU_X64 AND BUILD_SHARED_LIBS AND STEAMAUDIO_DEPS_CLOSED_SOURCE)
set_target_properties(phonon PROPERTIES LINK_FLAGS "/DELAYLOAD:opencl.dll /DELAYLOAD:gpuutilities.dll /DELAYLOAD:trueaudionext.dll")
endif()

Expand Down Expand Up @@ -967,16 +967,18 @@ if (IPL_OS_MACOS)
)
endif()

if (IPL_OS_WINDOWS)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/phonon.pdb
DESTINATION symbols/${IPL_BIN_SUBDIR}
)
elseif (IPL_OS_LINUX AND NOT IPL_CPU_ARMV8)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libphonon.so.dbg
DESTINATION symbols/${IPL_BIN_SUBDIR}
)
if(BUILD_SHARED_LIBS)
if (IPL_OS_WINDOWS)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/phonon.pdb
DESTINATION bin
)
elseif (IPL_OS_LINUX AND NOT IPL_CPU_ARMV8)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libphonon.so.dbg
DESTINATION bin
)
endif()
endif()

install(
Expand All @@ -994,4 +996,28 @@ if (IPL_OS_WINDOWS AND IPL_CPU_X64)
)
endif()

if(STEAMAUDIO_EXPORT)
export(EXPORT steam-audio_exports
NAMESPACE steam-audio::
FILE ${CMAKE_CURRENT_BINARY_DIR}/steam-audioTargets.cmake
)

# required to resolve object libraries on import
install(TARGETS core hrtf EXPORT steam-audio_exports)

install(EXPORT steam-audio_exports
NAMESPACE steam-audio::
FILE steam-audioTargets.cmake
DESTINATION share/steam-audio
)

include(CMakePackageConfigHelpers)
configure_package_config_file(steam-audio-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/steam-audio-config.cmake
INSTALL_DESTINATION share/steam-audio)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/steam-audio-config.cmake
DESTINATION share/steam-audio )
endif()

include(CMakeListsInternal.txt OPTIONAL)
7 changes: 7 additions & 0 deletions core/src/core/steam-audio-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

include(${CMAKE_CURRENT_LIST_DIR}/steam-audioTargets.cmake)

check_required_components(steam-audio)