aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt60
1 files changed, 53 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6deb43a4..e5a5ecfc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -239,10 +239,11 @@ IF(NOT CMAKE_DEBUG_POSTFIX)
FORCE)
ENDIF()
+SET(EXTRA_CFLAGS "")
IF(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
- ADD_DEFINITIONS("/wd4098")
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} /wd4098")
IF(NOT DXSDK_DIR)
STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
@@ -264,14 +265,14 @@ IF(MSVC)
ENDFOREACH(flag_var)
ENDIF()
ELSE()
- ADD_DEFINITIONS(-Winline -Wall)
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Winline -Wall")
CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
IF(HAVE_W_EXTRA)
- ADD_DEFINITIONS(-Wextra)
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wextra")
ENDIF()
IF(ALSOFT_WERROR)
- ADD_DEFINITIONS(-Werror)
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
ENDIF()
# Force enable -fPIC for CMake versions before 2.8.9 (later versions have
@@ -281,7 +282,7 @@ ELSE()
IF(CMAKE_VERSION VERSION_LESS "2.8.9" AND NOT WIN32)
CHECK_C_COMPILER_FLAG(-fPIC HAVE_FPIC_SWITCH)
IF(HAVE_FPIC_SWITCH)
- ADD_DEFINITIONS(-fPIC)
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC")
ENDIF()
ENDIF()
@@ -317,6 +318,7 @@ int main()
ENDIF()
# Set visibility/export options if available
+SET(HIDDEN_DECL "")
IF(WIN32)
SET(EXPORT_DECL "__declspec(dllexport)")
IF(NOT MINGW)
@@ -344,7 +346,8 @@ ELSE()
IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
- ADD_DEFINITIONS(-fvisibility=hidden)
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+ SET(HIDDEN_DECL "__attribute__((visibility(\"hidden\")))")
ENDIF()
ENDIF()
@@ -534,7 +537,7 @@ IF(NOT HAVE_WINDOWS_H)
CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
IF(HAVE_PTHREAD)
- ADD_DEFINITIONS(-pthread)
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread")
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
ENDIF()
@@ -1060,6 +1063,30 @@ ENDIF()
# This is always available
SET(BACKENDS "${BACKENDS} Null")
+option(ALSOFT_EMBED_HRTF_DATA "Embed the HRTF data files (increases library footprint)" OFF)
+if(ALSOFT_EMBED_HRTF_DATA)
+ if(WIN32)
+ set(ALC_OBJS ${ALC_OBJS} Alc/hrtf_res.rc)
+ else()
+ set(FILENAMES default-44100.mhr default-48000.mhr)
+ foreach(FILENAME ${FILENAMES})
+ set(outfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}${CMAKE_C_OUTPUT_EXTENSION})
+ add_custom_command(OUTPUT ${outfile}
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hrtf/${FILENAME}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/hrtf"
+ COMMAND "${CMAKE_LINKER}" -r -b binary -o "${outfile}" ${FILENAME}
+ COMMAND "${CMAKE_OBJCOPY}" --rename-section .data=.rodata,alloc,load,readonly,data,contents "${outfile}" "${outfile}"
+ COMMENT "Generating ${FILENAME}${CMAKE_C_OUTPUT_EXTENSION}"
+ VERBATIM
+ )
+ set(ALC_OBJS ${ALC_OBJS} ${outfile})
+ endforeach()
+ unset(outfile)
+ unset(FILENAMES)
+ endif()
+endif()
+
+
IF(ALSOFT_UTILS AND NOT ALSOFT_NO_CONFIG_UTIL)
add_subdirectory(utils/alsoft-config)
ENDIF()
@@ -1101,6 +1128,7 @@ CONFIGURE_FILE(
# Build a common library with reusable helpers
ADD_LIBRARY(common STATIC ${COMMON_OBJS})
+SET_PROPERTY(TARGET common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
IF(NOT LIBTYPE STREQUAL "STATIC")
SET_PROPERTY(TARGET common PROPERTY POSITION_INDEPENDENT_CODE TRUE)
ENDIF()
@@ -1111,6 +1139,7 @@ IF(LIBTYPE STREQUAL "STATIC")
ELSE()
ADD_LIBRARY(${LIBNAME} SHARED ${OPENAL_OBJS} ${ALC_OBJS})
ENDIF()
+SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
IF(WIN32 AND ALSOFT_NO_UID_DEFS)
SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
@@ -1209,6 +1238,11 @@ IF(WIN32)
ENDIF()
ENDIF()
+if(ALSOFT_EMBED_HRTF_DATA)
+ message(STATUS "Embedding HRTF datasets")
+ message(STATUS "")
+endif()
+
# Install alsoft.conf configuration file
IF(ALSOFT_CONFIG)
INSTALL(FILES alsoftrc.sample
@@ -1244,14 +1278,17 @@ ENDIF()
IF(ALSOFT_UTILS)
ADD_EXECUTABLE(openal-info utils/openal-info.c)
+ SET_PROPERTY(TARGET openal-info APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
TARGET_LINK_LIBRARIES(openal-info ${LIBNAME})
ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
+ SET_PROPERTY(TARGET makehrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
IF(HAVE_LIBM)
TARGET_LINK_LIBRARIES(makehrtf m)
ENDIF()
ADD_EXECUTABLE(bsincgen utils/bsincgen.c)
+ SET_PROPERTY(TARGET bsincgen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
IF(HAVE_LIBM)
TARGET_LINK_LIBRARIES(bsincgen m)
ENDIF()
@@ -1273,9 +1310,11 @@ ENDIF()
IF(ALSOFT_TESTS)
ADD_LIBRARY(test-common STATIC examples/common/alhelpers.c)
+ SET_PROPERTY(TARGET test-common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
ADD_EXECUTABLE(altonegen examples/altonegen.c)
TARGET_LINK_LIBRARIES(altonegen test-common ${LIBNAME})
+ SET_PROPERTY(TARGET altonegen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
IF(ALSOFT_INSTALL)
INSTALL(TARGETS altonegen
@@ -1293,36 +1332,42 @@ IF(ALSOFT_EXAMPLES)
IF(SDL2_FOUND AND SDL_SOUND_FOUND)
ADD_LIBRARY(ex-common STATIC examples/common/alhelpers.c
examples/common/sdl_sound.c)
+ SET_PROPERTY(TARGET ex-common APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET ex-common APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
${SDL_SOUND_INCLUDE_DIR})
ADD_EXECUTABLE(alstream examples/alstream.c)
TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
common ${LIBNAME})
+ SET_PROPERTY(TARGET alstream APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
${SDL_SOUND_INCLUDE_DIR})
ADD_EXECUTABLE(alreverb examples/alreverb.c)
TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
common ${LIBNAME})
+ SET_PROPERTY(TARGET alreverb APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
${SDL_SOUND_INCLUDE_DIR})
ADD_EXECUTABLE(allatency examples/allatency.c)
TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
common ${LIBNAME})
+ SET_PROPERTY(TARGET allatency APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
${SDL_SOUND_INCLUDE_DIR})
ADD_EXECUTABLE(alloopback examples/alloopback.c)
TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
common ${LIBNAME})
+ SET_PROPERTY(TARGET alloopback APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
${SDL_SOUND_INCLUDE_DIR})
ADD_EXECUTABLE(alhrtf examples/alhrtf.c)
TARGET_LINK_LIBRARIES(alhrtf ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
common ${LIBNAME})
+ SET_PROPERTY(TARGET alhrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET alhrtf APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
${SDL_SOUND_INCLUDE_DIR})
@@ -1361,6 +1406,7 @@ IF(ALSOFT_EXAMPLES)
IF(FFVER_OK AND NOT MSVC)
ADD_EXECUTABLE(alffplay examples/alffplay.c)
TARGET_LINK_LIBRARIES(alffplay common ex-common ${SDL2_LIBRARY} ${LIBNAME} ${FFMPEG_LIBRARIES})
+ SET_PROPERTY(TARGET alffplay APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET alffplay APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}
${FFMPEG_INCLUDE_DIRS})