mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
CMake: remove macro and fix warnings
This commit is contained in:
+44
-37
@@ -62,35 +62,16 @@ option(MINIAUDIO_USE_STDINT "Use <stdint.h> for sized types"
|
|||||||
option(MINIAUDIO_DEBUG_OUTPUT "Enable stdout debug output" OFF)
|
option(MINIAUDIO_DEBUG_OUTPUT "Enable stdout debug output" OFF)
|
||||||
|
|
||||||
|
|
||||||
set(LIBS_TO_INSTALL)
|
|
||||||
|
|
||||||
# This assumes that our static library has exactly one .c file and 1 .h file, both named ${prefix.c} and ${prefix.h} respectively
|
|
||||||
# prefix is optional and defaults to name
|
|
||||||
macro(add_miniaudio_library name relpath)
|
|
||||||
set(prefix ${name})
|
|
||||||
set (extra_args ${ARGN})
|
|
||||||
|
|
||||||
list(LENGTH extra_args extra_count)
|
|
||||||
if (${extra_count} GREATER 0)
|
|
||||||
list(GET extra_args 0 prefix)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
add_library(${name} STATIC
|
|
||||||
${relpath}/${prefix}.c
|
|
||||||
${relpath}/${prefix}.h
|
|
||||||
)
|
|
||||||
# Without this, changes made to LIBS_TO_INSTALL disappear when we return
|
|
||||||
list(APPEND LIBS_TO_INSTALL ${name})
|
|
||||||
set(LIBS_TO_INSTALL ${LIBS_TO_INSTALL} PARENT_SCOPE)
|
|
||||||
|
|
||||||
install(FILES ${relpath}/${prefix}.h
|
|
||||||
DESTINATION include/miniaudio/${relpath})
|
|
||||||
target_include_directories(${name} PUBLIC ${dir})
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
# Construct compiler options.
|
# Construct compiler options.
|
||||||
set(COMPILE_OPTIONS)
|
set(COMPILE_OPTIONS)
|
||||||
|
|
||||||
|
# Store libraries to install
|
||||||
|
# When installing any header that imports miniaudio.h from a relative path, we
|
||||||
|
# need to maintain its place in the directory tree so it can find Miniaudio
|
||||||
|
set(LIBS_TO_INSTALL)
|
||||||
|
|
||||||
|
|
||||||
if(MINIAUDIO_FORCE_CXX AND MINIAUDIO_FORCE_C89)
|
if(MINIAUDIO_FORCE_CXX AND MINIAUDIO_FORCE_C89)
|
||||||
message(FATAL_ERROR "MINIAUDIO_FORCE_CXX and MINIAUDIO_FORCE_C89 cannot be enabled at the same time.")
|
message(FATAL_ERROR "MINIAUDIO_FORCE_CXX and MINIAUDIO_FORCE_C89 cannot be enabled at the same time.")
|
||||||
endif()
|
endif()
|
||||||
@@ -478,8 +459,15 @@ endif()
|
|||||||
|
|
||||||
|
|
||||||
# Static Libraries
|
# Static Libraries
|
||||||
add_miniaudio_library(miniaudio ".")
|
add_library(miniaudio STATIC
|
||||||
|
miniaudio.c
|
||||||
|
miniaudio.h
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND LIBS_TO_INSTALL miniaudio)
|
||||||
|
install(FILES miniaudio.h DESTINATION include/miniaudio)
|
||||||
|
|
||||||
|
target_include_directories(miniaudio PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
target_compile_options (miniaudio PRIVATE ${COMPILE_OPTIONS})
|
target_compile_options (miniaudio PRIVATE ${COMPILE_OPTIONS})
|
||||||
target_compile_definitions(miniaudio PRIVATE ${COMPILE_DEFINES})
|
target_compile_definitions(miniaudio PRIVATE ${COMPILE_DEFINES})
|
||||||
|
|
||||||
@@ -494,7 +482,13 @@ if(HAS_LIBVORBIS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAS_LIBVORBIS)
|
if(HAS_LIBVORBIS)
|
||||||
add_miniaudio_library(miniaudio_libvorbis extras/decoders/libvorbis)
|
add_library(miniaudio_libvorbis STATIC
|
||||||
|
extras/decoders/libvorbis/miniaudio_libvorbis.c
|
||||||
|
extras/decoders/libvorbis/miniaudio_libvorbis.h
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND LIBS_TO_INSTALL miniaudio_libvorbis)
|
||||||
|
install(FILES extras/decoders/libvorbis/miniaudio_libvorbis.h DESTINATION include/miniaudio/extras/decoders/libvorbis)
|
||||||
|
|
||||||
target_compile_options (miniaudio_libvorbis PRIVATE ${COMPILE_OPTIONS})
|
target_compile_options (miniaudio_libvorbis PRIVATE ${COMPILE_OPTIONS})
|
||||||
target_compile_definitions(miniaudio_libvorbis PRIVATE ${COMPILE_DEFINES})
|
target_compile_definitions(miniaudio_libvorbis PRIVATE ${COMPILE_DEFINES})
|
||||||
@@ -513,7 +507,14 @@ if(HAS_LIBOPUS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAS_LIBOPUS)
|
if(HAS_LIBOPUS)
|
||||||
add_miniaudio_library(miniaudio_libopus extras/decoders/libopus)
|
add_library(miniaudio_libopus STATIC
|
||||||
|
extras/decoders/libopus/miniaudio_libopus.c
|
||||||
|
extras/decoders/libopus/miniaudio_libopus.h
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
list(APPEND LIBS_TO_INSTALL miniaudio_libopus)
|
||||||
|
install(FILES extras/decoders/libopus/miniaudio_libopus.h DESTINATION include/miniaudio/extras/decoders/libopus)
|
||||||
|
|
||||||
target_compile_options (miniaudio_libopus PRIVATE ${COMPILE_OPTIONS})
|
target_compile_options (miniaudio_libopus PRIVATE ${COMPILE_OPTIONS})
|
||||||
target_compile_definitions(miniaudio_libopus PRIVATE ${COMPILE_DEFINES})
|
target_compile_definitions(miniaudio_libopus PRIVATE ${COMPILE_DEFINES})
|
||||||
@@ -523,8 +524,17 @@ endif()
|
|||||||
|
|
||||||
if (NOT MINIAUDIO_NO_EXTRA_NODES)
|
if (NOT MINIAUDIO_NO_EXTRA_NODES)
|
||||||
function(add_extra_node name)
|
function(add_extra_node name)
|
||||||
add_miniaudio_library(miniaudio_${name}_node extras/nodes/ma_${name}_node ma_${name}_node)
|
add_library(miniaudio_${name}_node STATIC
|
||||||
|
extras/nodes/ma_${name}_node/ma_${name}_node.c
|
||||||
|
extras/nodes/ma_${name}_node/ma_${name}_node.h
|
||||||
|
)
|
||||||
|
set(libs "${LIBS_TO_INSTALL}")
|
||||||
|
|
||||||
|
list(APPEND libs miniaudio_${name}_node)
|
||||||
|
set(LIBS_TO_INSTALL "${libs}" PARENT_SCOPE) # without PARENT_SCOPE, any changes are lost
|
||||||
|
install(FILES extras/nodes/ma_${name}_node/ma_${name}_node.h DESTINATION include/miniaudio/extras/nodes/ma_${name}_node)
|
||||||
|
|
||||||
|
target_include_directories(miniaudio_${name}_node PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/extras/nodes/ma_${name}_node)
|
||||||
target_compile_options (miniaudio_${name}_node PRIVATE ${COMPILE_OPTIONS})
|
target_compile_options (miniaudio_${name}_node PRIVATE ${COMPILE_OPTIONS})
|
||||||
target_compile_definitions(miniaudio_${name}_node PRIVATE ${COMPILE_DEFINES})
|
target_compile_definitions(miniaudio_${name}_node PRIVATE ${COMPILE_DEFINES})
|
||||||
|
|
||||||
@@ -660,12 +670,9 @@ endif()
|
|||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
message(STATUS "Library list: ${LIBS_TO_INSTALL}")
|
||||||
|
install(TARGETS ${LIBS_TO_INSTALL}
|
||||||
install(
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
TARGETS ${LIBS_TO_INSTALL}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
||||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
||||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
||||||
)
|
)
|
||||||
Reference in New Issue
Block a user