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
35 set(DSOAL_INC ${DSOAL_INC} ${DSOAL_BINARY_DIR} ${DSOAL_SOURCE_DIR}/include/AL)
38 check_type_size("long" SIZEOF_LONG)
39 set(DSOAL_DEFS ${DSOAL_DEFS} "SIZEOF_LONG=${SIZEOF_LONG}")
41 check_c_source_compiles("#include <intrin.h>
44 unsigned long idx = 0;
45 _BitScanForward64(&idx, 1);
47 }" HAVE_BITSCANFORWARD64_INTRINSIC)
48 if(HAVE_BITSCANFORWARD64_INTRINSIC)
49 set(DSOAL_DEFS ${DSOAL_DEFS} HAVE_BITSCANFORWARD64_INTRINSIC)
51 check_c_source_compiles("#include <intrin.h>
54 unsigned long idx = 0;
55 _BitScanForward(&idx, 1);
57 }" HAVE_BITSCANFORWARD_INTRINSIC)
58 if(HAVE_BITSCANFORWARD_INTRINSIC)
59 set(DSOAL_DEFS ${DSOAL_DEFS} HAVE_BITSCANFORWARD_INTRINSIC)
65 set(DSOAL_FLAGS ${DSOAL_FLAGS} -Winline -Wall)
66 check_c_compiler_flag(-Wextra HAVE_W_EXTRA)
68 set(DSOAL_FLAGS ${DSOAL_FLAGS} -Wextra)
70 set(DSOAL_LIBS ${DSOAL_LIBS} -static-libgcc)
73 check_c_compiler_flag(-fvisibility=hidden HAVE_FVISIBILITY_HIDDEN)
74 if(HAVE_FVISIBILITY_HIDDEN)
75 set(DSOAL_FLAGS ${DSOAL_FLAGS} -fvisibility=hidden)
79 set(CMAKE_RC_COMPILER_INIT windres)
80 set(CMAKE_RC_COMPILE_OBJECT
81 "<CMAKE_RC_COMPILER> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
85 set(DSOAL_OBJS ${DSOAL_OBJS} debug.c version.rc)
87 set(DSOAL_DEFS ${DSOAL_DEFS} _WIN32 WINVER=0x0600 DEBUG_INFO)
89 set(DSOAL_LIBS ${DSOAL_LIBS} winmm ole32)
91 set(DSOAL_DEFS ${DSOAL_DEFS} COBJMACROS)
93 add_library(dsound SHARED ${DSOAL_OBJS} dsound.def)
95 set_target_properties(dsound PROPERTIES PREFIX "")
97 target_compile_definitions(dsound PRIVATE ${DSOAL_DEFS})
98 target_include_directories(dsound PRIVATE ${DSOAL_INC})
99 target_compile_options(dsound PRIVATE ${DSOAL_FLAGS})
100 target_link_libraries(dsound PRIVATE ${DSOAL_LIBS})