aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-12-15 12:25:50 -0800
committerChris Robinson <[email protected]>2017-12-15 12:25:50 -0800
commitd9f57c099b5a5c7c63c527e1d93cc5f5c8e68d1e (patch)
treeae66fc543df2e8e55e5d4872f5d8162fac423179
parent32f72c7471daaea53c6f0c6a50a98f4a7fec3614 (diff)
Use the correct functions set to the compiler switches
-rw-r--r--CMakeLists.txt284
-rw-r--r--native-tools/CMakeLists.txt5
2 files changed, 143 insertions, 146 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fb65489f..965a701e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,8 +62,14 @@ if(DEFINED LIB_SUFFIX)
endif()
+SET(CPP_DEFS ) # C pre-process, not C++
+SET(INC_PATHS )
+SET(C_FLAGS )
+SET(LINKER_FLAGS )
+SET(EXTRA_LIBS )
+
IF(WIN32)
- ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0502")
+ SET(CPP_DEFS ${CPP_DEFS} _WIN32 _WIN32_WINNT=0x0502)
OPTION(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF)
@@ -85,13 +91,10 @@ IF(WIN32)
ENDIF()
-SET(EXTRA_LIBS "")
-SET(EXTRA_LDFLAGS "")
-
# QNX's gcc do not uses /usr/include and /usr/lib pathes by default
IF ("${CMAKE_C_PLATFORM_ID}" STREQUAL "QNX")
- ADD_DEFINITIONS("-I/usr/include")
- SET(EXTRA_LDFLAGS "${EXTRA_LDFLAGS} -L/usr/lib")
+ SET(INC_PATHS ${INC_PATHS} /usr/include)
+ SET(LINKER_FLAGS ${LINKER_FLAGS} -L/usr/lib)
ENDIF()
IF(NOT LIBTYPE)
@@ -136,7 +139,7 @@ if(NOT WIN32)
IF(NOT HAVE_POSIX_MEMALIGN_POSIX)
SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
ELSE()
- ADD_DEFINITIONS(-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600)
+ SET(CPP_DEFS ${CPP_DEFS} _POSIX_C_SOURCE=200112L _XOPEN_SOURCE=600)
ENDIF()
ENDIF()
UNSET(OLD_REQUIRED_FLAGS)
@@ -145,10 +148,10 @@ ENDIF()
# Set defines for large file support
CHECK_FILE_OFFSET_BITS()
IF(_FILE_OFFSET_BITS)
- ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
+ SET(CPP_DEFS ${CPP_DEFS} "_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}")
ENDIF()
-ADD_DEFINITIONS(-D_LARGEFILE_SOURCE -D_LARGE_FILES)
+SET(CPP_DEFS ${CPP_DEFS} _LARGEFILE_SOURCE _LARGE_FILES)
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_LARGEFILE_SOURCE -D_LARGE_FILES")
# MSVC may need workarounds for C99 restrict and inline
@@ -158,7 +161,7 @@ IF(MSVC)
CHECK_C_SOURCE_COMPILES("int *restrict foo;
int main() {return 0;}" HAVE_RESTRICT)
IF(NOT HAVE_RESTRICT)
- ADD_DEFINITIONS("-Drestrict=")
+ SET(CPP_DEFS ${CPP_DEFS} "restrict=")
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Drestrict=")
ENDIF()
@@ -171,7 +174,7 @@ IF(MSVC)
MESSAGE(FATAL_ERROR "No inline keyword found, please report!")
ENDIF()
- ADD_DEFINITIONS(-Dinline=__inline)
+ SET(CPP_DEFS ${CPP_DEFS} inline=__inline)
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Dinline=__inline")
ENDIF()
ENDIF()
@@ -198,7 +201,7 @@ ENDIF()
CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_sec time.h HAVE_STRUCT_TIMESPEC)
IF(HAVE_STRUCT_TIMESPEC)
# Define it here so we don't have to include config.h for it
- ADD_DEFINITIONS("-DHAVE_STRUCT_TIMESPEC")
+ SET(CPP_DEFS ${CPP_DEFS} HAVE_STRUCT_TIMESPEC)
ENDIF()
# Some systems may need libatomic for C11 atomic functions to work
@@ -288,11 +291,9 @@ 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)
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} /wd4098")
+ SET(CPP_DEFS ${CPP_DEFS} _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+ SET(C_FLAGS ${C_FLAGS} /wd4098)
IF(NOT DXSDK_DIR)
STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}")
@@ -314,14 +315,14 @@ IF(MSVC)
ENDFOREACH(flag_var)
ENDIF()
ELSE()
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Winline -Wall")
+ SET(C_FLAGS ${C_FLAGS} -Winline -Wall)
CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
IF(HAVE_W_EXTRA)
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wextra")
+ SET(C_FLAGS ${C_FLAGS} -Wextra)
ENDIF()
IF(ALSOFT_WERROR)
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
+ SET(C_FLAGS ${C_FLAGS} -Werror)
ENDIF()
# We want RelWithDebInfo to actually include debug stuff (define _DEBUG
@@ -334,7 +335,7 @@ ELSE()
CHECK_C_COMPILER_FLAG(-fno-math-errno HAVE_FNO_MATH_ERRNO)
IF(HAVE_FNO_MATH_ERRNO)
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fno-math-errno")
+ SET(C_FLAGS ${C_FLAGS} -fno-math-errno)
ENDIF()
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
@@ -353,7 +354,7 @@ int main()
HAVE_STATIC_LIBGCC_SWITCH
)
if(HAVE_STATIC_LIBGCC_SWITCH)
- set(EXTRA_LDFLAGS "${EXTRA_LDFLAGS} -static-libgcc")
+ SET(LINKER_FLAGS ${LINKER_FLAGS} -static-libgcc)
endif()
set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
unset(OLD_REQUIRED_LIBRARIES)
@@ -388,7 +389,7 @@ 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)
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+ SET(C_FLAGS ${C_FLAGS} -fvisibility=hidden)
ENDIF()
ENDIF()
@@ -461,9 +462,10 @@ IF(NOT HAVE_GUIDDEF_H)
ENDIF()
# Some systems need libm for some of the following math functions to work
+SET(MATH_LIB )
CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
IF(HAVE_LIBM)
- SET(EXTRA_LIBS m ${EXTRA_LIBS})
+ SET(MATH_LIB ${MATH_LIB} m)
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
ENDIF()
@@ -524,7 +526,7 @@ IF(NOT HAVE_STRCASECMP)
MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
ENDIF()
- ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
+ SET(CPP_DEFS ${CPP_DEFS} strcasecmp=_stricmp)
ENDIF()
CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
@@ -534,7 +536,7 @@ IF(NOT HAVE_STRNCASECMP)
MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
ENDIF()
- ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
+ SET(CPP_DEFS ${CPP_DEFS} strncasecmp=_strnicmp)
ENDIF()
CHECK_SYMBOL_EXISTS(strnlen string.h HAVE_STRNLEN)
@@ -545,7 +547,7 @@ IF(NOT HAVE_SNPRINTF)
MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
ENDIF()
- ADD_DEFINITIONS(-Dsnprintf=_snprintf)
+ SET(CPP_DEFS ${CPP_DEFS} snprintf=_snprintf)
ENDIF()
CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
@@ -556,9 +558,9 @@ IF(NOT HAVE_ISFINITE)
IF(NOT HAVE__FINITE)
MESSAGE(FATAL_ERROR "No isfinite function found, please report!")
ENDIF()
- ADD_DEFINITIONS(-Disfinite=_finite)
+ SET(CPP_DEFS ${CPP_DEFS} isfinite=_finite)
ELSE()
- ADD_DEFINITIONS(-Disfinite=finite)
+ SET(CPP_DEFS ${CPP_DEFS} isfinite=finite)
ENDIF()
ENDIF()
@@ -569,7 +571,7 @@ IF(NOT HAVE_ISNAN)
MESSAGE(FATAL_ERROR "No isnan function found, please report!")
ENDIF()
- ADD_DEFINITIONS(-Disnan=_isnan)
+ SET(CPP_DEFS ${CPP_DEFS} isnan=_isnan)
ENDIF()
@@ -596,9 +598,9 @@ IF(NOT HAVE_WINDOWS_H)
CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
IF(HAVE_PTHREAD)
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread")
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
- SET(EXTRA_LDFLAGS "${EXTRA_LDFLAGS} -pthread")
+ SET(C_FLAGS ${C_FLAGS} -pthread)
+ SET(LINKER_FLAGS ${LINKER_FLAGS} -pthread)
ENDIF()
CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
@@ -889,6 +891,7 @@ IF(ALSA_FOUND)
SET(BACKENDS "${BACKENDS} ALSA${IS_LINKED},")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c)
ADD_BACKEND_LIBS(${ALSA_LIBRARIES})
+ SET(INC_PATHS ${INC_PATHS} ${ALSA_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_ALSA AND NOT HAVE_ALSA)
@@ -907,6 +910,7 @@ IF(OSS_FOUND)
IF(OSS_LIBRARIES)
SET(EXTRA_LIBS ${OSS_LIBRARIES} ${EXTRA_LIBS})
ENDIF()
+ SET(INC_PATHS ${INC_PATHS} ${OSS_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_OSS AND NOT HAVE_OSS)
@@ -922,6 +926,7 @@ IF(AUDIOIO_FOUND)
SET(HAVE_SOLARIS 1)
SET(BACKENDS "${BACKENDS} Solaris,")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c)
+ SET(INC_PATHS ${INC_PATHS} ${AUDIOIO_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_SOLARIS AND NOT HAVE_SOLARIS)
@@ -938,6 +943,7 @@ IF(SOUNDIO_FOUND)
SET(BACKENDS "${BACKENDS} SndIO (linked),")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c)
SET(EXTRA_LIBS ${SOUNDIO_LIBRARIES} ${EXTRA_LIBS})
+ SET(INC_PATHS ${INC_PATHS} ${SOUNDIO_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_SNDIO AND NOT HAVE_SNDIO)
@@ -954,6 +960,7 @@ IF(QSA_FOUND)
SET(BACKENDS "${BACKENDS} QSA (linked),")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/qsa.c)
SET(EXTRA_LIBS ${QSA_LIBRARIES} ${EXTRA_LIBS})
+ SET(INC_PATHS ${INC_PATHS} ${QSA_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_QSA AND NOT HAVE_QSA)
@@ -989,6 +996,7 @@ IF(HAVE_WINDOWS_H)
SET(BACKENDS "${BACKENDS} DirectSound${IS_LINKED},")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c)
ADD_BACKEND_LIBS(${DSOUND_LIBRARIES})
+ SET(INC_PATHS ${INC_PATHS} ${DSOUND_INCLUDE_DIRS})
ENDIF()
ENDIF()
@@ -1023,6 +1031,7 @@ IF(PORTAUDIO_FOUND)
SET(BACKENDS "${BACKENDS} PortAudio${IS_LINKED},")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c)
ADD_BACKEND_LIBS(${PORTAUDIO_LIBRARIES})
+ SET(INC_PATHS ${INC_PATHS} ${PORTAUDIO_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO)
@@ -1039,6 +1048,7 @@ IF(PULSEAUDIO_FOUND)
SET(BACKENDS "${BACKENDS} PulseAudio${IS_LINKED},")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c)
ADD_BACKEND_LIBS(${PULSEAUDIO_LIBRARIES})
+ SET(INC_PATHS ${INC_PATHS} ${PULSEAUDIO_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO)
@@ -1055,6 +1065,7 @@ IF(JACK_FOUND)
SET(BACKENDS "${BACKENDS} JACK${IS_LINKED},")
SET(ALC_OBJS ${ALC_OBJS} Alc/backends/jack.c)
ADD_BACKEND_LIBS(${JACK_LIBRARIES})
+ SET(INC_PATHS ${INC_PATHS} ${JACK_INCLUDE_DIRS})
ENDIF()
ENDIF()
IF(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK)
@@ -1203,11 +1214,6 @@ IF(ALSOFT_EXAMPLES)
ENDIF()
ENDIF()
-IF(LIBTYPE STREQUAL "STATIC")
- ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
- SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
-ENDIF()
-
IF(NOT WIN32)
SET(LIBNAME "openal")
ELSE()
@@ -1221,6 +1227,9 @@ SET(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
SET(bindir "\${exec_prefix}/${CMAKE_INSTALL_BINDIR}")
SET(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
SET(PACKAGE_VERSION "${LIB_VERSION}")
+IF(LIBTYPE STREQUAL "STATIC")
+ SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS})
+ENDIF()
# End configuration
CONFIGURE_FILE(
@@ -1231,31 +1240,32 @@ CONFIGURE_FILE(
"${OpenAL_BINARY_DIR}/openal.pc"
@ONLY)
-MACRO(ADD_INCLUDE_DIRS TRGT TESTVAR INCVAR)
- IF(${TESTVAR})
- SET_PROPERTY(TARGET ${TRGT} APPEND PROPERTY INCLUDE_DIRECTORIES ${${INCVAR}})
- ENDIF()
-ENDMACRO()
-
UNSET(HAS_ROUTER)
SET(IMPL_TARGET OpenAL)
+SET(SUBSYS_FLAG )
# Build main library
IF(LIBTYPE STREQUAL "STATIC")
+ SET(CPP_DEFS ${CPP_DEFS} AL_LIBTYPE_STATIC)
+ IF(WIN32 AND ALSOFT_NO_UID_DEFS)
+ SET(CPP_DEFS ${CPP_DEFS} AL_NO_UID_DEFS)
+ ENDIF()
ADD_LIBRARY(OpenAL STATIC ${COMMON_OBJS} ${OPENAL_OBJS} ${ALC_OBJS})
ELSE()
- IF(WIN32 AND ALSOFT_BUILD_ROUTER)
- ADD_LIBRARY(OpenAL SHARED router/router.c router/alc.c router/al.c ${COMMON_OBJS})
- SET_PROPERTY(TARGET OpenAL APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
- SET_PROPERTY(TARGET OpenAL APPEND PROPERTY
- COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES
- )
- SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS ${EXTRA_LDFLAGS})
+ IF(WIN32)
IF(MSVC)
- SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS " /SUBSYSTEM:WINDOWS")
+ SET(SUBSYS_FLAG ${SUBSYS_FLAG} "/SUBSYSTEM:WINDOWS")
ELSEIF(CMAKE_COMPILER_IS_GNUCC)
- SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS " -mwindows")
+ SET(SUBSYS_FLAG ${SUBSYS_FLAG} "-mwindows")
ENDIF()
+ ENDIF()
+
+ IF(WIN32 AND ALSOFT_BUILD_ROUTER)
+ ADD_LIBRARY(OpenAL SHARED router/router.c router/alc.c router/al.c ${COMMON_OBJS})
+ TARGET_COMPILE_DEFINITIONS(OpenAL
+ PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES ${CPP_DEFS})
+ TARGET_COMPILE_OPTIONS(OpenAL PRIVATE ${C_FLAGS})
+ TARGET_LINK_LIBRARIES(OpenAL PRIVATE ${LINKER_FLAGS})
SET_TARGET_PROPERTIES(OpenAL PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(OpenAL PROPERTIES OUTPUT_NAME ${LIBNAME})
IF(TARGET build_version)
@@ -1276,62 +1286,36 @@ SET_TARGET_PROPERTIES(${IMPL_TARGET} PROPERTIES OUTPUT_NAME ${LIBNAME}
VERSION ${LIB_VERSION}
SOVERSION ${LIB_MAJOR_VERSION}
)
-SET_PROPERTY(TARGET ${IMPL_TARGET} APPEND PROPERTY INCLUDE_DIRECTORIES
- "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc"
-)
-ADD_INCLUDE_DIRS(${IMPL_TARGET} HAVE_ALSA ALSA_INCLUDE_DIRS)
-ADD_INCLUDE_DIRS(${IMPL_TARGET} HAVE_OSS OSS_INCLUDE_DIRS)
-ADD_INCLUDE_DIRS(${IMPL_TARGET} HAVE_SOLARIS AUDIOIO_INCLUDE_DIRS)
-ADD_INCLUDE_DIRS(${IMPL_TARGET} HAVE_SNDIO SOUNDIO_INCLUDE_DIRS)
-ADD_INCLUDE_DIRS(${IMPL_TARGET} HAVE_QSA QSA_INCLUDE_DIRS)
-ADD_INCLUDE_DIRS(${IMPL_TARGET} HAVE_DSOUND DSOUND_INCLUDE_DIRS)
-ADD_INCLUDE_DIRS(${IMPL_TARGET} HAVE_PORTAUDIO PORTAUDIO_INCLUDE_DIRS)
-ADD_INCLUDE_DIRS(${IMPL_TARGET} HAVE_PULSEAUDIO PULSEAUDIO_INCLUDE_DIRS)
-ADD_INCLUDE_DIRS(${IMPL_TARGET} HAVE_JACK JACK_INCLUDE_DIRS)
-SET_PROPERTY(TARGET ${IMPL_TARGET} APPEND PROPERTY
- COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES
-)
-IF(WIN32 AND ALSOFT_NO_UID_DEFS)
- SET_PROPERTY(TARGET ${IMPL_TARGET} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
-ENDIF()
-SET_PROPERTY(TARGET ${IMPL_TARGET} APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
-SET_PROPERTY(TARGET ${IMPL_TARGET} APPEND_STRING PROPERTY LINK_FLAGS ${EXTRA_LDFLAGS})
-
-TARGET_LINK_LIBRARIES(${IMPL_TARGET} ${EXTRA_LIBS})
+TARGET_COMPILE_DEFINITIONS(${IMPL_TARGET}
+ PRIVATE AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES ${CPP_DEFS})
+TARGET_INCLUDE_DIRECTORIES(${IMPL_TARGET}
+ PRIVATE "${OpenAL_SOURCE_DIR}/OpenAL32/Include" "${OpenAL_SOURCE_DIR}/Alc" ${INC_PATHS})
+TARGET_COMPILE_OPTIONS(${IMPL_TARGET} PRIVATE ${C_FLAGS})
+TARGET_LINK_LIBRARIES(${IMPL_TARGET} PRIVATE ${LINKER_FLAGS} ${EXTRA_LIBS} ${MATH_LIB})
IF(TARGET build_version)
ADD_DEPENDENCIES(${IMPL_TARGET} build_version)
ENDIF()
-IF(WIN32)
- IF(MSVC)
- SET_PROPERTY(TARGET ${IMPL_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " /SUBSYSTEM:WINDOWS")
- ELSEIF(CMAKE_COMPILER_IS_GNUCC)
- SET_PROPERTY(TARGET ${IMPL_TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -mwindows")
- ENDIF()
-
- if(NOT LIBTYPE STREQUAL "STATIC")
- IF(MINGW AND ALSOFT_BUILD_IMPORT_LIB)
- FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
- FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
- IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
- MESSAGE(STATUS "")
- IF(NOT SED_EXECUTABLE)
- MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
- ENDIF()
- IF(NOT DLLTOOL_EXECUTABLE)
- MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
- ENDIF()
- ELSE()
- 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()
+IF(WIN32 AND MINGW AND ALSOFT_BUILD_IMPORT_LIB AND NOT LIBTYPE STREQUAL "STATIC")
+ FIND_PROGRAM(SED_EXECUTABLE NAMES sed DOC "sed executable")
+ FIND_PROGRAM(DLLTOOL_EXECUTABLE NAMES "${DLLTOOL}" DOC "dlltool executable")
+ IF(NOT SED_EXECUTABLE OR NOT DLLTOOL_EXECUTABLE)
+ MESSAGE(STATUS "")
+ IF(NOT SED_EXECUTABLE)
+ MESSAGE(STATUS "WARNING: Cannot find sed, disabling .def/.lib generation")
+ ENDIF()
+ IF(NOT DLLTOOL_EXECUTABLE)
+ MESSAGE(STATUS "WARNING: Cannot find dlltool, disabling .def/.lib generation")
ENDIF()
+ ELSE()
+ 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()
@@ -1429,17 +1413,18 @@ 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 OpenAL)
+ TARGET_COMPILE_OPTIONS(openal-info PRIVATE ${C_FLAGS})
+ TARGET_LINK_LIBRARIES(openal-info PRIVATE ${LINKER_FLAGS} OpenAL)
SET(MAKEHRTF_SRCS utils/makehrtf.c)
IF(NOT HAVE_GETOPT)
SET(MAKEHRTF_SRCS ${MAKEHRTF_SRCS} utils/getopt.c)
ENDIF()
ADD_EXECUTABLE(makehrtf ${MAKEHRTF_SRCS})
- SET_PROPERTY(TARGET makehrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
+ TARGET_COMPILE_DEFINITIONS(makehrtf PRIVATE ${CPP_DEFS})
+ TARGET_COMPILE_OPTIONS(makehrtf PRIVATE ${C_FLAGS})
IF(HAVE_LIBM)
- TARGET_LINK_LIBRARIES(makehrtf m)
+ TARGET_LINK_LIBRARIES(makehrtf PRIVATE ${LINKER_FLAGS} m)
ENDIF()
IF(ALSOFT_INSTALL)
@@ -1461,8 +1446,9 @@ IF(ALSOFT_TESTS)
SET(TEST_COMMON_OBJS examples/common/alhelpers.c)
ADD_EXECUTABLE(altonegen examples/altonegen.c ${COMMON_OBJS} ${TEST_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(altonegen OpenAL)
- SET_PROPERTY(TARGET altonegen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
+ TARGET_COMPILE_DEFINITIONS(altonegen PRIVATE ${CPP_DEFS})
+ TARGET_COMPILE_OPTIONS(altonegen PRIVATE ${C_FLAGS})
+ TARGET_LINK_LIBRARIES(altonegen PRIVATE ${LINKER_FLAGS} OpenAL ${MATH_LIB})
IF(ALSOFT_INSTALL)
INSTALL(TARGETS altonegen
@@ -1478,8 +1464,9 @@ ENDIF()
IF(ALSOFT_EXAMPLES)
ADD_EXECUTABLE(alrecord examples/alrecord.c ${COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alrecord OpenAL)
- SET_PROPERTY(TARGET alrecord APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
+ TARGET_COMPILE_DEFINITIONS(alrecord PRIVATE ${CPP_DEFS})
+ TARGET_COMPILE_OPTIONS(alrecord PRIVATE ${C_FLAGS})
+ TARGET_LINK_LIBRARIES(alrecord PRIVATE ${LINKER_FLAGS} OpenAL)
IF(ALSOFT_INSTALL)
INSTALL(TARGETS alrecord
@@ -1496,46 +1483,52 @@ IF(ALSOFT_EXAMPLES)
SET(EX_COMMON_OBJS examples/common/alhelpers.c)
ADD_EXECUTABLE(alplay examples/alplay.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alplay ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
- SET_PROPERTY(TARGET alplay APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
- SET_PROPERTY(TARGET alplay APPEND PROPERTY
- INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
- )
+ TARGET_COMPILE_DEFINITIONS(alplay PRIVATE ${CPP_DEFS})
+ TARGET_INCLUDE_DIRECTORIES(alplay
+ PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
+ TARGET_COMPILE_OPTIONS(alplay PRIVATE ${C_FLAGS})
+ TARGET_LINK_LIBRARIES(alplay
+ PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
ADD_EXECUTABLE(alstream examples/alstream.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alstream ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} 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}
- )
+ TARGET_COMPILE_DEFINITIONS(alstream PRIVATE ${CPP_DEFS})
+ TARGET_INCLUDE_DIRECTORIES(alstream
+ PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
+ TARGET_COMPILE_OPTIONS(alstream PRIVATE ${C_FLAGS})
+ TARGET_LINK_LIBRARIES(alstream
+ PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
ADD_EXECUTABLE(alreverb examples/alreverb.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alreverb ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} 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}
- )
+ TARGET_COMPILE_DEFINITIONS(alreverb PRIVATE ${CPP_DEFS})
+ TARGET_INCLUDE_DIRECTORIES(alreverb
+ PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
+ TARGET_COMPILE_OPTIONS(alreverb PRIVATE ${C_FLAGS})
+ TARGET_LINK_LIBRARIES(alreverb
+ PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
ADD_EXECUTABLE(allatency examples/allatency.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(allatency ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} 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}
- )
+ TARGET_COMPILE_DEFINITIONS(allatency PRIVATE ${CPP_DEFS})
+ TARGET_INCLUDE_DIRECTORIES(allatency
+ PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
+ TARGET_COMPILE_OPTIONS(allatency PRIVATE ${C_FLAGS})
+ TARGET_LINK_LIBRARIES(allatency
+ PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
ADD_EXECUTABLE(alloopback examples/alloopback.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alloopback ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} 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}
- )
+ TARGET_COMPILE_DEFINITIONS(alloopback PRIVATE ${CPP_DEFS})
+ TARGET_INCLUDE_DIRECTORIES(alloopback
+ PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
+ TARGET_COMPILE_OPTIONS(alloopback PRIVATE ${C_FLAGS})
+ TARGET_LINK_LIBRARIES(alloopback
+ PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL ${MATH_LIB})
ADD_EXECUTABLE(alhrtf examples/alhrtf.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alhrtf ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} 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}
- )
+ TARGET_COMPILE_DEFINITIONS(alhrtf PRIVATE ${CPP_DEFS})
+ TARGET_INCLUDE_DIRECTORIES(alhrtf
+ PRIVATE ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
+ TARGET_COMPILE_OPTIONS(alhrtf PRIVATE ${C_FLAGS})
+ TARGET_LINK_LIBRARIES(alhrtf
+ PRIVATE ${LINKER_FLAGS} ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL ${MATH_LIB})
IF(ALSOFT_INSTALL)
INSTALL(TARGETS alplay alstream alreverb allatency alloopback alhrtf
@@ -1574,11 +1567,12 @@ IF(ALSOFT_EXAMPLES)
ENDIF()
IF(FFVER_OK)
ADD_EXECUTABLE(alffplay examples/alffplay.cpp ${COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alffplay ${SDL2_LIBRARY} ${FFMPEG_LIBRARIES} OpenAL)
- SET_PROPERTY(TARGET alffplay APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
- SET_PROPERTY(TARGET alffplay APPEND PROPERTY
- INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS}
- )
+ TARGET_COMPILE_DEFINITIONS(alffplay PRIVATE ${CPP_DEFS})
+ TARGET_INCLUDE_DIRECTORIES(alffplay
+ PRIVATE ${SDL2_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS})
+ TARGET_COMPILE_OPTIONS(alffplay PRIVATE ${C_FLAGS})
+ TARGET_LINK_LIBRARIES(alffplay
+ PRIVATE ${LINKER_FLAGS} ${SDL2_LIBRARY} ${FFMPEG_LIBRARIES} OpenAL)
IF(ALSOFT_INSTALL)
INSTALL(TARGETS alffplay
diff --git a/native-tools/CMakeLists.txt b/native-tools/CMakeLists.txt
index c3055f8d..5e816bba 100644
--- a/native-tools/CMakeLists.txt
+++ b/native-tools/CMakeLists.txt
@@ -4,8 +4,9 @@ project(native-tools)
include(CheckLibraryExists)
+set(CPP_DEFS )
if(WIN32)
- add_definitions("-D_WIN32")
+ set(CPP_DEFS ${CPP_DEFS} _WIN32)
endif(WIN32)
check_library_exists(m pow "" HAVE_LIBM)
@@ -16,11 +17,13 @@ set_target_properties(bin2h PROPERTIES OUTPUT_NAME bin2h)
# Avoid configuration-dependent subdirectories while building with Visual Studio
set_target_properties(bin2h PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}")
set_target_properties(bin2h PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}")
+target_compile_definitions(bin2h PRIVATE ${CPP_DEFS})
add_executable(bsincgen bsincgen.c)
set_target_properties(bsincgen PROPERTIES OUTPUT_NAME bsincgen)
set_target_properties(bsincgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}")
set_target_properties(bsincgen PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}")
+target_compile_definitions(bsincgen PRIVATE ${CPP_DEFS})
if(HAVE_LIBM)
target_link_libraries(bsincgen m)
endif(HAVE_LIBM)