-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
165 lines (136 loc) · 5.65 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
#-------------------------------------------------------------------
# This file is part of the CMake build system for SkyX
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------
######################################################################
# SKYX BUILD SYSTEM
# Welcome to the CMake build system for SKYX.
# Inspired from the Ogre build system (modules FindPkgMacros.cmake,
# This is the main file where we prepare the general build environment
# and provide build configuration options.
######################################################################
cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0003 NEW)
project(SKYX)
# Include necessary submodules
set(CMAKE_MODULE_PATH
"${SKYX_SOURCE_DIR}/CMake"
"${SKYX_SOURCE_DIR}/CMake/Utils"
)
include(SkyXFindPkgMacros)
getenv_path(OGRE_HOME)
# Set where to find ogre Cmake files on unix
if (UNIX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/local/lib/OGRE/cmake/" "/usr/lib/OGRE/cmake/")
else (UNIX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ENV_OGRE_HOME}/CMake)
endif ()
include(CMakeDependentOption)
include(CheckCXXCompilerFlag)
include(SkyXMacroLogFeature)
include(SkyXConfigTargets)
set(SKYX_TEMPLATES_DIR "${SKYX_SOURCE_DIR}/CMake/Templates")
set(SKYX_WORK_DIR ${SKYX_BINARY_DIR})
#####################################################################
# Set up the basic build environment
#####################################################################
if (CMAKE_BUILD_TYPE STREQUAL "")
# CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up
# differentiation between debug and release builds.
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif ()
# determine SkyX version numbers
include(SkyXGetVersion)
skyx_get_version(${SKYX_SOURCE_DIR}/SkyX/Include/Prerequisites.h)
message(STATUS "Configuring SKYX ${SKYX_VERSION}")
if (NOT APPLE)
# Create debug libraries with _d postfix
set(CMAKE_DEBUG_POSTFIX "_d")
endif ()
# Set compiler specific build flags
if (CMAKE_COMPILER_IS_GNUCXX)
# check_cxx_compiler_flag(-msse OGRE_GCC_HAS_SSE)
# if (OGRE_GCC_HAS_SSE)
# add_definitions(-msse)
# endif ()
endif ()
if (MSVC)
add_definitions(/fp:fast)
endif ()
if (CMAKE_COMPILER_IS_GNUCXX)
# Test for GCC visibility
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-fvisibility=hidden SKYX_GCC_VISIBILITY)
if (OGRE_GCC_VISIBILITY)
# determine gcc version
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE SKYX_GCC_VERSION
)
message(STATUS "Detected g++ ${SKYX_GCC_VERSION}")
message(STATUS "Enabling GCC visibility flags")
set(SKYX_GCC_VISIBILITY_FLAGS "-DSKYX_GCC_VISIBILITY -fvisibility=hidden")
# check if we can safely add -fvisibility-inlines-hidden
string(TOLOWER "${CMAKE_BUILD_TYPE}" SKYX_BUILD_TYPE)
if (SKYX_BUILD_TYPE STREQUAL "debug" AND SKYX_GCC_VERSION VERSION_LESS "4.2")
message(STATUS "Skipping -fvisibility-inlines-hidden due to possible bug in g++ < 4.2")
else ()
set(SKYX_GCC_VISIBILITY_FLAGS "${SKYX_GCC_VISIBILITY_FLAGS} -fvisibility-inlines-hidden")
endif ()
endif (OGRE_GCC_VISIBILITY)
# Fix x64 issues on Linux
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" AND NOT APPLE)
add_definitions(-fPIC)
endif()
endif (CMAKE_COMPILER_IS_GNUCXX)
# Add Main include path
include_directories("${SKYX_SOURCE_DIR}/SkyX/include")
# Find dependencies
include(SkyXDependencies)
# definitions for samples
set(SKYX_LIBRARIES SkyX)
if (NOT WIN32)
set(SKYX_LIBRARIES ${SKYX_LIBRARIES} pthread)
endif(NOT WIN32)
# Specify build paths
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${SKYX_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${SKYX_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${SKYX_BINARY_DIR}/bin")
if (WIN32 OR APPLE)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# We don't want to install in default system location, install is really for the SDK, so call it for that
set(CMAKE_INSTALL_PREFIX
"${SKYX_BINARY_DIR}/sdk" CACHE PATH "SKYX install prefix" FORCE)
endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif(WIN32 OR APPLE)
######################################################################
# Provide user options to customise the build process
######################################################################
# Customise what to build
option(SKYX_BUILD_SAMPLES "Build SkyX demos" TRUE)
# Customise what to install
option(SKYX_INSTALL_SAMPLES "Install SkyX demos." TRUE)
cmake_dependent_option(SKYX_INSTALL_PDB "Install debug pdb files" FALSE "MSVC" FALSE)
cmake_dependent_option(SKYX_STATIC "Static build" FALSE "OGRE_STATIC" FALSE)
###################################################################
# configure global build settings based on selected build options
###################################################################
include(SkyXConfigureBuild)
##################################################################
# Now setup targets
##################################################################
# install resource files
#include(InstallResources)
# Setup SkyX core project
add_subdirectory(SkyX)
# Setup samples
if(SKYX_BUILD_SAMPLES)
add_subdirectory(SkyXDemo1) # Comment this line if you're using Ogre 1.8+, since this demo uses the old Ogre Terrain Scene Manager
add_subdirectory(SkyXDemo2)
add_subdirectory(SkyXDemo3)
endif(SKYX_BUILD_SAMPLES)
# Install CMake modules
add_subdirectory(CMake)
# Install runtime files and medias
add_subdirectory(SkyXCommon)