aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/CMakeLists.txt
blob: ee983d08aff43641fd1529e70df71ead9c1e80a4 (plain) (blame)
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# UltrastarDX CMake script
# by UltraStar Deluxe Team
#
# CMake primers:
# - Tutorial (Linux Magazin, German):
#   http://www.linux-magazin.de/heft_abo/ausgaben/2007/02/mal_ausspannen
# - Official CMake site:
#   http://www.cmake.org/ 
# - Official CMake 2.6 documentation
#   http://www.cmake.org/cmake/help/cmake2.6docs.html
# - CMake Useful Variables (CMake Wiki):
#   http://www.cmake.org/Wiki/CMake_Useful_Variables
#
# $URL$
# $Id$

##
# CMAKE SETTINGS
##

# min. version and policies
cmake_minimum_required(VERSION 2.6)
# module and script directory
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/dists/cmake/Modules)

##
# PROJECT SETTINGS
##

project(UltrastarDX)

set(CPACK_PACKAGE_NAME "ultrastardx")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "0")

set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}_alpha1")

set(PACKAGE_WEBSITE "http://www.ultrastardeluxe.org/")
set(PACKAGE_IRC "#ultrastardx at quakenet.org")

##
# MAIN DEPENDENCIES
##

find_package(PPC 2.2.0 REQUIRED)
include(UsePascal)
include(ExpandVersion)
include(FileUtils)

##
# LIBRARIES
##

if(NOT WIN32)
  find_package(PkgConfig REQUIRED)

  #find_package(OpenGL)
  #pkg_check_modules(opengl REQUIRED gl)

  pkg_check_modules(sdl REQUIRED sdl)
  #find_package(SDL REQUIRED)

  # find SDL_image
  message(STATUS "Looking for SDL_image")
  find_package(SDL_image)
  if(SDLIMAGE_LIBRARY)
    message(STATUS "Looking for SDL_image - found")
  else(SDLIMAGE_LIBRARY)
    message(FATAL_ERROR "Looking for SDL_image - missing")
  endif(SDLIMAGE_LIBRARY)
  # hide SDL_image from GUI
  mark_as_advanced(SDLIMAGE_LIBRARY SDLIMAGE_INCLUDE_DIR)

  pkg_check_modules(libpng REQUIRED libpng12)
  #find_package(PNG REQUIRED)
  pkg_check_modules(freetype REQUIRED freetype2)
  #find_package(Freetype REQUIRED)
  pkg_check_modules(sqlite3 REQUIRED sqlite3)

  # find FFMpeg
  # Note: do not use the min/max version parameters with ffmpeg
  # otherwise it might fail in ubuntu due to a wrong version number 
  # format in ffmpeg's .pc-files.
  # For example: 0d.51.1.2 instead of the correct 51.1.2.
  #   A check for version >=52.0.0 will return version 0d.51.1.2 
  #   although it is lower because pkg-config is confused by the 0d.
  # Use ${libav...}_VERSION_INT for version-checking instead
  pkg_check_modules(libavcodec REQUIRED libavcodec)
  expand_version(libavcodec_VERSION)
  pkg_check_modules(libavformat REQUIRED libavformat)
  expand_version(libavformat_VERSION)
  pkg_check_modules(libavutil REQUIRED libavutil)
  expand_version(libavutil_VERSION)
  set(ffmpeg_FOUND TRUE)

  # find FFMpeg's swscale lib (just if FFMpeg is compiled in GPL mode)
  pkg_check_modules(libswscale libswscale)
  expand_version(libswscale_VERSION)

  option(ENABLE_PROJECTM "Enable ProjectM support if available" OFF)
  set(libprojectM_USE_CWRAPPER FALSE)
  if(ENABLE_PROJECTM)
    # find projectM version
    set(libprojectM_MODULE "libprojectM >= 0.98")
    pkg_check_modules(libprojectM ${libprojectM_MODULE})

    if(libprojectM_FOUND)
      # get projectM data-dir (for preset- and font-dir)
      execute_process(
        COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir ${libprojectM_MODULE}
        OUTPUT_VARIABLE libprojectM_DATADIR
        OUTPUT_STRIP_TRAILING_WHITESPACE)

      # check if we need the c-wrapper
      if(NOT libprojectM_VERSION VERSION_LESS "1.0.0")
        set(libprojectM_USE_CWRAPPER TRUE)
      endif()
    endif(libprojectM_FOUND)
  endif(ENABLE_PROJECTM)
  expand_version(libprojectM_VERSION)

  # find portaudio
  pkg_check_modules(portaudio REQUIRED portaudio-2.0)
  expand_version(portaudio_VERSION)

  # find portmixer
  pkg_check_modules(portmixer portmixer)
endif(NOT WIN32)

##
# INITIALIZATION
##

include(FileUtils)

set(USDX_GAME_DIR ${CMAKE_CURRENT_BINARY_DIR}/game)
set(USDX_PLUGIN_DIR ${USDX_GAME_DIR}/plugins)

# init runtime environment for out-of-source builds
if(NOT WIN32)
if(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
  # create game dir
  file(MAKE_DIRECTORY ${USDX_GAME_DIR})

  # symlink directories which are shared by all out-of-source builds
  foreach(subdir covers fonts languages resources sounds themes visuals)
    file_symlink(${CMAKE_CURRENT_SOURCE_DIR}/game/${subdir} ${USDX_GAME_DIR}/${subdir})
  endforeach(subdir)

  # copy directories which are either changed by the build process
  # or while execution
  file_copy_dir(${CMAKE_CURRENT_SOURCE_DIR}/game/plugins ${USDX_PLUGIN_DIR})
endif()
endif(NOT WIN32)

##
# COMPILATION
##

add_subdirectory(src)
add_subdirectory(plugins)

macro(add_configuration_target target build_type)
ADD_CUSTOM_TARGET(${target}
  COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_BINARY_DIR}
    ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE:STRING=${build_type} ${PROJECT_SOURCE_DIR}
  COMMAND ${CMAKE_BUILD_TOOL}
  COMMAND ${CMAKE_COMMAND} -E echo "Configuration switched: ${build_type}"
)
endmacro()

# convenience targets to switch between debug and release configuration
add_configuration_target(debug Debug)
add_configuration_target(release Release)

##
# INSTALLATION
##

set(BINDIR "bin" CACHE STRING "Where to install binaries. Either relative to CMAKE_INSTALL_PREFIX or absolute.")
set(DATADIR "share/ultrastardx" CACHE STRING "Where to install game content. Either relative to CMAKE_INSTALL_PREFIX or absolute.")

get_target_property(usdx_exe ultrastardx PASCAL_LOCATION)
install(PROGRAMS ${usdx_exe} DESTINATION ${BINDIR})

install(
  DIRECTORY 
    artwork
    game/covers
    game/fonts
    game/languages
    game/resources
    game/sounds
    game/themes
  DESTINATION ${DATADIR}
  PATTERN .svn EXCLUDE
  PATTERN .PLACEHOLDER EXCLUDE
)
install(
  DIRECTORY ${USDX_PLUGIN_DIR}
  DESTINATION ${DATADIR}
  USE_SOURCE_PERMISSIONS
  PATTERN .svn EXCLUDE
  PATTERN .PLACEHOLDER EXCLUDE
)
install(
  FILES
    COPYING.txt
  DESTINATION ${DATADIR}
)

#if(APPLE)
  include(MacOSXBundle)
#endif(APPLE)

# add "uninstall" target
# See: http://www.vtk.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
CONFIGURE_FILE(
  "${CMAKE_CURRENT_SOURCE_DIR}/dists/cmake/Modules/cmake_uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)

ADD_CUSTOM_TARGET(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")


##
# CPACK
##

# CPack vars

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Karaoke program that evaluates your performance")
set(CPACK_PACKAGE_VENDOR "UltraStar Deluxe Team")
set(CPACK_PACKAGE_FILE_NAME "ultrastardx-${CPACK_PACKAGE_VERSION}")
set(CPACK_PACKAGE_EXECUTABLES "ultrastardx" "ultrastardx")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ultrastardx ${CPACK_PACKAGE_VERSION}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "ultrastardx-${CPACK_PACKAGE_VERSION}-src")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.txt")

if(WIN32 AND NOT UNIX)
  set(CPACK_NSIS_DISPLAY_NAME "UltraStar Deluxe") 
  set(CPACK_NSIS_HELP_LINK ${PACKAGE_WEBSITE})
  set(CPACK_NSIS_URL_INFO_ABOUT ${PACKAGE_WEBSITE})
  set(CPACK_NSIS_CONTACT "help@ultrastardx.org")
  set(CPACK_NSIS_MODIFY_PATH OFF)
  set(CPACK_GENERATOR "ZIP;NSIS")
else(WIN32 AND NOT UNIX)
  set(CPACK_STRIP_FILES TRUE)
endif(WIN32 AND NOT UNIX)


set(CPACK_SOURCE_IGNORE_FILES
  "~"
  "\\\\.svn"
  "\\\\.history"
  "\\\\.exe$"
  "\\\\.a$"
  "\\\\.dll$"
  "\\\\.dof$"
  "\\\\.zip$"
  "\\\\.gz$"
  "\\\\.bz2$"
  "\\\\.tmp$"
  "\\\\.dcu$"
  "\\\\.ppu$"
  "\\\\.o$"
  "\\\\.obj$"
  "link\\\\.res$"
  "CMakeFiles"
  "Makefile$"
  "CPack"
  "install_manifest\\\\.txt$"
  "CMakeCache\\\\.txt$"
  "^${PROJECT_SOURCE_DIR}/[^/]*\\\\.cmake$"
  "^${PROJECT_SOURCE_DIR}/src/.*\\\\.cmake$"
  "^${PROJECT_SOURCE_DIR}/plugins/.*\\\\.cmake$"
  "^${PROJECT_SOURCE_DIR}/game/ultrastardx$"
  "^${PROJECT_SOURCE_DIR}/src/paths\\\\.inc$"
  "^${PROJECT_SOURCE_DIR}/src/config-[^w].*\\\\.inc$"
  "^${PROJECT_SOURCE_DIR}/build/[^d]"
)
if(NOT ${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR})
  list(APPEND CPACK_SOURCE_IGNORE_FILES "^${PROJECT_BINARY_DIR}")
endif()

include(CPack)

##
# SUMMARY
##

message("
!! Configuration of ${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} done!
!!
!! Type \"make\" to compile and 
!!      \"make install\" to install it afterwards.
!!
!! For further information on ${CPACK_PACKAGE_NAME} visit:
!!   ${PACKAGE_WEBSITE}
!!
!! IMPORTANT:
!! This is an UNSUPPORTED ALPHA release for developers only.
!!
!! DO NOT EXPECT THE MAKEFILE OR THE PROGRAM ITSELF TO WORK
!!
!! If you want to contribute, visit the IRC-Channel instead:
!!   ${PACKAGE_IRC}
!!
!! PLEASE DO NOT SEND BUGREPORTS FOR THIS VERSION.
!!")

# TODO: insert this in the public beta release
#!!! In case you find a bug send a bugreport to:
#!!!   ${PACKAGE_BUGREPORT}
#!!! You might as well ask for help at the IRC-Channel
#!!!   ${PACKAGE_IRC}