1 cmake_minimum_required(VERSION 2.6)
3 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
9 IF(NOT CMAKE_BUILD_TYPE)
10 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
11 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
15 set(DSOAL_OBJS buffer.c
25 include_directories("${DSOAL_BINARY_DIR}" ${OPENAL_INCLUDE_DIR})
28 add_definitions(-D_WIN32 -DDEBUG_INFO)
30 set(DSOAL_OBJS ${DSOAL_OBJS} debug.c)
32 add_library(${LIBNAME} SHARED ${DSOAL_OBJS})
33 target_link_libraries(${LIBNAME} ${OPENAL_LIBRARY} dxguid uuid winmm ole32 dxerr8)
34 set_target_properties(${LIBNAME} PROPERTIES PREFIX ""
35 LINK_FLAGS "${DSOAL_SOURCE_DIR}/dsound-mingw.def")
37 find_path(WINE_INCLUDE_DIR library.h
40 /usr/local/include/wine)
41 if(NOT WINE_INCLUDE_DIR)
42 message(FATAL_ERROR "Could not find Wine header files" )
44 message(STATUS "Found Wine header files - ${WINE_INCLUDE_DIR}" )
46 set(DSOAL_CPP_FLAGS -D__WINESRC__ "-I${DSOAL_BINARY_DIR}" "-I${OPENAL_INCLUDE_DIR}")
47 set(DSOAL_C_FLAGS -g -O2 -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Wstrict-prototypes -Wwrite-strings -Wtype-limits -Wpointer-arith)
49 add_custom_command(OUTPUT version.res
50 COMMAND wrc --nostdinc ${DSOAL_CPP_FLAGS} "-I${WINE_INCLUDE_DIR}" "-I${WINE_INCLUDE_DIR}/windows" -foversion.res ${DSOAL_SOURCE_DIR}/version.rc
51 DEPENDS "${DSOAL_SOURCE_DIR}/version.rc"
52 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}/CMakeFiles/dsound.dir"
53 COMMENT "Generating version.res..." VERBATIM)
56 foreach(SRC ${DSOAL_OBJS})
57 string(REGEX REPLACE ".c" ".o" OBJ "${SRC}")
58 add_custom_command(OUTPUT "${OBJ}"
59 COMMAND winegcc ${DSOAL_CPP_FLAGS} ${DSOAL_C_FLAGS} -o "${OBJ}" -c "${DSOAL_SOURCE_DIR}/${SRC}"
60 DEPENDS "${DSOAL_SOURCE_DIR}/${SRC}"
61 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}/CMakeFiles/dsound.dir"
62 COMMENT "Building C object CMakeFiles/dsound.dir/${OBJ}" VERBATIM)
63 set(OBJECT_FILES "${OBJECT_FILES}" "${OBJ}")
66 add_custom_command(OUTPUT "${DSOAL_BINARY_DIR}/dsound.dll.so"
67 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
68 DEPENDS ${OBJECT_FILES} version.res
69 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}/CMakeFiles/dsound.dir"
70 COMMENT "Linking C shared library dsound.dll.so" VERBATIM)
72 add_custom_target(dsound ALL DEPENDS "${DSOAL_BINARY_DIR}/dsound.dll.so")