1 cmake_minimum_required(VERSION 2.6)
3 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
5 include(CheckCCompilerFlag)
6 include(CheckIncludeFile)
11 find_path(WINE_DIR include/wine/library.h
12 PATHS /usr /usr/local)
14 message(FATAL_ERROR "Could not find Wine installation directory")
16 message(STATUS "Found Wine installation directory - ${WINE_DIR}")
17 include_directories("${WINE_DIR}/include/wine" "${WINE_DIR}/include/wine/windows")
18 set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}" "${WINE_DIR}/include/wine" "${WINE_DIR}/include/wine/windows")
23 IF(NOT CMAKE_BUILD_TYPE)
24 SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
25 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
29 set(DSOAL_OBJS buffer.c
37 find_package(OpenAL REQUIRED)
38 include_directories("${DSOAL_BINARY_DIR}" ${OPENAL_INCLUDE_DIR})
41 add_definitions(-Winline -Wall)
42 check_c_compiler_flag(-Wextra HAVE_W_EXTRA)
44 add_definitions(-Wextra)
48 check_include_file(dsound.h HAVE_DSOUND_H)
50 message(FATAL_ERROR "Could not find dsound.h")
56 set(WINDRES "${HOST}-windres")
58 set(WINDRES "windres")
62 add_definitions(-D_WIN32 -DDEBUG_INFO)
64 set(DSOAL_OBJS ${DSOAL_OBJS} debug.c)
66 add_library(${LIBNAME} SHARED ${DSOAL_OBJS})
67 add_custom_command(TARGET ${LIBNAME} PRE_BUILD
68 COMMAND "${WINDRES}" -o version.o -i "${DSOAL_SOURCE_DIR}/version.rc"
69 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}"
70 COMMENT "Generating version.o" VERBATIM)
71 target_link_libraries(${LIBNAME} ${OPENAL_LIBRARY} dxguid uuid winmm ole32 dxerr8)
72 set_target_properties(${LIBNAME} PROPERTIES PREFIX ""
73 LINK_FLAGS "version.o ${DSOAL_SOURCE_DIR}/dsound-mingw.def")
75 add_definitions(-D__WINESRC__)
77 add_library(${LIBNAME} STATIC ${DSOAL_OBJS})
78 set_target_properties(${LIBNAME} PROPERTIES PREFIX "lib" SUFFIX ".a"
81 add_custom_command(TARGET ${LIBNAME} PRE_BUILD
82 COMMAND wrc --nostdinc -D__WINESRC__ "-I${WINE_DIR}/include/wine" "-I${WINE_DIR}/include/wine/windows" -foversion.res "${DSOAL_SOURCE_DIR}/version.rc"
83 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}"
84 COMMENT "Generating version.res" VERBATIM)
85 add_custom_command(TARGET ${LIBNAME} PRE_BUILD
86 COMMAND widl -D__WINESRC__ "-I${WINE_DIR}/include/wine" "-I${WINE_DIR}/include/wine/windows" -r -o "${LIBNAME}_classes_r.res" "${DSOAL_SOURCE_DIR}/${LIBNAME}_classes.idl"
87 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}"
88 COMMENT "Generating ${LIBNAME}_classes_r.res" VERBATIM)
89 add_custom_command(TARGET ${LIBNAME} PRE_LINK
90 COMMAND winebuild -w --def -o "lib${LIBNAME}.def" --export "${DSOAL_SOURCE_DIR}/${LIBNAME}.spec"
91 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}"
92 COMMENT "Generating lib${LIBNAME}.def" VERBATIM)
93 add_custom_command(TARGET ${LIBNAME} POST_BUILD
94 COMMAND winegcc -shared "${DSOAL_SOURCE_DIR}/${LIBNAME}.spec" "${LIBNAME}_classes_r.res" version.res -o "${LIBNAME}.dll.so" "lib${LIBNAME}.a" ${OPENAL_LIBRARY} -ldxguid -luuid -lwinmm -lole32 -ldxerr8
95 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}"
96 COMMENT "Linking Wine shared library ${LIBNAME}.dll.so" VERBATIM)
97 add_custom_command(TARGET ${LIBNAME} POST_BUILD
98 COMMAND winegcc -shared "${DSOAL_SOURCE_DIR}/${LIBNAME}.spec" "${LIBNAME}_classes_r.res" version.res -o "${LIBNAME}.dll.fake" "lib${LIBNAME}.a" ${OPENAL_LIBRARY} -ldxguid -luuid -lwinmm -lole32 -ldxerr8
99 WORKING_DIRECTORY "${DSOAL_BINARY_DIR}"
100 COMMENT "Creating ${LIBNAME}.dll.fake" VERBATIM)
102 install(FILES "${DSOAL_BINARY_DIR}/${LIBNAME}.dll.so"
103 DESTINATION "${WINE_DIR}/lib${LIB_SUFFIX}/wine")
104 install(FILES "${DSOAL_BINARY_DIR}/lib${LIBNAME}.def"
105 DESTINATION "${WINE_DIR}/lib${LIB_SUFFIX}/wine")
106 install(FILES "${DSOAL_BINARY_DIR}/${LIBNAME}.dll.fake"
107 DESTINATION "${WINE_DIR}/lib${LIB_SUFFIX}/wine/fakedlls"
108 RENAME ${LIBNAME}.dll)