1 cmake_minimum_required(VERSION 2.6)
3 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
5 include(CheckCCompilerFlag)
11 IF(NOT CMAKE_BUILD_TYPE)
12 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
13 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
17 set(DSOAL_OBJS buffer.c
27 include_directories("${DSOAL_BINARY_DIR}" ${OPENAL_INCLUDE_DIR})
30 add_definitions(-D_WIN32 -DDEBUG_INFO)
32 add_definitions(-Winline -Wall)
33 check_c_compiler_flag(-Wextra HAVE_W_EXTRA)
35 add_definitions(-Wextra)
37 check_c_compiler_flag(-Wformat=0 HAVE_W_FORMAT_ZERO)
38 if(HAVE_W_FORMAT_ZERO)
39 add_definitions(-Wformat=0)
43 set(DSOAL_OBJS ${DSOAL_OBJS} debug.c)
45 add_library(${LIBNAME} SHARED ${DSOAL_OBJS})
46 target_link_libraries(${LIBNAME} ${OPENAL_LIBRARY} dxguid uuid winmm ole32 dxerr8)
47 set_target_properties(${LIBNAME} PROPERTIES PREFIX ""
48 LINK_FLAGS "${DSOAL_SOURCE_DIR}/dsound-mingw.def")
50 find_path(WINE_INCLUDE_DIR library.h
53 /usr/local/include/wine)
54 if(NOT WINE_INCLUDE_DIR)
55 message(FATAL_ERROR "Could not find Wine header files" )
57 message(STATUS "Found Wine header files - ${WINE_INCLUDE_DIR}" )
59 set(DSOAL_CPP_FLAGS -D__WINESRC__ "-I${DSOAL_BINARY_DIR}" "-I${OPENAL_INCLUDE_DIR}")
60 set(DSOAL_C_FLAGS -g -O2 -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Wstrict-prototypes -Wwrite-strings -Wtype-limits -Wpointer-arith)
62 add_custom_command(OUTPUT version.res
63 COMMAND wrc --nostdinc ${DSOAL_CPP_FLAGS} "-I${WINE_INCLUDE_DIR}" "-I${WINE_INCLUDE_DIR}/windows" -foversion.res ${DSOAL_SOURCE_DIR}/version.rc
64 DEPENDS "${DSOAL_SOURCE_DIR}/version.rc"
65 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}/CMakeFiles/dsound.dir"
66 COMMENT "Generating version.res..." VERBATIM)
69 foreach(SRC ${DSOAL_OBJS})
70 string(REGEX REPLACE ".c" ".o" OBJ "${SRC}")
71 add_custom_command(OUTPUT "${OBJ}"
72 COMMAND winegcc ${DSOAL_CPP_FLAGS} ${DSOAL_C_FLAGS} -o "${OBJ}" -c "${DSOAL_SOURCE_DIR}/${SRC}"
73 DEPENDS "${DSOAL_SOURCE_DIR}/${SRC}"
74 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}/CMakeFiles/dsound.dir"
75 COMMENT "Building C object CMakeFiles/dsound.dir/${OBJ}" VERBATIM)
76 set(OBJECT_FILES "${OBJECT_FILES}" "${OBJ}")
79 add_custom_command(OUTPUT "${DSOAL_BINARY_DIR}/dsound.dll.so"
80 COMMAND winegcc -shared "${DSOAL_SOURCE_DIR}/dsound.spec" ${OBJECT_FILES} version.res -o "${DSOAL_BINARY_DIR}/dsound.dll.so" -lopenal -ldxguid -luuid -lwinmm -lole32 -ldxerr8
81 DEPENDS ${OBJECT_FILES} version.res
82 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}/CMakeFiles/dsound.dir"
83 COMMENT "Linking C shared library dsound.dll.so" VERBATIM)
85 add_custom_target(dsound ALL DEPENDS "${DSOAL_BINARY_DIR}/dsound.dll.so")