Fix an ifdef check that accidentally got committed
[dsound-openal.git] / CMakeLists.txt
blobbe1e354981be3f7e8a853542654a8873682ef17b
1 cmake_minimum_required(VERSION 2.6)
3 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
5 project(DSOAL C)
7 set(LIBNAME dsound)
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."
12         FORCE)
13 ENDIF()
15 set(DSOAL_OBJS buffer.c
16                capture.c
17                dsound8.c
18                dsound_main.c
19                duplex.c
20                primary.c
21                propset.c
22                regsvr.c)
24 find_package(OpenAL)
25 include_directories("${DSOAL_BINARY_DIR}" ${OPENAL_INCLUDE_DIR})
27 if(WIN32)
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")
36 else()
37     find_path(WINE_INCLUDE_DIR library.h
38               PATHS
39               /usr/include/wine
40               /usr/local/include/wine)
41     if(NOT WINE_INCLUDE_DIR)
42         message(FATAL_ERROR "Could not find Wine header files" )
43     endif()
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)
55     set(OBJECT_FILES)
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}")
64     endforeach()
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")
73 endif()