forked from springlobby/springlobby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
159 lines (130 loc) · 6.59 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
PROJECT(springlobby)
#set minimum cmake version
cmake_minimum_required(VERSION 3.1)
SET(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} )
if (CMAKE_GENERATOR MATCHES "Ninja")
message(STATUS "Ninja detected, enabling install workarround")
# fixes "ninja install" error:
# file INSTALL cannot find
# "/home/abma/Projects/SpringLobby/src/CMakeFiles/CMakeRelink.dir/springlobby".
set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# workarround for include/c++/4.8/type_traits:268:39: error: use of undeclared identifier '__float128'
add_definitions("-D__STRICT_ANSI__")
endif()
# check for minimal gcc version
set(MIN_GCC_VER "4.7")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${MIN_GCC_VER}")
message(FATAL_ERROR "gcc >=${MIN_GCC_VER} required")
else()
message(STATUS "gcc ${CMAKE_CXX_COMPILER_VERSION} detected")
endif()
endif()
#----------------------------------------------------------------------------------------------------
# General Settings
#----------------------------------------------------------------------------------------------------
SET( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
INCLUDE(compat_flags)
#----------------------------------------------------------------------------------------------------
# Load needed Modules
#----------------------------------------------------------------------------------------------------
if(NOT DEFINED SPRINGLOBBY_REV)
EXECUTE_PROCESS(COMMAND ${springlobby_SOURCE_DIR}/tools/get-revision.sh
OUTPUT_VARIABLE SPRINGLOBBY_REV
ERROR_VARIABLE GIT_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif(NOT DEFINED SPRINGLOBBY_REV)
# PKG-Config
FIND_PACKAGE( PkgConfig )
#----------------------------------------------------------------------------------------------------
# Options, that can be changed be the User in order to customise springlobby
#----------------------------------------------------------------------------------------------------
option( OPTION_TRANSLATION_SUPPORT "Enables translation support to the programs and adds facilities for helping translators (requires GNU Gettext)" TRUE)
option( OPTION_NOTIFY "Enables libnotify support for popup status messages (requires libnotify)" TRUE)
option( BUILD_SHARED_LIBS "Chooses whether to link dynamic or static libraries. Recommend keeping this activated unless you know what you're doing." FALSE)
SET(SHARE_INSTALL_DIR "/share" CACHE PATH "Share directory name")
SET(SPRINGLOBBY_REV "${SPRINGLOBBY_REV}")
if (WIN32)
SET(LOCALE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/locale")
else()
SET(LOCALE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}${SHARE_INSTALL_DIR}/locale")
endif()
IF( AUX_VERSION )
ADD_DEFINITIONS( -DAUX_VERSION="${AUX_VERSION}" )
ENDIF( AUX_VERSION )
INCLUDE(SpringLobbyMacros)
Add_Subdirectory(doc)
#----------------------------------------------------------------------------------------------------
# L10n support
#----------------------------------------------------------------------------------------------------
if( OPTION_TRANSLATION_SUPPORT )
add_subdirectory(po)
endif( OPTION_TRANSLATION_SUPPORT )
ADD_DEFINITIONS( -DLOCALE_INSTALL_DIR="${LOCALE_INSTALL_DIR}" )
Add_Subdirectory(src)
#cppcheck stuff
find_program( CPPCHECK_BINARY NAMES cppcheck )
IF( EXISTS ${CPPCHECK_BINARY} )
ADD_CUSTOM_TARGET( cppcheck )
FOREACH( list ${updaterSrc} ${header} ${SLSharedWithSettings} ${StandAloneSettings} ${curlSRC} ${SettingsSrc} ${springlobbySrc} )
FOREACH( SOURCEFILE ${list} )
LIST( APPEND CHECKPATHS ${SOURCEFILE} )
ENDFOREACH( SOURCEFILE )
ENDFOREACH( list )
ADD_CUSTOM_TARGET( cppcheck-full ${CPPCHECK_BINARY} "--xml" "--enable=all" "-f" "--quiet"
${CHECKPATHS} "2>${CMAKE_CURRENT_BINARY_DIR}/cppcheck-full.xml" "&&"
"${CMAKE_CURRENT_SOURCE_DIR}/tools/cppcheck-htmlreport" "--source-dir=${CMAKE_CURRENT_SOURCE_DIR}/"
"--file=${CMAKE_CURRENT_BINARY_DIR}/cppcheck-full.xml" "--report-dir=report-full" "--title=SpringLobby - Full")
ADD_CUSTOM_TARGET( cppcheck-lite ${CPPCHECK_BINARY} "--xml" "-f" "--quiet"
${CHECKPATHS} "2>${CMAKE_CURRENT_BINARY_DIR}/cppcheck-lite.xml" "&&"
"${CMAKE_CURRENT_SOURCE_DIR}/tools/cppcheck-htmlreport" "--source-dir=${CMAKE_CURRENT_SOURCE_DIR}/"
"--file=${CMAKE_CURRENT_BINARY_DIR}/cppcheck-lite.xml" "--report-dir=report-lite" "--title=SpringLobby - Lite")
add_dependencies( cppcheck cppcheck-full )
add_dependencies( cppcheck cppcheck-lite )
ENDIF( EXISTS ${CPPCHECK_BINARY} )
find_program(CLANG_FORMAT_BINARY NAMES clang-format-3.5 clang-format-3.4 clang-format)
if (EXISTS ${CLANG_FORMAT_BINARY})
file(GLOB_RECURSE files {CMAKE_CURRENT_SOURCE_DIR} src/*.cpp src/*.hpp src/*.h)
foreach(exclude src/lsl;src/downloader/lib ) # exclude some files
foreach(file in ${files})
if (file MATCHES "^${CMAKE_CURRENT_SOURCE_DIR}/${exclude}")
list(REMOVE_ITEM files ${file})
endif()
endforeach()
endforeach()
add_custom_target(format COMMAND ${CLANG_FORMAT_BINARY} -i ${files})
else()
message(WARNING "clang-format not found")
endif()
IF( WIN32 )
LIST( APPEND SLSharedWithSettings ${CMAKE_CURRENT_SOURCE_DIR}/src/stacktrace.c )
ELSE( WIN32 )
LIST( APPEND SLSharedWithSettings ${CMAKE_CURRENT_SOURCE_DIR}/src/stacktrace.cpp )
ENDIF( WIN32 )
INCLUDE(cmake/package_config.cmake)
IF(WIN32)
install(FILES AUTHORS COPYING README THANKS NEWS DESTINATION ${CMAKE_INSTALL_PREFIX})
ELSE (WIN32)
install(FILES AUTHORS COPYING README THANKS NEWS DESTINATION "${CMAKE_INSTALL_PREFIX}${SHARE_INSTALL_DIR}/doc/springlobby")
install(FILES src/images/springlobby.svg DESTINATION "${CMAKE_INSTALL_PREFIX}${SHARE_INSTALL_DIR}/icons/hicolor/scalable/apps")
install(FILES src/springlobby.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}${SHARE_INSTALL_DIR}/applications")
install(FILES share/freedesktop.org/springlobby.appdata.xml DESTINATION "${CMAKE_INSTALL_PREFIX}${SHARE_INSTALL_DIR}/metainfo")
ENDIF (WIN32)
add_custom_target(pack ${CMAKE_MAKE_PROGRAM} package
&& ${springlobby_SOURCE_DIR}/tools/transform_release_zip.sh
${CMAKE_BINARY_DIR}/${PACKAGE_NAME}-${PACKAGE_VERSION}-win32.zip
${CMAKE_STRIP})
# setup make dist
add_custom_target(dist ${CMAKE_SOURCE_DIR}/tools/make_dist.sh "${springlobby_BINARY_DIR}" "${PACKAGE_NAME}-${PACKAGE_VERSION}" "${PACKAGE_VERSION}")
# setup make distcheck
add_custom_target(distcheck + cd ${CMAKE_BINARY_DIR} &&
rm -rf ${PACKAGE_NAME}-${PACKAGE_VERSION} &&
tar -xzf ${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz &&
cd ${PACKAGE_NAME}-${PACKAGE_VERSION}/ &&
cmake "-DCMAKE_CXX_FLAGS:STRING=-O0" . && ${CMAKE_MAKE_PROGRAM})
add_dependencies( distcheck dist )
#add_dependencies( versiontest version )