-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
69 lines (56 loc) · 2.09 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
cmake_minimum_required(VERSION 3.5)
# TODO: Determine actual required CMake version
# Set default build type to Release
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)")
endif()
project(FMComposer)
# Detect and enable C++11 support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "FMComposer requires C++11, but ${CMAKE_CXX_COMPILER} does not appear to support C++11. Please use a different compiler or update ${CMAKE_CXX_COMPILER}.")
endif()
include_directories(src)
# Add source files
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.c")
# Set executable output path
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# Set executable name
set(EXECUTABLE_NAME "FMComposer")
add_executable(${EXECUTABLE_NAME} ${SOURCES})
# Add CMake modules
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# Detect and add SFML
find_package(SFML 2 REQUIRED graphics window system)
if(SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
endif()
# Detect and add OpenGL
find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
include_directories(${OPENGL_INCLUDE_DIRS})
target_link_libraries(${EXECUTABLE_NAME} ${OPENGL_LIBRARIES})
endif()
# Detect and add FLAC
find_package(FLAC REQUIRED)
if(FLAC_FOUND)
include_directories(${FLAC_INCLUDE_DIR})
target_link_libraries(${EXECUTABLE_NAME} ${FLAC_LIBRARY})
endif()
# Detect and add PortAudio
find_package(PortAudio REQUIRED)
if(PORTAUDIO_FOUND)
include_directories(${PORTAUDIO_INCLUDE_DIRS})
target_link_libraries(${EXECUTABLE_NAME} ${PORTAUDIO_LIBRARIES})
endif()
# Link POSIX Thread library if necessary
if(CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(${EXECUTABLE_NAME} pthread)
endif(CMAKE_COMPILER_IS_GNUCC)