-
Notifications
You must be signed in to change notification settings - Fork 308
/
CMakeLists.txt
166 lines (130 loc) · 6.23 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
159
160
161
162
163
164
165
166
cmake_minimum_required(VERSION 3.14) # Native support for Android in CMAKE requires at least version 3.7.
# Project details.
project(Horde3D)
set(CMAKE_CXX_STANDARD 11)
SET(${PROJECT_NAME}_MAJOR_VERSION 2)
SET(${PROJECT_NAME}_MINOR_VERSION 0)
SET(${PROJECT_NAME}_PATCH_LEVEL 0)
# Add local repository for FindXXX.cmake modules.
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/BuildTools/CMake/Modules" ${CMAKE_MODULE_PATH})
# Check for strncpy_s function.
include(CheckFunctionExists)
check_function_exists(strncpy_s HAVE_STRNCPY_S)
# To build or not to build examples (removes GLFW or SDL dependency)
option(HORDE3D_BUILD_EXAMPLES "Builds Horde3D examples" ON)
# Check the required windowing backend
if(HORDE3D_BUILD_EXAMPLES)
include(CMakeDependentOption)
# We can use SDL or GLFW
# SDL is the only choice for IOS and Android
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows" OR
${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
option(HORDE3D_USE_SDL "Use SDL for window creation/event handling" OFF)
option(HORDE3D_USE_GLFW "Use GLFW for window creation/event handling" ON)
else()
# IOS and android are not supported by glfw
option(HORDE3D_USE_SDL "Use SDL for window creation/event handling" ON)
endif()
if(HORDE3D_USE_GLFW)
# Look for required GLFW library.
option(HORDE3D_FORCE_DOWNLOAD_GLFW "Force linking Horde3D to a downloaded version of GLFW" OFF)
find_package(GLFW)
IF(GLFW_FOUND)
include_directories(${GLFW_INCLUDE_DIR})
ENDIF(GLFW_FOUND)
endif()
if(HORDE3D_USE_SDL)
# Look for required SDL library.
option(HORDE3D_FORCE_DOWNLOAD_SDL "Force linking Horde3D to a downloaded version of SDL" OFF)
IF( ${CMAKE_SYSTEM_NAME} MATCHES "iOS" )
set( HORDE3D_FORCE_DOWNLOAD_SDL OFF )
endif()
find_package(SDL2)
IF(SDL2_FOUND)
include_directories(${SDL2_INCLUDE_DIR})
ENDIF(SDL2_FOUND)
endif()
# Only one library can be used, so disable the other one
if(GLFW_FOUND)
set(HORDE3D_USE_SDL OFF CACHE BOOL "Use SDL for window creation/event handling" FORCE)
elseif(SDL_FOUND)
set(HORDE3D_USE_GLFW OFF CACHE BOOL "Use GLFW for window creation/event handling" FORCE)
endif()
else()
message("Not building examples.")
endif(HORDE3D_BUILD_EXAMPLES)
# Render backend selection
option(HORDE3D_USE_GL2 "Add OpenGL 2 render backend. Turns off ES3 render backend." ON)
option(HORDE3D_USE_GL4 "Add OpenGL 4 render backend. Turns off ES3 render backend." ON)
option(HORDE3D_USE_GLES3 "Add OpenGL ES 3 render backend. Turns off desktop GL backends." OFF)
if(HORDE3D_USE_GLES3)
set(USE_GLES3 TRUE)
set(HORDE3D_USE_GL2 OFF CACHE BOOL "Add OpenGL 2 render backend. Turns off ES3 render backend." FORCE)
set(HORDE3D_USE_GL4 OFF CACHE BOOL "Add OpenGL 4 render backend. Turns off ES3 render backend." FORCE)
endif(HORDE3D_USE_GLES3)
if(HORDE3D_USE_GL2 OR HORDE3D_USE_GL4)
if(HORDE3D_USE_GL2)
set(USE_GL2 TRUE)
endif(HORDE3D_USE_GL2)
if(HORDE3D_USE_GL4)
set(USE_GL4 TRUE)
endif(HORDE3D_USE_GL4)
set(HORDE3D_USE_GLES3 OFF CACHE BOOL "Add OpenGL ES 3 render backend. Turns off desktop GL backends." FORCE)
endif(HORDE3D_USE_GL2 OR HORDE3D_USE_GL4)
if (NOT HORDE3D_USE_GL2 AND NOT HORDE3D_USE_GL4 AND NOT HORDE3D_USE_GLES3 )
message( SEND_ERROR "Rendering backend is not selected!")
endif()
# Set binaries output folder.
SET(HORDE3D_OUTPUT_PATH_PREFIX "${PROJECT_BINARY_DIR}/Binaries")
SET(HORDE3D_OUTPUT_PATH_SUFFIX "")
IF(${CMAKE_CFG_INTDIR} STREQUAL ".")
SET(HORDE3D_OUTPUT_PATH_SUFFIX ${CMAKE_BUILD_TYPE})
IF(NOT HORDE3D_OUTPUT_PATH_SUFFIX)
SET(HORDE3D_OUTPUT_PATH_SUFFIX "Release")
ENDIF(NOT HORDE3D_OUTPUT_PATH_SUFFIX)
ENDIF(${CMAKE_CFG_INTDIR} STREQUAL ".")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${HORDE3D_OUTPUT_PATH_PREFIX}/${CMAKE_SYSTEM_NAME}/${HORDE3D_OUTPUT_PATH_SUFFIX} CACHE STRING "Where binaries and shared lib files go" FORCE)
IF( ${CMAKE_SYSTEM_NAME} STREQUAL "Android" )
# Copy android project into build directory
SET(HORDE3D_ANDROID_PROJECT_PATH "${PROJECT_SOURCE_DIR}/BuildTools/android")
# For Linux we have to set ANDROID_SDK_ROOT variable
set(ANDROID_SDK_ROOT_PATH "" CACHE STRING "Path to Android SDK")
# Set rendering interface to GLES3
set(USE_GLES3 TRUE)
set(HORDE3D_USE_GL2 OFF CACHE BOOL "Add OpenGL 2 render backend. Turns off ES3 render backend." FORCE)
set(HORDE3D_USE_GL4 OFF CACHE BOOL "Add OpenGL 4 render backend. Turns off ES3 render backend." FORCE)
# On Linux set gradlew to be executable (a bit of a hack)
if( ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux" )
execute_process( COMMAND chmod "+x" "${PROJECT_SOURCE_DIR}/BuildTools/android/gradlew" )
endif()
# file(COPY "BuildTools/android" DESTINATION ${HORDE3D_OUTPUT_PATH_PREFIX}/${CMAKE_SYSTEM_NAME})
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${HORDE3D_OUTPUT_PATH_PREFIX}/${CMAKE_SYSTEM_NAME}/android/app/src/main/jniLibs/${ANDROID_ABI} )
ENDIF()
IF( ${CMAKE_SYSTEM_NAME} MATCHES "iOS" )
include( "ios" )
SET(HORDE3D_IOS_TOOLS_PATH "${PROJECT_SOURCE_DIR}/BuildTools/ios")
set(IOS_CODE_SIGN_IDENTITY "Apple Development" CACHE STRING "Code sign (used for application signing)")
set(IOS_DEVELOPMENT_TEAM "" CACHE STRING "Development team id (used for application signing)")
# Set rendering interface to GLES3
set(USE_GLES3 TRUE)
set(HORDE3D_USE_GL2 OFF CACHE BOOL "Add OpenGL 2 render backend. Turns off ES3 render backend." FORCE)
set(HORDE3D_USE_GL4 OFF CACHE BOOL "Add OpenGL 4 render backend. Turns off ES3 render backend." FORCE)
set(HORDE3D_USE_GLES3 ON CACHE BOOL "Add OpenGL ES 3 render backend. Turns off desktop GL backends." FORCE)
ENDIF()
IF(MSVC)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:mainCRTStartup ")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG" )
# Manage extensions.
include(Extensions/Extensions.txt)
# Add engine target.
add_subdirectory(Horde3D)
option(HORDE3D_BUILD_EDITOR "Build Horde3D Editor" OFF)
if(HORDE3D_BUILD_EDITOR)
add_subdirectory(Horde3DEditor)
endif(HORDE3D_BUILD_EDITOR)
if(POLICY CMP0058)
cmake_policy(SET CMP0058 NEW)
endif()