view CMakeLists.txt @ 10:d51a735106c2

All classes have basic functionality and support the full ao api. Test driver is now lists available sound drivers. TODO - AOSystem needs to be made into a singleton. - Need more fully fleshed out tests. - Need Doxygen - Need to consider more abstraction rather than the 1-1 mapping of api calls to methods.
author Eris Caffee <discordia@eldalin.com>
date Thu, 26 Mar 2015 16:17:33 -0500
parents 65c716ba7cda
children 9f0ed655b46c
line source
1 cmake_minimum_required (VERSION 2.6 FATAL_ERROR)
2 #set (CMAKE_VERBOSE_MAKEFILE ON)
4 set (App_Name "libaocpp")
5 project (${App_Name})
7 set (App_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 ################################################################################
63 # The core project files
65 set (LIB_SRCS
66 src/AODriver.cpp
67 src/AOSystem.cpp
68 src/AODevice.cpp
69 src/AOOptions.cpp
70 src/aopp.hpp
71 )
73 set ( AOPP_SYSTEM_INFO_SRCS
74 src/aopp_system_info.cpp
75 )
77 # The directories that contain the libraries we will be linking against.
78 # This must come before the ADD_EXECUTABLE directive.
79 link_directories (
80 )
82 set (TEST_APP_NAME "aopp_system_info")
84 # Define the executable program file we are creating. We must list all of
85 # the source files.
86 add_executable ( ${TEST_APP_NAME}
87 ${AOPP_SYSTEM_INFO_SRCS}
88 ${LIB_SRCS}
89 )
91 # Although we listed the library directories above, we also need to list the
92 # individual libraries we will be linking against.
93 target_link_libraries (${TEST_APP_NAME}
94 )
97 # Example to build a linux library with a test driver.
99 # set (SRCS_${App_Name}
100 # src/.cpp
101 # include/.h
102 # )
104 # include_directories (
105 # ${PROJECT_SOURCE_DIR}/include
106 # )
108 # # Build both static and shared libraries
109 # # The target properties are needed because, by default, the output name
110 # # will be the name in the add_library command, and we need to have different
111 # # names in the two commands for the shared and static versions, even though
112 # # we want the final files to have the same names with different extensions.
113 # #
114 # # The prefix is needed mostly in case we build on windows, which has no prefix
115 # # by default.
116 # #
117 # # The clean_direct_output option makes sure that the two lib builds don't
118 # # clobber each others temp files since they are being built from the same
119 # # sources.
121 # add_library (${App_Name} SHARED
122 # ${SRCS_${App_Name}}
123 # )
124 # set_target_properties (${App_Name} PROPERTIES OUTPUT_NAME ${App_Name})
125 # set_target_properties (${App_Name} PROPERTIES PREFIX "lib")
126 # set_target_properties (${App_Name} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
128 # add_library (${App_Name}-static STATIC
129 # ${SRCS_${App_Name}}
130 # )
131 # set_target_properties (${App_Name}-static PROPERTIES OUTPUT_NAME ${App_Name})
132 # set_target_properties (${App_Name}-static PROPERTIES PREFIX "lib")
133 # set_target_properties (${App_Name}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
135 # # Build a test application.
137 # link_directories (
138 # )
140 # include_directories (
141 # ${CMAKE_SOURCE_DIR}/include
142 # )
144 # add_executable (${App_Name}-test
145 # src/main.cpp
146 # )
148 # target_link_libraries (${App_Name}-test
149 # ${App_Name}
150 # )
152 ################################################################################
153 # Doxygen documentation
154 #
155 # - Create a directory named docs to hold your Doxygen config and standalone
156 # (.dox) files.
157 # - Name your Doxyfile config as "docs/Doxyfile.in".
158 # - In that file, set the following variables as shown, adjusting INPUT as
159 # needed to reflect the actual location of the fiels you wnat processed.
160 #
161 # PROJECT_NAME = "@App_Name@"
162 # PROJECT_BRIEF = "@App_Description@"
163 # STRIP_FROM_PATH = @CMAKE_CURRENT_SOURCE_DIR@
164 # INPUT = @CMAKE_CURRENT_SOURCE_DIR@/src/ @CMAKE_CURRENT_SOURCE_DIR@/include/ @CMAKE_CURRENT_SOURCE_DIR@/docs/
165 #
166 # Then you can generate the docs with "make docs" and this will create a "docs" directory under your build directory.
167 #
169 option(Option_Doxygen "Generate Doxygen documentation." OFF)
171 if (Option_Doxygen)
173 find_package(Doxygen)
174 if (NOT DOXYGEN_FOUND)
175 message (FATAL_ERROR "Doxygen not found!")
176 endif ()
178 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile @ONLY)
180 add_custom_target(docs
181 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile
182 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
183 COMMENT "Generating API documentation with Doxygen" VERBATIM
184 )
186 endif ()
188 ################################################################################
190 option(Option_AO_Dev "Build a libao Application." ON)
192 if (Option_AO_Dev)
194 find_path(AO_INCLUDE_DIR ao/ao.h)
195 find_library(AO_LIBRARY NAMES ao)
197 if (AO_INCLUDE_DIR AND AO_LIBRARY)
198 include_directories(
199 ${AO_INCLUDE_DIR}
200 ${INCLUDE_DIRECTORIES}
201 )
203 target_link_libraries(${TEST_APP_NAME}
204 ${AO_LIBRARY}
205 ${TARGET_LINK_LIBRARIES}
206 )
207 else ()
208 message (FATAL_ERROR "AO not found")
209 endif()
211 endif ()
213 ################################################################################