forked from performous/performous
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
90 lines (74 loc) · 4.01 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
cmake_minimum_required(VERSION 2.8)
project(Performous CXX C)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include(GetGitRevisionDescription)
git_describe(PROJECT_VERSION --tags)
if(NOT PROJECT_VERSION)
set(PROJECT_VERSION "1.1+")
endif()
message("Building ${PROJECT_NAME} ${PROJECT_VERSION}")
# Avoid source tree pollution
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not permitted. Make a separate folder for building:\nmkdir build; cd build; cmake ..\nBefore that, remove the files already created:\nrm -rf CMakeCache.txt CMakeFiles")
endif(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
# Add a sensible build type default and warning because empty means no optimization and no debug info.
if(NOT CMAKE_BUILD_TYPE)
message("WARNING: CMAKE_BUILD_TYPE is not defined!\n Defaulting to CMAKE_BUILD_TYPE=RelWithDebInfo. Use ccmake to set a proper value.")
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_definitions("-DNDEBUG")
endif()
# Enable C++14 support and other compiler flags...
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
message("Detected GCC version ${GCC_VERSION}")
if (GCC_VERSION VERSION_GREATER 7 OR GCC_VERSION VERSION_EQUAL 7)
set(CMAKE_CXX_FLAGS "-std=c++14 -Wall -Wextra -fcx-limited-range ${CMAKE_CXX_FLAGS}")
elseif (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
set(CMAKE_CXX_FLAGS "-std=c++1y -Wall -Wextra -Wno-attributes -Wno-deprecated-declarations -fcx-limited-range ${CMAKE_CXX_FLAGS}")
message(WARNING "Your GCC is rather old, disabling some useful compiler warnings (GCC 7+ or Clang 5+ recommended for proper C++17 support).")
else()
message(FATAL_ERROR "Your C++ compiler is too old, please upgrade.")
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# Note: AUTO_PTR is for Boost which won't compile with C++17 otherwise (fixed in Boost git but not in 1.66)
set(CMAKE_CXX_FLAGS "-std=c++1z -Wall -Wextra -D_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR ${CMAKE_CXX_FLAGS}")
endif()
if(WIN32)
set(CMAKE_CXX_FLAGS "-DWIN32_LEAN_AND_MEAN ${CMAKE_CXX_FLAGS}")
set(SHARE_INSTALL_DEFAULT ".")
SET(LOCALE_DIR_DEFAULT "locale")
else()
set(SHARE_INSTALL_DEFAULT "share/games/performous")
SET(LOCALE_DIR_DEFAULT "share/locale")
endif()
set(SHARE_INSTALL "${SHARE_INSTALL_DEFAULT}" CACHE STRING "Data file install path. Must be a relative path (from CMAKE_INSTALL_PREFIX), with no trailing slash.")
mark_as_advanced(SHARE_INSTALL)
set(LOCALE_DIR "${LOCALE_DIR_DEFAULT}" CACHE STRING "Locale file install path. Must be a relative path (from CMAKE_INSTALL_PREFIX), with no trailing slash.")
mark_as_advanced(LOCALE_DIR)
find_package(Gettext)
if(Gettext_FOUND)
message(STATUS "Localization enabled: Building and installing .mo files")
add_subdirectory(lang)
else()
message(STATUS "Localization disabled: Gettext tools (msgfmt) missing")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ced)
add_subdirectory(data)
add_subdirectory(game)
add_subdirectory(ced)
add_subdirectory(docs)
if(WIN32)
install(FILES win32/ConfigureSongDirectory.bat DESTINATION .)
endif()
#CPACK variables
include(CPack)
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Niek Nooijens")
SET(CPACK_PACKAGE_CONTACT "[email protected]")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libavcodec54, libavformat54, libswresample2, libsdl2-2.0-0, libportaudiocpp0, libboost-all-dev, libswscale2, libxml++2.6-2, libopencv-dev, librsvg2-2, libpango-1.0-0, libcairo2, libjpeg8, libpng12-0, libportmidi0 ")
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION_SUMMARY "A free music rhythm game similar to SingStar, Guitar Hero and DDR")
SET(CPACK_DEBIAN_PACKAGE_VERSION ${PROJECT_VERSION})
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
SET(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${PROJECT_NAME};ALL;/")