forked from koraa/sauerbraten-fork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
88 lines (66 loc) · 3.1 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
cmake_minimum_required(VERSION 2.8.12)
include(cmake/functions.cmake)
include(cmake/glibc_cxx11_abi_detection.cmake)
include(cmake/silence_find_pathprogram.cmake)
### Different Configuration Types (Debug release)
# Only generate Debug and Release configuration types.
set(CMAKE_CONFIGURATION_TYPES Debug Release)
# First choice is Debug
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE INTERN "")
endif()
message(STATUS "CMAKE_VERSION = ${CMAKE_VERSION}")
message(STATUS "CMAKE_GENERATOR = ${CMAKE_GENERATOR}")
# Set a default toolchain file
string(TOLOWER "${CMAKE_GENERATOR}" GEN)
if(GEN MATCHES ".*visual studio.*")
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/platform/vs.cmake)
elseif(GEN MATCHES ".*mingw.*" OR MINGW)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/platform/mingw.cmake)
else()
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/platform/linux.cmake)
endif()
message(STATUS "Using Toolchain File ${CMAKE_TOOLCHAIN_FILE}")
# Project Name and start working in project scope (some things just work until now, some just work after this command)
project(Inexor)
# Use folders in the resulting project files.
set_property(GLOBAL PROPERTY OS_FOLDERS ON)
# Get compiler/os/architecture variables
include(cmake/platform_detection.cmake)
# Set compile flags and compile specific definitions
include(cmake/compile_flags_and_defs.cmake)
#### Install paths ####
# Error if paths aren't set well
get_filename_component(MAINDIR "${CMAKE_SOURCE_DIR}" REALPATH) # Main inexor folder
get_filename_component(BINDIR "${CMAKE_BINARY_DIR}" REALPATH) # Where it generates the projects into
if(${MAINDIR} STREQUAL ${BINDIR})
message(FATAL_ERROR "Keep your directories clean, don't generate the project-files in the main directory! ${MAINDIR} ${BINDIR}")
endif()
# Set the path to inexor/ explicitly to simplify some following definitions
set(SOURCE_DIR ${MAINDIR}/inexor)
# INSTALL_LOCALLY will surpress the installation into CMAKE_INSTALL_PREFIX which is by default some global system path.
option(INSTALL_LOCALLY "Install everything relative to this folder (${MAINDIR}). Not into some global system directories." ON)
if(INSTALL_LOCALLY)
set(CMAKE_INSTALL_PREFIX ${MAINDIR} CACHE PATH "" FORCE)
message(STATUS "Local installation chosen. No files will move outside this folder (${MAINDIR}). .. ${CMAKE_INSTALL_PREFIX}")
endif()
# Define where to move the binary by target 'install'
if(OS_LINUX)
set(EXE_DIR "bin/linux/${PROJECT_ARCH}")
elseif(OS_MACOSX)
set(EXE_DIR "bin/mac/${PROJECT_ARCH}")
elseif(OS_WINDOWS)
set(EXE_DIR "bin/windows/win${PROJECT_ARCH}")
endif()
set(INSTALL_RESOURCES_DIR "bin/all")
message(STATUS "Generating Project-Files to ${CMAKE_CURRENT_BINARY_DIR}")
message(STATUS "Resulting Executable goes to ${EXE_DIR}")
### Go for the subfolders.
add_subdirectory(vendor)
add_subdirectory(inexor)
install(FILES ${INSTALL_SHARED_LIBS} ${INSTALL_EXES} DESTINATION ${EXE_DIR})
install(FILES ${INSTALL_RESOURCES} DESTINATION ${INSTALL_RESOURCES_DIR})
# shipped portable stuff on win (dirty but temporarily)
if(OS_WINDOWS)
install(DIRECTORY ${INSTALL_PORTABLE_DIR} DESTINATION "bin/windows/all")
endif()