1 cmake_minimum_required(VERSION 2.6)
4 IF(COMMAND CMAKE_POLICY)
5 CMAKE_POLICY(SET CMP0003 NEW)
6 CMAKE_POLICY(SET CMP0005 NEW)
8 CMAKE_POLICY(SET CMP0042 NEW)
10 ENDIF(COMMAND CMAKE_POLICY)
12 set(CMAKE_MODULE_PATH "${alure_SOURCE_DIR}/cmake")
14 include(CheckCXXCompilerFlag)
15 include(CheckCXXSourceCompiles)
17 find_package(OpenAL REQUIRED)
19 option(ALURE_STATIC_GCCRT "Static-link libgcc and libstdc++ runtimes" OFF)
22 check_cxx_compiler_flag(-std=c++11 HAVE_STD_CXX11)
24 set(CXX_FLAGS -std=c++11 ${CXX_FLAGS})
27 check_cxx_compiler_flag(-Wall HAVE_WALL_SWITCH)
29 set(CXX_FLAGS ${CXX_FLAGS} -Wall)
31 check_cxx_compiler_flag(-Wextra HAVE_WEXTRA_SWITCH)
32 if(HAVE_WEXTRA_SWITCH)
33 set(CXX_FLAGS ${CXX_FLAGS} -Wextra)
36 check_cxx_compiler_flag(-fno-rtti HAVE_NO_RTTI_SWITCH)
37 if(HAVE_NO_RTTI_SWITCH)
38 set(CXX_FLAGS ${CXX_FLAGS} -fno-rtti)
40 check_cxx_compiler_flag(/GR- HAVE_GRX_SWITCH)
42 set(CXX_FLAGS ${CXX_FLAGS} /GR-)
47 if(ALURE_STATIC_GCCRT)
48 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
49 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc -static-libstdc++)
50 check_cxx_source_compiles(
54 std::vector<int> test;
57 HAVE_STATIC_GCCRT_SWITCHES
59 if(HAVE_STATIC_GCCRT_SWITCHES)
60 set(LINKER_OPTS -static-libgcc -static-libstdc++)
62 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
63 unset(OLD_REQUIRED_LIBRARIES)
67 set(alure_srcs src/devicemanager.cpp
78 set(alure_libs ${OPENAL_LIBRARY})
83 set(decoder_incls ${decoder_incls} ${OGG_INCLUDE_DIRS})
86 set(decoder_incls ${decoder_incls} ${VORBIS_INCLUDE_DIRS})
87 set(alure_libs ${alure_libs} ${VORBIS_LIBRARIES})
88 set(alure_srcs ${alure_srcs} src/decoders/vorbisfile.cpp)
89 set(HAVE_VORBISFILE 1)
94 set(decoder_incls ${decoder_incls} ${FLAC_INCLUDE_DIRS})
95 set(alure_libs ${alure_libs} ${FLAC_LIBRARIES})
96 set(alure_srcs ${alure_srcs} src/decoders/flac.cpp)
102 set(decoder_incls ${decoder_incls} ${OPUS_INCLUDE_DIRS})
103 set(alure_libs ${alure_libs} ${OPUS_LIBRARIES})
104 set(alure_srcs ${alure_srcs} src/decoders/opusfile.cpp)
107 set(alure_libs ${alure_libs} ${OGG_LIBRARIES})
110 find_package(SndFile)
112 set(decoder_incls ${decoder_incls} ${SNDFILE_INCLUDE_DIRS})
113 set(alure_libs ${alure_libs} ${SNDFILE_LIBRARIES})
114 set(alure_srcs ${alure_srcs} src/decoders/sndfile.cpp)
115 set(HAVE_LIBSNDFILE 1)
120 set(decoder_incls ${decoder_incls} ${MPG123_INCLUDE_DIRS})
121 set(alure_libs ${alure_libs} ${MPG123_LIBRARIES})
122 set(alure_srcs ${alure_srcs} src/decoders/mpg123.cpp)
128 "${alure_SOURCE_DIR}/config.h.in"
129 "${alure_BINARY_DIR}/config.h")
132 add_library(alure2 SHARED ${alure_srcs})
133 target_compile_definitions(alure2 PRIVATE ALURE_BUILD_DLL)
134 target_include_directories(alure2
135 PUBLIC ${alure_SOURCE_DIR}/include/AL ${OPENAL_INCLUDE_DIR}
136 PRIVATE ${alure_SOURCE_DIR}/include ${alure_SOURCE_DIR}/src ${alure_BINARY_DIR}
139 target_compile_options(alure2 PRIVATE ${CXX_FLAGS})
140 target_link_libraries(alure2 PUBLIC ${alure_libs} PRIVATE ${LINKER_OPTS})
142 add_library(alure2_s STATIC ${alure_srcs})
143 target_compile_definitions(alure2_s PUBLIC ALURE_STATIC_LIB PRIVATE ALURE_BUILD_STATIC)
144 target_include_directories(alure2_s
145 PUBLIC ${alure_SOURCE_DIR}/include/AL ${OPENAL_INCLUDE_DIR}
146 PRIVATE ${alure_SOURCE_DIR}/include ${alure_SOURCE_DIR}/src ${alure_BINARY_DIR}
149 target_compile_options(alure2_s PRIVATE ${CXX_FLAGS})
150 target_link_libraries(alure2_s PUBLIC ${alure_libs})
153 add_executable(alure-enum examples/alure-enum.cpp)
154 target_compile_options(alure-enum PRIVATE ${CXX_FLAGS})
155 target_link_libraries(alure-enum PRIVATE alure2)
157 add_executable(alure-play examples/alure-play.cpp)
158 target_compile_options(alure-play PRIVATE ${CXX_FLAGS})
159 target_link_libraries(alure-play PRIVATE alure2)
161 add_executable(alure-stream examples/alure-stream.cpp)
162 target_compile_options(alure-stream PRIVATE ${CXX_FLAGS})
163 target_link_libraries(alure-stream PRIVATE alure2)
165 add_executable(alure-reverb examples/alure-reverb.cpp)
166 target_compile_options(alure-reverb PRIVATE ${CXX_FLAGS})
167 target_link_libraries(alure-reverb PRIVATE alure2)
169 add_executable(alure-hrtf examples/alure-hrtf.cpp)
170 target_compile_options(alure-hrtf PRIVATE ${CXX_FLAGS})
171 target_link_libraries(alure-hrtf PRIVATE alure2)
175 add_executable(alure-physfs examples/alure-physfs.cpp)
176 target_include_directories(alure-physfs PRIVATE ${PHYSFS_INCLUDE_DIR})
177 target_compile_options(alure-physfs PRIVATE ${CXX_FLAGS})
178 target_link_libraries(alure-physfs PRIVATE alure2 ${PHYSFS_LIBRARY} ${LINKER_OPTS})
183 add_executable(alure-dumb examples/alure-dumb.cpp)
184 target_include_directories(alure-dumb PRIVATE ${DUMB_INCLUDE_DIRS})
185 target_compile_options(alure-dumb PRIVATE ${CXX_FLAGS})
186 target_link_libraries(alure-dumb PRIVATE alure2 ${DUMB_LIBRARIES} ${LINKER_OPTS})
190 if(NOT DEFINED LIB_SUFFIX)
194 install(TARGETS alure2 alure2_s
195 RUNTIME DESTINATION bin
196 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
197 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"