forked from ellenhager/Rainbone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
237 lines (204 loc) · 6.46 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
cmake_minimum_required(VERSION 2.8)
SET(APP_NAME rainbone)
PROJECT(${APP_NAME})
# include the directory itself as a path to include directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# set project paths
set(CMAKE_BINARY_DIR ${PROJECT_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
# SOURCES containing all .cpp files
file(GLOB SOURCE src/*.cpp)
include_directories(${PROJECT_INCLUDE_DIR})
# create an executable file from SOURCES
add_executable(${APP_NAME}
${SOURCE})
# add postfix
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
# target properties
set_target_properties(${APP_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH}/debug
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH}/release
)
if( APPLE )
option(SGCT_CPP11 "Use libc++ instead of libstdc++" ON)
set(CMAKE_OSX_ARCHITECTURES "x86_64")
if(CMAKE_GENERATOR STREQUAL Xcode)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9")
endif()
endif()
# add external libraries
find_library(SGCT_RELEASE_LIBRARY
NAMES sgct libsgct libsgct_cpp11
REQUIRED)
find_library(SGCT_DEBUG_LIBRARY
NAMES sgctd libsgctd libsgct_cpp11d
REQUIRED)
find_library(PORTAUDIO_DEBUG_LIBRARY
NAMES portaudio libportaudio
REQUIRED)
find_library(PORTAUDIO_RELEASE_LIBRARY
NAMES portaudio libportaudio
REQUIRED)
find_library(SFML_SYSTEM_DEBUG_LIBRARY
NAMES sfml-system-d libsfml-system
REQUIRED)
find_library(SFML_SYSTEM_RELEASE_LIBRARY
NAMES sfml-system libsfml-system
REQUIRED)
find_library(SFML_AUDIO_DEBUG_LIBRARY
NAMES sfml-audio-d libsfml-audio
REQUIRED)
find_library(SFML_AUDIO_RELEASE_LIBRARY
NAMES sfml-audio libsfml-audio
REQUIRED)
if( WIN32 )
find_path(SGCT_INCLUDE_DIRECTORY
NAMES sgct
PATHS $ENV{SGCT_ROOT_DIR}/include NO_DEFAULT_PATH
REQUIRED)
find_path(PORTAUDIO_INCLUDE_DIRECTORY
NAMES portaudio
PATHS $ENV{PORTAUDIO_ROOT_DIR}/include NO_DEFAULT_PATH
REQUIRED)
find_path(SFML_INCLUDE_DIRECTORY
NAMES SFML
PATHS $ENV{SFTML_ROOT_DIR}/include NO_DEFAULT_PATH
REQUIRED)
else()
find_path(SGCT_INCLUDE_DIRECTORY
NAMES sgct
PATH_SUFFIXES sgct
PATHS $ENV{SGCT_ROOT_DIR}/include
REQUIRED)
find_path(PORTAUDIO_INCLUDE_DIRECTORY
NAMES portaudio
PATH_SUFFIXES portaudio
PATHS $ENV{PORTAUDIO_ROOT_DIR}/include
REQUIRED)
find_path(SFML_INCLUDE_DIRECTORY
NAMES SFML
PATH_SUFFIXES SFML
PATHS $ENV{SFML_ROOT_DIR}/include
REQUIRED)
endif()
set(SGCT_LIBS
debug ${SGCT_DEBUG_LIBRARY}
optimized ${SGCT_RELEASE_LIBRARY}
)
set(PORTAUDIO_LIBS
debug ${PORTAUDIO_DEBUG_LIBRARY}
optimized ${PORTAUDIO_RELEASE_LIBRARY}
)
set(SFML_SYSTEM_LIBS
debug ${SFML_SYSTEM_DEBUG_LIBRARY}
optimized ${SFML_SYSTEM_RELEASE_LIBRARY}
)
set(SFML_AUDIO_LIBS
debug ${SFML_AUDIO_DEBUG_LIBRARY}
optimized ${SFML_AUDIO_RELEASE_LIBRARY}
)
# find packages
find_package(OpenGL REQUIRED)
# include directories
include_directories(${SGCT_INCLUDE_DIRECTORY} ${PORTAUDIO_INCLUDE_DIRECTORY}
${SFML_SYSTEM_INCLUDE_DIRECTORY}
${SFML_AUDIO_INCLUDE_DIRECTORY})
if( MSVC )
set(LIBS
${SGCT_LIBS}
${PORTAUDIO_LIBS}
${SFML_SYSTEM_LIBS}
${SFML_AUDIO_LIBS}
${OPENGL_LIBRARY}
ws2_32
)
elseif( WIN32 ) #MINGW or similar
set(LIBS
${SGCT_LIBS}
${PORTAUDIO_LIBS}
${SFML_SYSTEM_LIBS}
${SFML_AUDIO_LIBS}
${OPENGL_LIBRARY}
ws2_32
)
elseif( APPLE )
find_library(COCOA_LIBRARY Cocoa REQUIRED)
find_library(IOKIT_LIBRARY IOKit REQUIRED)
find_library(COREVIDEO_LIBRARY CoreVideo REQUIRED)
find_library(COREAUDIO_LIBRARY CoreAudio REQUIRED)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox REQUIRED)
find_library(AUDIOUNIT_LIBRARY AudioUnit REQUIRED)
find_library(CORESERVICES_LIBRARY CoreServices REQUIRED)
find_library(CARBON_LIBRARY Carbon REQUIRED)
set(LIBS
${SGCT_LIBS}
${PORTAUDIO_LIBS}
${SFML_SYSTEM_LIBS}
${SFML_AUDIO_LIBS}
${OPENGL_LIBRARY}
${COCOA_LIBRARY}
${IOKIT_LIBRARY}
${COREVIDEO_LIBRARY}
${COREAUDIO_LIBRARY}
${AUDIOTOOLBOX_LIBRARY}
${AUDIOUNIT_LIBRARY}
${CORESERVICES_LIBRARY}
${CARBON_LIBRARY}
)
else() #linux
find_library(X11_LIBRARY X11 REQUIRED)
find_library(XRANDR_LIBRARY Xrandr REQUIRED)
find_library(XI_LIBRARY Xi REQUIRED)
find_library(XXF86VM_LIBRARY Xxf86vm)
find_library(PTHREAD pthread REQUIRED)
set(LIBS
${SGCT_LIBS}
${PORTAUDIO_LIBS}
${SFML_SYSTEM_LIBS}
${SFML_AUDIO_LIBS}
${OPENGL_LIBRARY}
${X11_LIBRARY}
${XRANDR_LIBRARY}
${XI_LIBRARY}
${XXF86VM_LIBRARY}
${PTHREAD}
)
endif()
if( MSVC )
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG")
if( "${MSVC_VERSION}" LESS 1600 ) #less than visual studio 2010
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags
${CMAKE_EXE_LINKER_FLAGS_DEBUG})
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${replacementFlags}" )
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags
${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${replacementFlags}" )
else()
STRING(REPLACE "INCREMENTAL" "INCREMENTAL:NO" replacementFlags
${CMAKE_EXE_LINKER_FLAGS_DEBUG})
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${replacementFlags}" )
STRING(REPLACE "INCREMENTAL" "INCREMENTAL:NO" replacementFlags
${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${replacementFlags}" )
endif()
#MESSAGE(STATUS "flags: ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
endif()
if(MSVC AND NOT "${MSVC_VERSION}" LESS 1400)
add_definitions( "/MP" )
endif()
if( WIN32 )
add_definitions(-D__WIN32__)
elseif( APPLE )
add_definitions(-D__APPLE__)
if( SGCT_CPP11 )
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
add_definitions(-D__SGCT_CPP11__)
else()
set(CMAKE_CXX_FLAGS "-std=c++0x -stdlib=libstdc++ ${CMAKE_CXX_FLAGS}")
endif()
else()
add_definitions(-D__LINUX__)
endif()
target_link_libraries(${APP_NAME} ${LIBS})