1 cmake_minimum_required(VERSION 3.0.2)
3 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
5 include(CheckCCompilerFlag)
6 include(CheckCSourceCompiles)
8 include(CheckIncludeFile)
13 IF(NOT CMAKE_BUILD_TYPE)
14 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
15 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
24 set(DSOAL_OBJS buffer.c
34 set(DSOAL_INC ${DSOAL_INC} ${DSOAL_BINARY_DIR} ${DSOAL_SOURCE_DIR}/include/AL)
37 check_type_size("long" SIZEOF_LONG)
38 set(DSOAL_DEFS ${DSOAL_DEFS} "SIZEOF_LONG=${SIZEOF_LONG}")
40 check_c_source_compiles("#include <intrin.h>
43 unsigned long idx = 0;
44 _BitScanForward64(&idx, 1);
46 }" HAVE_BITSCANFORWARD64_INTRINSIC)
47 if(HAVE_BITSCANFORWARD64_INTRINSIC)
48 set(DSOAL_DEFS ${DSOAL_DEFS} HAVE_BITSCANFORWARD64_INTRINSIC)
50 check_c_source_compiles("#include <intrin.h>
53 unsigned long idx = 0;
54 _BitScanForward(&idx, 1);
56 }" HAVE_BITSCANFORWARD_INTRINSIC)
57 if(HAVE_BITSCANFORWARD_INTRINSIC)
58 set(DSOAL_DEFS ${DSOAL_DEFS} HAVE_BITSCANFORWARD_INTRINSIC)
64 set(DSOAL_FLAGS ${DSOAL_FLAGS} -Winline -Wall)
65 check_c_compiler_flag(-Wextra HAVE_W_EXTRA)
67 set(DSOAL_FLAGS ${DSOAL_FLAGS} -Wextra)
69 set(DSOAL_LIBS ${DSOAL_LIBS} -static-libgcc)
72 check_c_compiler_flag(-fvisibility=hidden HAVE_FVISIBILITY_HIDDEN)
73 if(HAVE_FVISIBILITY_HIDDEN)
74 set(DSOAL_FLAGS ${DSOAL_FLAGS} -fvisibility=hidden)
78 set(CMAKE_RC_COMPILER_INIT windres)
79 set(CMAKE_RC_COMPILE_OBJECT
80 "<CMAKE_RC_COMPILER> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
84 set(DSOAL_OBJS ${DSOAL_OBJS} debug.c version.rc)
86 set(DSOAL_DEFS ${DSOAL_DEFS} _WIN32 WINVER=0x0600 DEBUG_INFO)
88 set(DSOAL_LIBS ${DSOAL_LIBS} winmm ole32)
90 set(DSOAL_DEFS ${DSOAL_DEFS} COBJMACROS)
92 add_library(dsound SHARED ${DSOAL_OBJS} dsound.def)
94 set_target_properties(dsound PROPERTIES PREFIX "")
96 target_compile_definitions(dsound PRIVATE ${DSOAL_DEFS})
97 target_include_directories(dsound PRIVATE ${DSOAL_INC})
98 target_compile_options(dsound PRIVATE ${DSOAL_FLAGS})
99 target_link_libraries(dsound PRIVATE ${DSOAL_LIBS})