aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authoralexey.lysiuk <[email protected]>2017-05-05 13:29:52 +0300
committeralexey.lysiuk <[email protected]>2017-05-05 14:30:06 +0300
commit17dfaca43d4f72c1691a66a5124247f121d967d8 (patch)
tree2b9a80318f16e80b74d7f195250dfcde0c4d2a25 /CMakeLists.txt
parent9c9ad2f60aead15416c8b582e20fadf847a13ce8 (diff)
Implement cross-platform embedding of HRTF data
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt67
1 files changed, 29 insertions, 38 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index efb06ebf..f15bcea2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1102,44 +1102,35 @@ 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)
- elseif(APPLE)
- macro(add_custom_binary FILENAME BIN_NAME)
- set(outfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}${CMAKE_C_OUTPUT_EXTENSION})
- set(stubsrcfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}.stub.c)
- set(stubfile ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${FILENAME}.stub${CMAKE_C_OUTPUT_EXTENSION})
- add_custom_command(OUTPUT ${outfile}
- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hrtf/${FILENAME}"
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/hrtf"
- COMMAND touch "${stubsrcfile}"
- COMMAND "${CMAKE_C_COMPILER}" -o "${stubfile}" -c "${stubsrcfile}"
- COMMAND "${CMAKE_LINKER}" -r -o "${outfile}" -sectcreate binary ${BIN_NAME} ${FILENAME} "${stubfile}"
- COMMAND rm "${stubsrcfile}" "${stubfile}"
- COMMENT "Generating ${FILENAME}${CMAKE_C_OUTPUT_EXTENSION}"
- VERBATIM
- )
- set(ALC_OBJS ${ALC_OBJS} ${outfile})
- endmacro()
- add_custom_binary(default-44100.mhr "default_44100")
- add_custom_binary(default-48000.mhr "default_48000")
- 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()
+ SET(NATIVE_SRC_DIR "${OpenAL_SOURCE_DIR}/utils/native-tools/")
+ SET(NATIVE_BIN_DIR "${OpenAL_BINARY_DIR}/native-tools/")
+ FILE(MAKE_DIRECTORY "${NATIVE_BIN_DIR}")
+
+ SET(BIN2H_COMMAND "${NATIVE_BIN_DIR}bin2h")
+ ADD_CUSTOM_COMMAND(OUTPUT "${BIN2H_COMMAND}"
+ COMMAND ${CMAKE_COMMAND} "${NATIVE_SRC_DIR}"
+ COMMAND ${CMAKE_COMMAND} --build . --config "Release"
+ WORKING_DIRECTORY "${NATIVE_BIN_DIR}"
+ DEPENDS "${NATIVE_SRC_DIR}CMakeLists.txt" "${NATIVE_SRC_DIR}bin2h.c"
+ VERBATIM
+ )
+
+ MACRO(make_hrtf_header FILENAME VARNAME)
+ SET(infile "${OpenAL_SOURCE_DIR}/hrtf/${FILENAME}")
+ SET(outfile "${OpenAL_BINARY_DIR}/${FILENAME}.h")
+
+ ADD_CUSTOM_COMMAND(OUTPUT "${outfile}"
+ COMMAND "${BIN2H_COMMAND}" "${infile}" "${outfile}" ${VARNAME}
+ DEPENDS "${BIN2H_COMMAND}" "${infile}"
+ COMMENT "Generating ${FILENAME}.h"
+ VERBATIM
+ )
+
+ SET(ALC_OBJS ${ALC_OBJS} "${outfile}")
+ ENDMACRO()
+
+ make_hrtf_header(default-44100.mhr "hrtf_default_44100")
+ make_hrtf_header(default-48000.mhr "hrtf_default_48000")
endif()