-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
104 lines (90 loc) · 4.14 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
# ***************************************************************************
# * Copyright 2015 Michael Eischer, Philipp Nordhus *
# * Robotics Erlangen e.V. *
# * http://www.robotics-erlangen.de/ *
# * [email protected] *
# * *
# * This program is free software: you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License as published by *
# * the Free Software Foundation, either version 3 of the License, or *
# * any later version. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU General Public License for more details. *
# * *
# * You should have received a copy of the GNU General Public License *
# * along with this program. If not, see <http://www.gnu.org/licenses/>. *
# ***************************************************************************
cmake_minimum_required(VERSION 3.5.0)
project(erforce)
enable_testing()
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_SOURCE_DIR}/src/framework/cmake")
if(POLICY CMP0071) # compatibility with CMake 3.10.0
cmake_policy(SET CMP0071 OLD)
endif()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-std=gnu++17 HAVE_C17)
if (NOT HAVE_C17)
message(FATAL_ERROR "Your compiler does not understand -std=c++17, consider updating your compiler")
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++17")
SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED YES)
SET(CMAKE_CXX_EXTENSIONS ON)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
if(MINGW)
find_program(WINDRES_EXECUTABLE NAMES windres)
set(CMAKE_RC_COMPILER_INIT ${WINDRES_EXECUTABLE})
enable_language(RC)
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> \"-I${CMAKE_SOURCE_DIR}/data/pkg\" -i <SOURCE> -o <OBJECT>")
# make sure MinGW doesn't screw up packing the radiocommands
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-ms-bitfields")
endif(MINGW)
if(APPLE)
# the option "S" prevents execution of ranlib
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Sqc <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Sqc <TARGET> <LINK_FLAGS> <OBJECTS>")
# silence ranlib "has no symbols"-warning
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols <TARGET>")
SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols <TARGET>")
endif()
add_custom_target(download)
include(EnvHelper)
find_package(OpenGL REQUIRED)
find_package(Threads REQUIRED)
sanitize_env()
find_package(Protobuf 3.3.0)
restore_env()
# old cmake versions can't detect the protobuf version number
# the protobuf version on such systems is too old to be useful
if(NOT ${PROTOBUF_FOUND} OR ${CMAKE_VERSION} VERSION_LESS 3.6.0 OR NOT TARGET protobuf::protoc)
include(BuildProtobuf)
endif()
set(CMAKE_AUTOMOC ON)
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5OpenGL REQUIRED)
if(NOT APPLE)
# file open dialogs crash on mac
find_package(Jemalloc)
endif()
include(BuildEigen)
include(BuildLuaJIT2)
include(BuildSourceMap)
include(GetGameController)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_subdirectory(src)
if(UNIX AND NOT APPLE)
configure_file(data/pkg/autoref.desktop.in autoref.desktop)
add_custom_target(install-menu
COMMAND xdg-desktop-menu install --novendor ${CMAKE_BINARY_DIR}/autoref.desktop
COMMENT "Installing menu entries" VERBATIM
)
endif()
include(AddTests)