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 include_directories(${alure_SOURCE_DIR}/include ${alure_SOURCE_DIR}/include/AL ${alure_SOURCE_DIR}/src ${alure_BINARY_DIR} ${OPENAL_INCLUDE_DIR})
21 option(ALURE_USE_RTTI "Enable run-time type information" OFF)
22 option(ALURE_STATIC_GCCRT "Static-link libgcc and libstdc++ runtimes" OFF)
24 check_cxx_compiler_flag(-std=c++11 HAVE_STD_CXX11)
26 set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
29 check_cxx_compiler_flag(-Wall HAVE_WALL_SWITCH)
31 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
33 check_cxx_compiler_flag(-Wextra HAVE_WEXTRA_SWITCH)
34 if(HAVE_WEXTRA_SWITCH)
35 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
38 if(NOT ALURE_USE_RTTI)
39 check_cxx_compiler_flag(-fno-rtti HAVE_NO_RTTI_SWITCH)
40 if(HAVE_NO_RTTI_SWITCH)
41 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
43 check_cxx_compiler_flag(/GR- HAVE_GRX_SWITCH)
45 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
51 if(ALURE_STATIC_GCCRT)
52 set(OLD_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
53 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -static-libgcc -static-libstdc++)
54 check_cxx_source_compiles(
58 std::vector<int> test;
61 HAVE_STATIC_GCCRT_SWITCHES
63 if(HAVE_STATIC_GCCRT_SWITCHES)
64 set(LINKER_OPTS -static-libgcc -static-libstdc++)
66 set(CMAKE_REQUIRED_LIBRARIES ${OLD_REQUIRED_LIBRARIES})
67 unset(OLD_REQUIRED_LIBRARIES)
71 set(alure_srcs src/devicemanager.cpp
82 set(alure_libs ${OPENAL_LIBRARY})
88 include_directories(${OGG_INCLUDE_DIRS} ${VORBIS_INCLUDE_DIRS})
89 set(alure_libs ${alure_libs} ${VORBIS_LIBRARIES} ${OGG_LIBRARIES})
90 set(alure_srcs ${alure_srcs} src/decoders/vorbisfile.cpp)
91 set(HAVE_VORBISFILE 1)
96 include_directories(${OGG_INCLUDE_DIRS} ${FLAC_INCLUDE_DIRS})
97 set(alure_libs ${alure_libs} ${FLAC_LIBRARIES} ${OGG_LIBRARIES})
98 set(alure_srcs ${alure_srcs} src/decoders/flac.cpp)
104 include_directories(${OGG_INCLUDE_DIRS} ${OPUS_INCLUDE_DIRS})
105 set(alure_libs ${alure_libs} ${OPUS_LIBRARIES} ${OGG_LIBRARIES})
106 set(alure_srcs ${alure_srcs} src/decoders/opusfile.cpp)
111 find_package(SndFile)
113 include_directories(${SNDFILE_INCLUDE_DIRS})
114 set(alure_libs ${alure_libs} ${SNDFILE_LIBRARIES})
115 set(alure_srcs ${alure_srcs} src/decoders/sndfile.cpp)
116 set(HAVE_LIBSNDFILE 1)
121 include_directories(${MPG123_INCLUDE_DIRS})
122 set(alure_libs ${alure_libs} ${MPG123_LIBRARIES})
123 set(alure_srcs ${alure_srcs} src/decoders/mpg123.cpp)
129 "${alure_SOURCE_DIR}/config.h.in"
130 "${alure_BINARY_DIR}/config.h")
133 add_library(alure2 SHARED ${alure_srcs})
134 target_link_libraries(alure2 ${alure_libs} ${LINKER_OPTS})
135 set_property(TARGET alure2 APPEND PROPERTY COMPILE_DEFINITIONS ALURE_BUILD_DLL)
137 add_library(alure2_s STATIC ${alure_srcs})
138 set_property(TARGET alure2_s APPEND PROPERTY COMPILE_DEFINITIONS ALURE_STATIC_LIB ALURE_BUILD_STATIC)
141 add_executable(alure-enum examples/alure-enum.cpp)
142 target_link_libraries(alure-enum alure2 ${LINKER_OPTS})
144 add_executable(alure-play examples/alure-play.cpp)
145 target_link_libraries(alure-play alure2 ${LINKER_OPTS})
147 add_executable(alure-stream examples/alure-stream.cpp)
148 target_link_libraries(alure-stream alure2 ${LINKER_OPTS})
150 add_executable(alure-reverb examples/alure-reverb.cpp)
151 target_link_libraries(alure-reverb alure2 ${LINKER_OPTS})
153 add_executable(alure-hrtf examples/alure-hrtf.cpp)
154 target_link_libraries(alure-hrtf alure2 ${LINKER_OPTS})
158 add_executable(alure-physfs examples/alure-physfs.cpp)
159 set_property(TARGET alure-physfs APPEND PROPERTY INCLUDE_DIRECTORIES "${PHYSFS_INCLUDE_DIR}")
160 target_link_libraries(alure-physfs alure2 "${PHYSFS_LIBRARY}" ${LINKER_OPTS})
165 add_executable(alure-dumb examples/alure-dumb.cpp)
166 set_property(TARGET alure-dumb APPEND PROPERTY INCLUDE_DIRECTORIES "${DUMB_INCLUDE_DIRS}")
167 target_link_libraries(alure-dumb alure2 "${DUMB_LIBRARIES}" ${LINKER_OPTS})
171 if(NOT DEFINED LIB_SUFFIX)
175 install(TARGETS alure2 alure2_s
176 RUNTIME DESTINATION bin
177 LIBRARY DESTINATION "lib${LIB_SUFFIX}"
178 ARCHIVE DESTINATION "lib${LIB_SUFFIX}"