FAudioGMS/CMakeLists.txt

144 lines
4.3 KiB
CMake
Raw Normal View History

2021-10-29 09:36:36 +00:00
# CMake Project for FAudioGMS
cmake_minimum_required(VERSION 2.8.12)
project(FAudioGMS C)
#Options
option(BUILD_SHARED_LIBS "Build shared library" ON)
SET(LIB_MAJOR_VERSION "0")
SET(LIB_MINOR_VERSION "2")
SET(LIB_REVISION "0")
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
# Build Type
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
# By default, we use Release
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE "Release" CACHE
STRING "Choose the type of build." FORCE
)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "Debug" "Release" "RelWithDebInfo"
)
endif()
# Platform Flags
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
set(LOBJC "objc")
elseif(WIN32)
# "FAudioGMS.dll", not "libFAudioGMS.dll"
set(CMAKE_SHARED_LIBRARY_PREFIX "")
endif()
if(UNIX)
2021-10-29 22:42:07 +00:00
SET(BIN_RPATH "\$ORIGIN;\$ORIGIN/assets") #thanks yoyo games
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH ${BIN_RPATH})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
endif()
2021-10-29 09:36:36 +00:00
# Source lists
add_library(FAudioGMS
#Public header
src/FAudioGMS.h
#Source files
lib/dr_wav.h
src/FAudioGMS.c
)
# FAudio Source lists
add_library(FAudio STATIC
# Public Headers
lib/FAudio/include/F3DAudio.h
lib/FAudio/include/FACT3D.h
lib/FAudio/include/FACT.h
lib/FAudio/include/FAPOBase.h
lib/FAudio/include/FAPOFX.h
lib/FAudio/include/FAPO.h
lib/FAudio/include/FAudioFX.h
lib/FAudio/include/FAudio.h
# Internal Headers
lib/FAudio/src/FACT_internal.h
lib/FAudio/src/FAudio_internal.h
lib/FAudio/src/stb.h
lib/FAudio/src/stb_vorbis.h
# Source Files
lib/FAudio/src/F3DAudio.c
lib/FAudio/src/FACT3D.c
lib/FAudio/src/FACT.c
lib/FAudio/src/FACT_internal.c
lib/FAudio/src/FAPOBase.c
lib/FAudio/src/FAPOFX.c
lib/FAudio/src/FAPOFX_echo.c
lib/FAudio/src/FAPOFX_eq.c
lib/FAudio/src/FAPOFX_masteringlimiter.c
lib/FAudio/src/FAPOFX_reverb.c
lib/FAudio/src/FAudio.c
lib/FAudio/src/FAudioFX_reverb.c
lib/FAudio/src/FAudioFX_volumemeter.c
lib/FAudio/src/FAudio_internal.c
lib/FAudio/src/FAudio_internal_simd.c
lib/FAudio/src/FAudio_operationset.c
lib/FAudio/src/FAudio_platform_sdl2.c
lib/FAudio/src/FAudio_platform_win32.c
)
# Build flags
if(NOT MSVC)
set_property(TARGET FAudioGMS PROPERTY COMPILE_FLAGS "-std=gnu99 -Wall -Wno-strict-aliasing -pedantic")
set_property(TARGET FAudio PROPERTY COMPILE_FLAGS "-fPIC")
endif()
# includes
target_include_directories(FAudioGMS PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/FAudio/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/SDL/include>
)
target_include_directories(FAudio PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/FAudio/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/SDL/include>
)
# Soname
set_target_properties(FAudioGMS PROPERTIES OUTPUT_NAME "FAudioGMS"
VERSION ${LIB_VERSION}
SOVERSION ${LIB_MAJOR_VERSION}
)
# Internal Dependencies
target_link_libraries(FAudioGMS PRIVATE FAudio ${LOBJC})
# SDL2 Dependency
if (DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
message(STATUS "using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
target_include_directories(FAudioGMS PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_include_directories(FAudio PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_link_libraries(FAudioGMS PUBLIC ${SDL2_LIBRARIES})
else()
# Only try to autodetect if both SDL2 variables aren't explicitly set
find_package(SDL2 CONFIG)
if (TARGET SDL2::SDL2)
message(STATUS "using TARGET SDL2::SDL2")
target_link_libraries(FAudioGMS PUBLIC SDL2::SDL2)
target_link_libraries(FAudio PUBLIC SDL2::SDL2)
elseif (TARGET SDL2)
message(STATUS "using TARGET SDL2")
target_link_libraries(FAudioGMS PUBLIC SDL2)
target_link_libraries(FAudio PUBLIC SDL2)
else()
message(STATUS "no TARGET SDL2::SDL2, or SDL2, using variables")
target_include_directories(FAudioGMS PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_include_directories(FAudio PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_link_libraries(FAudioGMS PUBLIC ${SDL2_LIBRARIES})
endif()
endif()