view CMakeLists.txt @ 11:9f0ed655b46c

Simple player added. Doesn't work right, though. There's lots of static. Is it because I'm in a VM?
author Eris Caffee <discordia@eldalin.com>
date Tue, 31 Mar 2015 17:58:33 -0500
parents d51a735106c2
children
line source
1 cmake_minimum_required (VERSION 2.6 FATAL_ERROR)
2 #set (CMAKE_VERBOSE_MAKEFILE ON)
4 set (Proj_Name "libaocpp")
5 project (${Proj_Name})
7 set (Proj_Description "Object Oriented wrapper around libao.")
10 ################################################################################
11 # Ensure that we are not building in our source directories.
13 set (Build_Dir_OK "TRUE")
14 string (REGEX MATCH "^${CMAKE_SOURCE_DIR}" In_Sub_Dir ${CMAKE_BINARY_DIR})
15 if (In_Sub_Dir)
16 string (REGEX MATCH "^${CMAKE_SOURCE_DIR}/build" In_Build_Dir ${CMAKE_BINARY_DIR})
17 if (NOT In_Build_Dir)
18 set (Build_Dir_OK "FALSE")
19 endif ()
20 endif ()
22 if (NOT Build_Dir_OK)
23 message (FATAL_ERROR "You must run cmake from a directory that is not in your source tree, or that is in a special subdirectory of the tree whose name begins with 'build'.")
24 endif ()
27 ################################################################################
28 # Set up the basic build environment
29 # A build type defines which options are passed to the compiler, and there are
30 # several that CMake defines by default. It does not set one by default, though
31 # so we need to set the build type manually here, and we are setting it to the
32 # generally useful "Release with debug info"
34 if (CMAKE_BUILD_TYPE STREQUAL "")
35 # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This messes up
36 # differentiation between debug and release builds.
37 set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
38 endif ()
41 ################################################################################
42 # When using GCC turn on lots of warnings.
43 # Some other options to consider:
44 # C++ -Weffc++
45 # C -std=gnu99 -std=c99
47 if (CMAKE_COMPILER_IS_GNUCXX)
48 add_definitions(-pedantic -Wall -std=c++11)
49 endif ()
52 ################################################################################
54 option(Option_Profile_Program "Build for gprof profiling." OFF)
56 if (Option_Profile_Program)
57 add_definitions(-pg)
58 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
59 endif ()
62 ################################################################################
64 find_path(AO_INCLUDE_DIR ao/ao.h)
65 find_library(AO_LIBRARY NAMES ao)
67 if (AO_INCLUDE_DIR AND AO_LIBRARY)
68 include_directories(
69 ${AO_INCLUDE_DIR}
70 ${INCLUDE_DIRECTORIES}
71 )
72 else ()
73 message (FATAL_ERROR "AO not found")
74 endif()
77 find_path(VORBISFILE_INCLUDE_DIR vorbis/vorbisfile.h)
78 find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
80 if (VORBISFILE_INCLUDE_DIR AND VORBISFILE_LIBRARY)
81 include_directories(
82 ${VORBISFILE_INCLUDE_DIR}
83 ${INCLUDE_DIRECTORIES}
84 )
85 else ()
86 message (FATAL_ERROR "VorbisFile not found")
87 endif()
89 find_library(VORBIS_LIBRARY NAMES vorbis)
90 find_path(VORBISFILE_INCLUDE_DIR vorbis/vorbisfile.h)
91 find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
93 if (VORBISFILE_INCLUDE_DIR AND VORBISFILE_LIBRARY AND VORBIS_LIBRARY)
94 include_directories(
95 ${VORBISFILE_INCLUDE_DIR}
96 ${INCLUDE_DIRECTORIES}
97 )
98 else ()
99 message (FATAL_ERROR "VorbisFile not found")
100 endif()
102 message (STATUS "VORBISFILE_INCLUDE_DIR ${VORBISFILE_INCLUDE_DIR}")
103 message (STATUS "VORBISFILE_LIBRARY ${VORBISFILE_LIBRARY}")
104 message (STATUS "VORBIS_LIBRARY ${VORBIS_LIBRARY}")
106 ################################################################################
107 # The core project files
109 set (LIB_SRCS
110 src/AODriver.cpp
111 src/AOSystem.cpp
112 src/AODevice.cpp
113 src/AOOptions.cpp
114 src/aopp.hpp
115 )
117 ########################################
119 set (TEST_APP_NAME "aopp_system_info")
121 set ( AOPP_SYSTEM_INFO_SRCS
122 src/aopp_system_info.cpp
123 )
125 # The directories that contain the libraries we will be linking against.
126 # This must come before the ADD_EXECUTABLE directive.
127 link_directories (
128 )
131 # Define the executable program file we are creating. We must list all of
132 # the source files.
133 add_executable ( ${TEST_APP_NAME}
134 ${AOPP_SYSTEM_INFO_SRCS}
135 ${LIB_SRCS}
136 )
138 # Although we listed the library directories above, we also need to list the
139 # individual libraries we will be linking against.
140 target_link_libraries(${TEST_APP_NAME}
141 ${AO_LIBRARY}
142 ${TARGET_LINK_LIBRARIES}
143 )
146 ########################################
148 set (PLAYOGG_APP_NAME "playogg")
150 set ( PLAYOGG_SRCS
151 src/playogg.cpp
152 )
154 # The directories that contain the libraries we will be linking against.
155 # This must come before the ADD_EXECUTABLE directive.
156 link_directories (
157 )
160 # Define the executable program file we are creating. We must list all of
161 # the source files.
162 add_executable ( ${PLAYOGG_APP_NAME}
163 ${PLAYOGG_SRCS}
164 ${LIB_SRCS}
165 )
167 # Although we listed the library directories above, we also need to list the
168 # individual libraries we will be linking against.
169 target_link_libraries(${PLAYOGG_APP_NAME}
170 ${AO_LIBRARY}
171 ${VORBIS_LIBRARY}
172 ${VORBISFILE_LIBRARY}
173 ${TARGET_LINK_LIBRARIES}
174 )
190 # Example to build a linux library with a test driver.
192 # set (SRCS_${App_Name}
193 # src/.cpp
194 # include/.h
195 # )
197 # include_directories (
198 # ${PROJECT_SOURCE_DIR}/include
199 # )
201 # # Build both static and shared libraries
202 # # The target properties are needed because, by default, the output name
203 # # will be the name in the add_library command, and we need to have different
204 # # names in the two commands for the shared and static versions, even though
205 # # we want the final files to have the same names with different extensions.
206 # #
207 # # The prefix is needed mostly in case we build on windows, which has no prefix
208 # # by default.
209 # #
210 # # The clean_direct_output option makes sure that the two lib builds don't
211 # # clobber each others temp files since they are being built from the same
212 # # sources.
214 # add_library (${App_Name} SHARED
215 # ${SRCS_${App_Name}}
216 # )
217 # set_target_properties (${App_Name} PROPERTIES OUTPUT_NAME ${App_Name})
218 # set_target_properties (${App_Name} PROPERTIES PREFIX "lib")
219 # set_target_properties (${App_Name} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
221 # add_library (${App_Name}-static STATIC
222 # ${SRCS_${App_Name}}
223 # )
224 # set_target_properties (${App_Name}-static PROPERTIES OUTPUT_NAME ${App_Name})
225 # set_target_properties (${App_Name}-static PROPERTIES PREFIX "lib")
226 # set_target_properties (${App_Name}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
228 # # Build a test application.
230 # link_directories (
231 # )
233 # include_directories (
234 # ${CMAKE_SOURCE_DIR}/include
235 # )
237 # add_executable (${App_Name}-test
238 # src/main.cpp
239 # )
241 # target_link_libraries (${App_Name}-test
242 # ${App_Name}
243 # )
245 ################################################################################
246 # Doxygen documentation
247 #
248 # - Create a directory named docs to hold your Doxygen config and standalone
249 # (.dox) files.
250 # - Name your Doxyfile config as "docs/Doxyfile.in".
251 # - In that file, set the following variables as shown, adjusting INPUT as
252 # needed to reflect the actual location of the fiels you wnat processed.
253 #
254 # PROJECT_NAME = "@App_Name@"
255 # PROJECT_BRIEF = "@App_Description@"
256 # STRIP_FROM_PATH = @CMAKE_CURRENT_SOURCE_DIR@
257 # INPUT = @CMAKE_CURRENT_SOURCE_DIR@/src/ @CMAKE_CURRENT_SOURCE_DIR@/include/ @CMAKE_CURRENT_SOURCE_DIR@/docs/
258 #
259 # Then you can generate the docs with "make docs" and this will create a "docs" directory under your build directory.
260 #
262 option(Option_Doxygen "Generate Doxygen documentation." OFF)
264 if (Option_Doxygen)
266 find_package(Doxygen)
267 if (NOT DOXYGEN_FOUND)
268 message (FATAL_ERROR "Doxygen not found!")
269 endif ()
271 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile @ONLY)
273 add_custom_target(docs
274 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile
275 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
276 COMMENT "Generating API documentation with Doxygen" VERBATIM
277 )
279 endif ()
281 ################################################################################