|
1 |
| -#This is the CMake file used to build GDevelop. |
2 |
| -#For more information, see the README.md file. |
| 1 | +# This is the CMake file used to build GDevelop. |
| 2 | +# For more information, see the README.md file. |
3 | 3 |
|
4 |
| -cmake_minimum_required(VERSION 2.6) |
5 |
| -cmake_policy(SET CMP0011 NEW) |
| 4 | +cmake_minimum_required(VERSION 3.5) |
6 | 5 |
|
7 | 6 | # Add utility functions
|
8 | 7 | include(scripts/CMakeClangUtils.txt) # To add clang-format and clang-tidy support to a target
|
9 | 8 |
|
10 | 9 | # Macro for defining an option
|
11 | 10 | macro(gd_set_option var default type docstring)
|
12 |
| - if(NOT DEFINED ${var}) |
13 |
| - set(${var} ${default}) |
14 |
| - endif() |
15 |
| - set(${var} ${${var}} CACHE ${type} ${docstring} FORCE) |
| 11 | + if(NOT DEFINED ${var}) |
| 12 | + set(${var} ${default}) |
| 13 | + endif() |
| 14 | + set(${var} ${${var}} CACHE ${type} ${docstring} FORCE) |
16 | 15 | endmacro()
|
| 16 | + |
| 17 | +# Set options |
17 | 18 | gd_set_option(BUILD_CORE TRUE BOOL "TRUE to build GDevelop Core library")
|
18 | 19 | gd_set_option(BUILD_GDJS TRUE BOOL "TRUE to build GDevelop JS Platform")
|
19 | 20 | gd_set_option(BUILD_EXTENSIONS TRUE BOOL "TRUE to build the extensions")
|
20 | 21 | gd_set_option(BUILD_TESTS TRUE BOOL "TRUE to build the tests")
|
21 | 22 |
|
22 | 23 | # Disable deprecated code
|
23 |
| -set(NO_GUI TRUE CACHE BOOL "" FORCE) #Force disable old GUI related code. |
| 24 | +set(NO_GUI TRUE CACHE BOOL "" FORCE) # Force disable old GUI related code. |
24 | 25 |
|
25 |
| -#Setting up installation directory, for Linux (has to be done before "project" command). |
26 |
| -IF(NOT WIN32) |
27 |
| - if (NOT APPLE) |
28 |
| - gd_set_option(GD_INSTALL_PREFIX "/opt/gdevelop/" STRING "The directory where GDevelop should be installed") |
29 |
| - ELSE() |
30 |
| - gd_set_option(GD_INSTALL_PREFIX "." STRING "The directory where GDevelop should be installed") |
31 |
| - ENDIF() |
| 26 | +# Setting up installation directory, for Linux (has to be done before "project" command). |
| 27 | +if(NOT WIN32) |
| 28 | + if(NOT APPLE) |
| 29 | + gd_set_option(GD_INSTALL_PREFIX "/opt/gdevelop/" STRING "The directory where GDevelop should be installed") |
| 30 | + else() |
| 31 | + gd_set_option(GD_INSTALL_PREFIX "." STRING "The directory where GDevelop should be installed") |
| 32 | + endif() |
32 | 33 |
|
33 |
| - #As we embed SFML, prevent it to be installed system-wide |
| 34 | + # As we embed SFML, prevent it to be installed system-wide |
34 | 35 | set(CMAKE_INSTALL_PREFIX "${GD_INSTALL_PREFIX}/useless")
|
35 |
| -ENDIF() |
| 36 | +endif() |
36 | 37 |
|
37 | 38 | project(GDevelop)
|
38 | 39 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
39 |
| -IF(NOT WIN32 AND NOT APPLE AND NOT BUILD_TESTS) |
40 |
| - SET(CMAKE_SKIP_BUILD_RPATH TRUE) #Avoid errors when packaging for linux. |
41 |
| -ENDIF() |
42 |
| -IF(APPLE) |
| 40 | +if(NOT WIN32 AND NOT APPLE AND NOT BUILD_TESTS) |
| 41 | + set(CMAKE_SKIP_BUILD_RPATH TRUE) # Avoid errors when packaging for linux. |
| 42 | +endif() |
| 43 | +if(APPLE) |
43 | 44 | set(CMAKE_MACOSX_RPATH 1)
|
44 | 45 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
|
45 | 46 | set(CMAKE_INSTALL_RPATH ".")
|
46 | 47 | set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
47 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_") |
48 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-potentially-evaluated-expression") |
49 |
| -ENDIF() |
50 |
| -#Sanity checks |
51 |
| -IF ("${CMAKE_BUILD_TYPE}" STREQUAL "") |
52 |
| - message( "CMAKE_BUILD_TYPE is empty, assuming build type is Release" ) |
| 48 | + add_compile_options( |
| 49 | + -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_ |
| 50 | + -Wno-potentially-evaluated-expression) |
| 51 | +endif() |
| 52 | +# Sanity checks |
| 53 | +if("${CMAKE_BUILD_TYPE}" STREQUAL "") |
| 54 | + message(STATUS "CMAKE_BUILD_TYPE is empty, assuming build type is Release") |
53 | 55 | set(CMAKE_BUILD_TYPE Release)
|
54 |
| -ENDIF() |
| 56 | +endif() |
55 | 57 |
|
56 |
| -IF("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT WIN32 AND CMAKE_COMPILER_IS_GNUCXX) |
57 |
| - SET(CMAKE_SHARED_LINKER_FLAGS "-s") #Force stripping to avoid errors when packaging for linux. |
58 |
| -ENDIF() |
| 58 | +if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT WIN32 AND CMAKE_COMPILER_IS_GNUCXX) |
| 59 | + set(CMAKE_SHARED_LINKER_FLAGS "-s") # Force stripping to avoid errors when packaging for linux. |
| 60 | +endif() |
59 | 61 |
|
60 | 62 | #Activate C++11
|
61 |
| -include(CheckCXXCompilerFlag) |
62 |
| -CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_CXX11) |
63 |
| -CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_CXX0X) |
64 |
| -if(COMPILER_SUPPORTS_CXX11) |
65 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") |
66 |
| -elseif(COMPILER_SUPPORTS_CXX0X) |
67 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") |
68 |
| -else() |
69 |
| - message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support (with GNU extensions). Please use a different C++ compiler.") |
70 |
| -endif() |
| 63 | +set(CMAKE_CXX_STANDARD 11) |
| 64 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
71 | 65 |
|
72 | 66 | # Mark some warnings as errors
|
73 | 67 | if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
74 | 68 | # Activate as much warnings as possible to avoid errors like
|
75 | 69 | # uninitialized variables or other hard to debug bugs.
|
76 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") |
77 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option") |
78 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder-ctor -Wno-reorder -Wno-pessimizing-move -Wno-unused-variable -Wno-unused-private-field") |
| 70 | + add_compile_options( |
| 71 | + -Wall |
| 72 | + -Wno-unknown-warning-option |
| 73 | + -Wno-reorder-ctor |
| 74 | + -Wno-reorder |
| 75 | + -Wno-pessimizing-move |
| 76 | + -Wno-unused-variable |
| 77 | + -Wno-unused-private-field |
79 | 78 |
|
80 |
| - # Make as much warnings considered as errors as possible (only one for now). |
81 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-stack-address") |
| 79 | + # Make as much warnings considered as errors as possible (only one for now). |
| 80 | + -Werror=return-stack-address) |
82 | 81 | endif()
|
83 | 82 |
|
84 |
| -#Define common directories: |
| 83 | +# Define common directories: |
85 | 84 | set(GD_base_dir ${CMAKE_CURRENT_SOURCE_DIR})
|
86 | 85 |
|
87 |
| -#Add all the CMakeLists: |
88 |
| -ADD_SUBDIRECTORY(ExtLibs) |
89 |
| -IF(BUILD_CORE) |
90 |
| - ADD_SUBDIRECTORY(Core) |
91 |
| -ENDIF() |
92 |
| -IF(BUILD_GDJS) |
93 |
| - ADD_SUBDIRECTORY(GDJS) |
94 |
| -ENDIF() |
95 |
| -IF(EMSCRIPTEN) |
96 |
| - ADD_SUBDIRECTORY(GDevelop.js) |
97 |
| -ENDIF() |
98 |
| -IF(BUILD_EXTENSIONS) |
99 |
| - ADD_SUBDIRECTORY(Extensions) |
100 |
| -ENDIF() |
| 86 | +# Add all the CMakeLists: |
| 87 | +add_subdirectory(ExtLibs) |
| 88 | +if(BUILD_CORE) |
| 89 | + add_subdirectory(Core) |
| 90 | +endif() |
| 91 | +if(BUILD_GDJS) |
| 92 | + add_subdirectory(GDJS) |
| 93 | +endif() |
| 94 | +if(EMSCRIPTEN) |
| 95 | + add_subdirectory(GDevelop.js) |
| 96 | +endif() |
| 97 | +if(BUILD_EXTENSIONS) |
| 98 | + add_subdirectory(Extensions) |
| 99 | +endif() |
0 commit comments