aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt116
1 files changed, 60 insertions, 56 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a8aa079b..70709444 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,10 +62,7 @@ if(DEFINED LIB_SUFFIX)
endif()
-IF(NOT WIN32)
- SET(LIBNAME openal)
-ELSE()
- SET(LIBNAME OpenAL32)
+IF(WIN32)
ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0502")
# This option is mainly for static linking OpenAL Soft into another project
@@ -331,7 +328,7 @@ ELSE()
# Force enable -fPIC for CMake versions before 2.8.9 (later versions have
# the POSITION_INDEPENDENT_CODE target property). The static common library
- # will be linked into the dynamic openal library, which requires all its
+ # will be linked into the dynamic OpenAL library, which requires all its
# code to be position-independent.
IF(CMAKE_VERSION VERSION_LESS "2.8.9" AND NOT WIN32)
CHECK_C_COMPILER_FLAG(-fPIC HAVE_FPIC_SWITCH)
@@ -1240,64 +1237,63 @@ CONFIGURE_FILE(
"${OpenAL_BINARY_DIR}/openal.pc"
@ONLY)
-# 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()
-
# Build main library
IF(LIBTYPE STREQUAL "STATIC")
- ADD_LIBRARY(${LIBNAME} STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
+ ADD_LIBRARY(OpenAL STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
ELSE()
- ADD_LIBRARY(${LIBNAME} SHARED ${OPENAL_OBJS} ${ALC_OBJS})
+ ADD_LIBRARY(OpenAL SHARED ${COMMON_OBJS} ${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)
+SET_PROPERTY(TARGET OpenAL APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
+SET_PROPERTY(TARGET OpenAL 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)
+ SET_PROPERTY(TARGET OpenAL APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
ENDIF()
-SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
+SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc")
IF(HAVE_ALSA)
- SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
+ SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
ENDIF()
IF(HAVE_OSS)
- SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${OSS_INCLUDE_DIRS})
+ SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${OSS_INCLUDE_DIRS})
ENDIF()
IF(HAVE_SOLARIS)
- SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${AUDIOIO_INCLUDE_DIRS})
+ SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${AUDIOIO_INCLUDE_DIRS})
ENDIF()
IF(HAVE_SNDIO)
- SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${SOUNDIO_INCLUDE_DIRS})
+ SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${SOUNDIO_INCLUDE_DIRS})
ENDIF()
IF(HAVE_QSA)
- SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${QSA_INCLUDE_DIRS})
+ SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${QSA_INCLUDE_DIRS})
ENDIF()
IF(HAVE_DSOUND)
- SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${DSOUND_INCLUDE_DIRS})
+ SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${DSOUND_INCLUDE_DIRS})
ENDIF()
IF(HAVE_PORTAUDIO)
- SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PORTAUDIO_INCLUDE_DIRS})
+ SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${PORTAUDIO_INCLUDE_DIRS})
ENDIF()
IF(HAVE_PULSEAUDIO)
- SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${PULSEAUDIO_INCLUDE_DIRS})
+ SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${PULSEAUDIO_INCLUDE_DIRS})
ENDIF()
IF(HAVE_JACK)
- SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${JACK_INCLUDE_DIRS})
+ SET_PROPERTY(TARGET OpenAL APPEND PROPERTY INCLUDE_DIRECTORIES ${JACK_INCLUDE_DIRS})
ENDIF()
IF(WIN32)
IF(MSVC)
- SET_PROPERTY(TARGET ${LIBNAME} APPEND_STRING PROPERTY LINK_FLAGS " /SUBSYSTEM:WINDOWS")
+ SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS " /SUBSYSTEM:WINDOWS")
ELSEIF(CMAKE_COMPILER_IS_GNUCC)
- SET_PROPERTY(TARGET ${LIBNAME} APPEND_STRING PROPERTY LINK_FLAGS " -mwindows")
+ SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS " -mwindows")
ENDIF()
ENDIF()
-SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
- SOVERSION ${LIB_MAJOR_VERSION})
-IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
- SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
+SET_TARGET_PROPERTIES(OpenAL PROPERTIES VERSION ${LIB_VERSION}
+ SOVERSION ${LIB_MAJOR_VERSION})
+IF(NOT WIN32)
+ SET_TARGET_PROPERTIES(OpenAL PROPERTIES OUTPUT_NAME "openal")
+ELSE()
+ SET_TARGET_PROPERTIES(OpenAL PROPERTIES OUTPUT_NAME "OpenAL32")
+ENDIF()
+
+if(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
+ SET_TARGET_PROPERTIES(OpenAL PROPERTIES PREFIX "")
IF(MINGW AND ALSOFT_BUILD_IMPORT_LIB)
FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
@@ -1311,29 +1307,37 @@ IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC")
MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
ENDIF()
ELSE()
- SET_PROPERTY(TARGET ${LIBNAME} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--output-def,${LIBNAME}.def")
- ADD_CUSTOM_COMMAND(TARGET ${LIBNAME} POST_BUILD
- COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" ${LIBNAME}.def
- COMMAND "${DLLTOOL_EXECUTABLE}" -d ${LIBNAME}.def -l ${LIBNAME}.lib -D ${LIBNAME}.dll
- COMMENT "Stripping ordinals from ${LIBNAME}.def and generating ${LIBNAME}.lib..."
+ SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--output-def,OpenAL32.def")
+ ADD_CUSTOM_COMMAND(TARGET OpenAL POST_BUILD
+ COMMAND "${SED_EXECUTABLE}" -i -e "s/ @[^ ]*//" OpenAL32.def
+ COMMAND "${DLLTOOL_EXECUTABLE}" -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll
+ COMMENT "Stripping ordinals from OpenAL32.def and generating OpenAL32.lib..."
VERBATIM
)
ENDIF()
ENDIF()
ENDIF()
-TARGET_LINK_LIBRARIES(${LIBNAME} common ${EXTRA_LIBS})
+TARGET_LINK_LIBRARIES(OpenAL ${EXTRA_LIBS})
IF(TARGET build_version)
- ADD_DEPENDENCIES(${LIBNAME} build_version)
+ ADD_DEPENDENCIES(OpenAL build_version)
ENDIF()
IF(ALSOFT_INSTALL)
# Add an install target here
- INSTALL(TARGETS ${LIBNAME}
+ INSTALL(TARGETS OpenAL EXPORT OpenAL
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
+ EXPORT(TARGETS OpenAL
+ NAMESPACE OpenAL::
+ FILE OpenALConfig.cmake)
+ INSTALL(EXPORT OpenAL
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL
+ NAMESPACE OpenAL::
+ FILE OpenALConfig.cmake)
INSTALL(FILES include/AL/al.h
include/AL/alc.h
include/AL/alext.h
@@ -1404,7 +1408,7 @@ 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})
+ TARGET_LINK_LIBRARIES(openal-info OpenAL)
ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
SET_PROPERTY(TARGET makehrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
@@ -1437,8 +1441,8 @@ 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})
+ ADD_EXECUTABLE(altonegen examples/altonegen.c ${COMMON_OBJS})
+ TARGET_LINK_LIBRARIES(altonegen test-common OpenAL)
SET_PROPERTY(TARGET altonegen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
IF(ALSOFT_INSTALL)
@@ -1463,41 +1467,41 @@ IF(ALSOFT_EXAMPLES)
INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
)
- ADD_EXECUTABLE(alstream examples/alstream.c)
+ ADD_EXECUTABLE(alstream examples/alstream.c ${COMMON_OBJS})
TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
- common ${LIBNAME})
+ OpenAL)
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)
+ ADD_EXECUTABLE(alreverb examples/alreverb.c ${COMMON_OBJS})
TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
- common ${LIBNAME})
+ OpenAL)
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)
+ ADD_EXECUTABLE(allatency examples/allatency.c ${COMMON_OBJS})
TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
- common ${LIBNAME})
+ OpenAL)
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)
+ ADD_EXECUTABLE(alloopback examples/alloopback.c ${COMMON_OBJS})
TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
- common ${LIBNAME})
+ OpenAL)
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)
+ ADD_EXECUTABLE(alhrtf examples/alhrtf.c ${COMMON_OBJS})
TARGET_LINK_LIBRARIES(alhrtf ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY}
- common ${LIBNAME})
+ OpenAL)
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}
@@ -1539,8 +1543,8 @@ IF(ALSOFT_EXAMPLES)
ENDIF()
ENDIF()
IF(FFVER_OK AND NOT MSVC)
- ADD_EXECUTABLE(alffplay examples/alffplay.c)
- TARGET_LINK_LIBRARIES(alffplay common ${SDL2_LIBRARY} ${LIBNAME} ${FFMPEG_LIBRARIES})
+ ADD_EXECUTABLE(alffplay examples/alffplay.c ${COMMON_OBJS})
+ TARGET_LINK_LIBRARIES(alffplay ${SDL2_LIBRARY} OpenAL ${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}