1 cmake_minimum_required(VERSION 2.6)
3 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
5 include(CheckCCompilerFlag)
6 include(CheckIncludeFile)
12 IF(NOT CMAKE_BUILD_TYPE)
13 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
14 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
18 set(DSOAL_OBJS buffer.c
26 find_package(OpenAL REQUIRED)
27 include_directories("${DSOAL_BINARY_DIR}" ${OPENAL_INCLUDE_DIR})
30 add_definitions(-Winline -Wall)
31 check_c_compiler_flag(-Wextra HAVE_W_EXTRA)
33 add_definitions(-Wextra)
36 check_c_compiler_flag(-Wformat=0 HAVE_W_FORMAT_ZERO)
37 if(HAVE_W_FORMAT_ZERO)
38 add_definitions(-Wformat=0)
44 check_include_file(dsound.h HAVE_DSOUND_H)
46 message(FATAL_ERROR "Could not find dsound.h")
49 add_definitions(-D_WIN32 -DDEBUG_INFO)
51 set(DSOAL_OBJS ${DSOAL_OBJS} debug.c)
53 add_library(${LIBNAME} SHARED ${DSOAL_OBJS})
54 target_link_libraries(${LIBNAME} ${OPENAL_LIBRARY} dxguid uuid winmm ole32 dxerr8)
55 set_target_properties(${LIBNAME} PROPERTIES PREFIX ""
56 LINK_FLAGS "${DSOAL_SOURCE_DIR}/dsound-mingw.def")
58 find_path(WINE_DIR include/wine/library.h
59 PATHS /usr /usr/local)
61 message(FATAL_ERROR "Could not find Wine installation directory")
63 message(STATUS "Found Wine installation directory - ${WINE_DIR}")
64 add_definitions(-D__WINESRC__ "-I${WINE_DIR}/include/wine" "-I${WINE_DIR}/include/wine/windows")
65 set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}" "${WINE_DIR}/include/wine" "${WINE_DIR}/include/wine/windows")
67 check_include_file(dsound.h HAVE_DSOUND_H)
69 message(FATAL_ERROR "Could not find dsound.h")
72 add_library(dsoal STATIC ${DSOAL_OBJS})
73 set_target_properties(dsoal PROPERTIES PREFIX "lib" SUFFIX ".a"
77 foreach(SRC ${DSOAL_OBJS})
78 string(REGEX REPLACE ".c" ".o" OBJ "${SRC}")
79 set(OBJECT_FILES "${OBJECT_FILES}" "${OBJ}")
82 add_custom_command(TARGET dsoal POST_BUILD
83 COMMAND wrc --nostdinc -D__WINESRC__ "-I${DSOAL_BINARY_DIR}" "-I${WINE_DIR}/include/wine" "-I${WINE_DIR}/include/wine/windows" -foversion.res ${DSOAL_SOURCE_DIR}/version.rc
84 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}/CMakeFiles/dsoal.dir"
85 COMMENT "Generating version.res..." VERBATIM)
86 add_custom_command(TARGET dsoal POST_BUILD
87 COMMAND winegcc -shared "${DSOAL_SOURCE_DIR}/dsound.spec" version.res -o "${DSOAL_BINARY_DIR}/dsound.dll.so" "${DSOAL_BINARY_DIR}/libdsoal.a" -lopenal -ldxguid -luuid -lwinmm -lole32 -ldxerr8
88 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}/CMakeFiles/dsoal.dir"
89 COMMENT "Linking C shared library dsound.dll.so" VERBATIM)
90 add_custom_command(TARGET dsoal POST_BUILD
91 COMMAND winegcc -shared "${DSOAL_SOURCE_DIR}/dsound.spec" version.res -o "${DSOAL_BINARY_DIR}/dsound.dll.fake" "${DSOAL_BINARY_DIR}/libdsoal.a" -lopenal -ldxguid -luuid -lwinmm -lole32 -ldxerr8
92 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}/CMakeFiles/dsoal.dir"
93 COMMENT "Linking C shared library dsound.dll.fake" VERBATIM)