Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/freealut-1.1.0/CMakeLists.txt @ 21

Last change on this file since 21 was 14, checked in by landauf, 17 years ago

added freealut

File size: 7.0 KB
Line 
1# cmake project file by Prakash Punnoor
2CMAKE_MINIMUM_REQUIRED(VERSION 2.0)
3
4SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/admin/CMakeModules")
5PROJECT(Alut C)
6SET(PACKAGE "freealut")
7SET(PACKAGE_TARNAME "freealut")
8SET(PACKAGE_NAME "freealut library")
9SET(PACKAGE_MAJOR_VERSION "1")
10SET(PACKAGE_MINOR_VERSION "0")
11SET(PACKAGE_BUILD_VERSION "1")
12SET(PACKAGE_VERSION "${PACKAGE_MAJOR_VERSION}.${PACKAGE_MINOR_VERSION}.${PACKAGE_BUILD_VERSION}")
13SET(MAJOR_VERSION "0")
14SET(MINOR_VERSION "0")
15SET(BUILD_VERSION "0")
16SET(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_VERSION}")
17SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
18SET(PACKAGE_BUGREPORT "openal-devel@opensource.creative.com")
19SET(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}")
20
21INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
22INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFiles.cmake)
23INCLUDE(${CMAKE_ROOT}/Modules/CheckCSourceCompiles.cmake)
24
25FIND_PACKAGE(ConfigHelper)
26
27SET(ALUT_SOURCES src/alutBufferData.c
28                 src/alutCodec.c
29                 src/alutError.c
30                 src/alutInit.c
31                 src/alutInputStream.c
32                 src/alutInternal.h
33                 src/alutLoader.c
34                 src/alutOutputStream.c
35                 src/alutUtil.c
36                 src/alutVersion.c
37                 src/alutWaveform.c)
38
39INCLUDE_DIRECTORIES(${Alut_SOURCE_DIR}/include)
40
41SET(ADD_WFLAGS "")
42SET(ADD_CFLAGS "")
43SET(ADD_LDFLAGS "")
44SET(ADD_LIBS "")
45
46OPTION(BUILD_STATIC    "build static library too"   ON)
47OPTION(PROFILE         "enable profile"            OFF)
48OPTION(OPTIMIZATION    "enable optimization"        ON)
49OPTION(WARNINGS        "enable warnings"            ON)
50IF(WARNINGS)
51  OPTION(MORE_WARNINGS "enable more warnings"       OFF)
52  OPTION(USE_WERROR    "enable fail on all warning" OFF)
53ENDIF(WARNINGS)
54
55#want test-suit?
56OPTION(BUILD_TESTS "build the test-suite" OFF)
57
58
59ADD_DEFINE(ALUT_BUILD_LIBRARY)
60# We could possibly need struct timespec and random(), which are not ANSI.
61# Define to 500 if Single Unix conformance is wanted, 600 for sixth revision.
62ADD_DEFINE("_XOPEN_SOURCE 500")
63# We might need nanosleep, which is a POSIX IEEE Std 1003.1b-1993 feature.
64# Define to the POSIX version that should be used.
65ADD_DEFINE("_POSIX_C_SOURCE 199309")
66# Without __NO_CTYPE tolower and friends are macros which introduce a GLIBC 2.3
67# dependency. By defining this identifier we are currently backwards compatible
68# to GLIBC 2.1.3, which is a good thing. In addition, the macros lead to code
69# which triggers warnings with -Wunreachable-code.
70ADD_DEFINE("__NO_CTYPE 1")
71
72ADD_DEFINITIONS(-DHAVE_CONFIG_H)
73ADD_DEFINITIONS(-DNDEBUG)
74
75FIND_LIBRARY(OPENAL_LIB NAMES openal openal32 PATHS /usr/lib /usr/local/lib ${OPENAL_LIB_DIR})
76IF(OPENAL_LIB MATCHES "NOTFOUND")
77  MESSAGE(FATAL_ERROR "OpenAL not installed, cannot build alut - aborting.")
78ENDIF(OPENAL_LIB MATCHES "NOTFOUND")
79
80IF(UNIX)
81 SET(ADD_LIBS ${ADD_LIBS} m)
82ENDIF(UNIX)
83
84SET(CMAKE_REQUIRED_INCLUDES ${OPENAL_INCLUDE_DIR})
85CHECK_INCLUDE_FILES("AL/alc.h;AL/al.h" AL_HEADERS)
86IF(NOT AL_HEADERS)
87  MESSAGE(FATAL_ERROR "OpenAL header files not found - aborting.")
88ENDIF(NOT AL_HEADERS)
89
90IF(DEFINED OPENAL_INCLUDE_DIR)
91  INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
92ENDIF(DEFINED OPENAL_INCLUDE_DIR)
93
94FIND_PACKAGE(SleepFunction)
95
96CHECK_INCLUDE_FILE_DEFINE(stdint.h HAVE_STDINT_H)
97
98IF(WIN32)
99  CHECK_INCLUDE_FILE_DEFINE(basetsd.h HAVE_BASETSD_H)
100ENDIF(WIN32)
101
102# FindSleepFunction will check for unistd.h if time.h wasn't found
103IF(HAVE_TIME_H)
104  CHECK_INCLUDE_FILE_DEFINE(unistd.h HAVE_UNISTD_H)
105ENDIF(HAVE_TIME_H)
106
107IF(HAVE_UNISTD_H)
108  CHECK_FUNCTION_DEFINE("
109  #include <sys/types.h>
110  #include <sys/stat.h>
111  #include <unistd.h>
112  " stat "(\"\", (struct stat*)0)" HAVE_STAT)
113ENDIF(HAVE_UNISTD_H)
114
115IF(NOT HAVE_STAT)
116  CHECK_FUNCTION_DEFINE("
117  #include <sys/types.h>
118  #include <sys/stat.h>
119  " _stat "(\"\", (struct _stat*)0)" HAVE__STAT)
120ENDIF(NOT HAVE_STAT)
121
122# compiler specific settings
123FIND_PACKAGE(CompilerAttribute)
124FIND_PACKAGE(CompilerVisibility)
125FIND_PACKAGE(CompilerFlagsSet)
126
127GENERATE_CONFIG_H()
128
129SET(CMAKE_C_FLAGS "${ADD_WFLAGS} ${ADD_CFLAGS} ${CMAKE_C_FLAGS}")
130SET(CMAKE_CXX_FLAGS "${ADD_CFLAGS} ${CMAKE_CXX_FLAGS}")
131SET(CMAKE_SHARED_LINKER_FLAGS "${ADD_LDFLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
132SET(CMAKE_MODULE_LINKER_FLAGS "${ADD_LDFLAGS} ${CMAKE_MODULE_LINKER_FLAGS}")
133
134IF(BUILD_STATIC)
135  # we can't create a static library with the same name
136  # as the shared one, so we copy it over after creation
137  ADD_LIBRARY(alut_static STATIC ${ALUT_SOURCES})
138  TARGET_LINK_LIBRARIES(alut_static ${OPENAL_LIB} ${ADD_LIBS})
139  IF(NOT WIN32)
140    ADD_CUSTOM_COMMAND(
141      TARGET alut_static
142      POST_BUILD
143      COMMAND ${CMAKE_COMMAND}
144      ARGS -E copy
145        ${CMAKE_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}alut_static${CMAKE_STATIC_LIBRARY_SUFFIX}
146        ${CMAKE_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}alut${CMAKE_STATIC_LIBRARY_SUFFIX})
147    INSTALL_FILES(/lib FILES ${CMAKE_STATIC_LIBRARY_PREFIX}alut${CMAKE_STATIC_LIBRARY_SUFFIX})
148  ENDIF(NOT WIN32)
149ENDIF(BUILD_STATIC)
150
151
152ADD_LIBRARY(alut SHARED ${ALUT_SOURCES})
153SET_TARGET_PROPERTIES(alut PROPERTIES VERSION ${VERSION} SOVERSION ${MAJOR_VERSION})
154TARGET_LINK_LIBRARIES(alut ${OPENAL_LIB} ${ADD_LIBS})
155
156INSTALL_TARGETS(/lib alut)
157INSTALL_FILES(/include/AL FILES include/AL/alut.h)
158
159# needed for openal.pc.in and openal-config.in
160SET(prefix ${CMAKE_INSTALL_PREFIX})
161SET(exec_prefix "\${prefix}")
162SET(libdir "\${exec_prefix}/lib")
163SET(bindir "\${exec_prefix}/bin")
164SET(includedir "\${prefix}/include")
165SET(requirements "")
166# static linking dependecies are broken, so pthread isn't needed currently
167SET(PTHREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
168
169CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/admin/pkgconfig/freealut.pc.in
170               ${CMAKE_BINARY_DIR}/admin/pkgconfig/freealut.pc @ONLY)
171CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/admin/pkgconfig/freealut-config.in
172               ${CMAKE_BINARY_DIR}/admin/pkgconfig/freealut-config @ONLY)
173INSTALL_PROGRAMS(/bin FILES admin/pkgconfig/freealut-config)
174INSTALL_FILES(/lib/pkgconfig FILES admin/pkgconfig/freealut.pc)
175
176
177# test-suite
178IF(BUILD_TESTS)
179    # examples
180    ADD_EXECUTABLE(hello_world examples/hello_world.c)
181    TARGET_LINK_LIBRARIES(hello_world ${OPENAL_LIB} ${ADD_LIBS} alut)
182
183    ADD_EXECUTABLE(playfile examples/playfile.c)
184    TARGET_LINK_LIBRARIES(playfile ${OPENAL_LIB} ${ADD_LIBS} alut)
185
186
187    SET(TESTS errorstuff
188              fileloader
189              memoryloader
190              version
191              waveforms)
192
193    FOREACH(TEST ${TESTS})
194      SET(TEST_SRC test_suite/test_${TEST}.c)
195      SET_SOURCE_FILES_PROPERTIES(${TEST_SRC} PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations")
196      ADD_EXECUTABLE(test_${TEST} ${TEST_SRC})
197      TARGET_LINK_LIBRARIES(test_${TEST} ${OPENAL_LIB} ${ADD_LIBS} alut)
198    ENDFOREACH(TEST)
199
200    #copy over testdata, so test-suite can be used in binary dir
201    SET(TESTDATA file1.wav
202                 file2.au
203                 file3.raw)
204
205    FOREACH(TESTDATUM ${TESTDATA})
206      CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/test_suite/${TESTDATUM} ${CMAKE_BINARY_DIR}/${TESTDATUM} COPYONLY)
207    ENDFOREACH(TESTDATUM)
208ENDIF(BUILD_TESTS)
Note: See TracBrowser for help on using the repository browser.