forked from OGRECave/ogre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
258 lines (221 loc) · 9.07 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------
############################################################
# OgreMain core library
############################################################
# define header and source files for the library
file(GLOB HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
list(APPEND HEADER_FILES
${PROJECT_BINARY_DIR}/include/OgreBuildSettings.h
${PROJECT_BINARY_DIR}/include/OgreComponents.h
${PROJECT_BINARY_DIR}/include/OgreExports.h
${CMAKE_CURRENT_SOURCE_DIR}/include/Ogre.i)
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
# Remove optional header files
list(REMOVE_ITEM HEADER_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/include/OgreDDSCodec.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/OgrePVRTCCodec.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/OgreETCCodec.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/OgreZip.h"
)
# Remove optional source files
list(REMOVE_ITEM SOURCE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/OgreFileSystemLayerNoOp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/OgreDDSCodec.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/OgrePVRTCCodec.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/OgreETCCodec.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/OgreZip.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/OgreSearchOps.cpp"
)
# Add platform specific files
if (EMSCRIPTEN)
set(PLATFORM_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/OgreFileSystemLayerNoOp.cpp")
elseif (WIN32)
file(GLOB PLATFORM_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/WIN32/*.cpp")
elseif (APPLE)
if (APPLE_IOS)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/iOS")
file(GLOB PLATFORM_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/iOS/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/iOS/*.mm")
set(PLATFORM_LIBS "")
else ()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/OSX")
file(GLOB PLATFORM_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/OSX/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/OSX/*.mm")
set(PLATFORM_LIBS "-framework CoreFoundation -framework Foundation")
endif ()
elseif(ANDROID)
# required by OgrePlatformInformation.cpp
include_directories(${ANDROID_NDK}/sources/android/cpufeatures)
file(GLOB PLATFORM_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/Android/*.cpp")
# Remove optional platform source files
list(REMOVE_ITEM PLATFORM_SOURCE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/Android/OgreAPKZipArchive.cpp"
)
elseif (UNIX)
file(GLOB PLATFORM_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/GLX/*.cpp")
set(PLATFORM_LIBS pthread)
endif()
if(NOT WIN32)
list(APPEND PLATFORM_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/OgreSearchOps.cpp")
endif()
# Configure threading files
file(GLOB THREAD_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/Threading/*.h")
include_directories("include/Threading" "src/")
if (OGRE_THREAD_PROVIDER EQUAL 0)
list(APPEND THREAD_HEADER_FILES
include/Threading/OgreThreadDefinesNone.h
include/Threading/OgreDefaultWorkQueueStandard.h
)
set(THREAD_SOURCE_FILES
src/Threading/OgreDefaultWorkQueueStandard.cpp
)
elseif (OGRE_THREAD_PROVIDER EQUAL 1)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
list(APPEND THREAD_HEADER_FILES
include/Threading/OgreThreadDefinesBoost.h
include/Threading/OgreThreadHeadersBoost.h
include/Threading/OgreDefaultWorkQueueStandard.h
)
set(THREAD_SOURCE_FILES
src/Threading/OgreDefaultWorkQueueStandard.cpp
)
elseif (OGRE_THREAD_PROVIDER EQUAL 2)
list(APPEND THREAD_HEADER_FILES
include/Threading/OgreThreadDefinesPoco.h
include/Threading/OgreThreadHeadersPoco.h
include/Threading/OgreDefaultWorkQueueStandard.h
)
set(THREAD_SOURCE_FILES
src/Threading/OgreDefaultWorkQueueStandard.cpp
)
elseif (OGRE_THREAD_PROVIDER EQUAL 3)
list(APPEND THREAD_HEADER_FILES
include/Threading/OgreThreadDefinesTBB.h
include/Threading/OgreThreadHeadersTBB.h
include/Threading/OgreDefaultWorkQueueTBB.h
)
set(THREAD_SOURCE_FILES
src/Threading/OgreDefaultWorkQueueTBB.cpp
)
elseif (OGRE_THREAD_PROVIDER EQUAL 4)
list(APPEND THREAD_HEADER_FILES
include/Threading/OgreThreadDefinesSTD.h
include/Threading/OgreThreadHeadersSTD.h
include/Threading/OgreDefaultWorkQueueStandard.h
)
list(APPEND THREAD_SOURCE_FILES
src/Threading/OgreDefaultWorkQueueStandard.cpp
)
endif ()
list(APPEND HEADER_FILES ${THREAD_HEADER_FILES})
set(LIBRARIES)
if (OGRE_CONFIG_THREADS)
list(APPEND LIBRARIES ${OGRE_THREAD_LIBRARIES})
endif ()
if (OGRE_CONFIG_ENABLE_DDS)
list(APPEND SOURCE_FILES src/OgreDDSCodec.cpp src/OgreDDSCodec.h)
endif ()
if (OGRE_CONFIG_ENABLE_PVRTC)
list(APPEND HEADER_FILES )
list(APPEND SOURCE_FILES src/OgrePVRTCCodec.cpp src/OgrePVRTCCodec.h)
endif ()
if (OGRE_CONFIG_ENABLE_ETC)
list(APPEND SOURCE_FILES src/OgreETCCodec.cpp src/OgreETCCodec.h)
endif ()
if (OGRE_CONFIG_ENABLE_ASTC)
list(APPEND SOURCE_FILES src/OgreASTCCodec.cpp src/OgreASTCCodec.h)
endif ()
if (OGRE_CONFIG_ENABLE_ZIP)
include_directories(src/zip)
list(APPEND HEADER_FILES include/OgreZip.h)
list(APPEND SOURCE_FILES src/OgreZip.cpp src/zip/zip.c)
if(ANDROID)
list(APPEND PLATFORM_SOURCE_FILES src/Android/OgreAPKZipArchive.cpp)
endif()
endif ()
if(OGRE_CONFIG_FILESYSTEM_UNICODE)
set_source_files_properties(src/OgreFileSystem.cpp
PROPERTIES COMPILE_DEFINITIONS _OGRE_FILESYSTEM_ARCHIVE_UNICODE)
set_source_files_properties(src/OgreZip.cpp
PROPERTIES COMPILE_DEFINITIONS _OGRE_FILESYSTEM_ARCHIVE_UNICODE)
endif()
if(OGRE_PROFILING_REMOTERY_PATH)
list(APPEND SOURCE_FILES ${OGRE_PROFILING_REMOTERY_PATH}/Remotery.c)
set_source_files_properties(${OGRE_PROFILING_REMOTERY_PATH}/Remotery.c PROPERTIES LANGUAGE CXX)
set_source_files_properties(src/OgreProfiler.cpp PROPERTIES COMPILE_DEFINITIONS USE_REMOTERY)
endif()
set (TARGET_LINK_FLAGS "")
# setup OgreMain target
get_native_precompiled_header(OgreMain)
add_library(OgreMain ${OGRE_LIB_TYPE} ${OgreMain_pch} ${HEADER_FILES} ${SOURCE_FILES} ${PLATFORM_HEADERS} ${PLATFORM_SOURCE_FILES} ${THREAD_HEADER_FILES} ${THREAD_SOURCE_FILES})
if (WINDOWS_STORE OR WINDOWS_PHONE)
set_target_properties(OgreMain PROPERTIES VS_WINRT_COMPONENT "true")
endif ()
generate_export_header(OgreMain
EXPORT_MACRO_NAME _OgreExport
NO_EXPORT_MACRO_NAME _OgrePrivate
DEPRECATED_MACRO_NAME OGRE_DEPRECATED
EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/OgreExports.h)
target_include_directories(OgreMain PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>"
$<INSTALL_INTERFACE:include/OGRE>
PRIVATE "${OGRE_PROFILING_REMOTERY_PATH}")
# In visual studio 2010 - 64 bit we get this error: "LINK : fatal error LNK1210: exceeded internal ILK size limit; link with /INCREMENTAL:NO"
if(WIN32 AND MSVC10 AND CMAKE_CL_64)
set_target_properties(OgreMain PROPERTIES
VERSION ${OGRE_SOVERSION}
LINK_FLAGS "/INCREMENTAL:NO"
)
else()
set_target_properties(OgreMain PROPERTIES VERSION ${OGRE_SOVERSION} SOVERSION ${OGRE_SOVERSION})
endif()
if (APPLE)
if (APPLE_IOS)
set_target_properties(OgreMain PROPERTIES INSTALL_NAME_DIR "OGRE")
else()
if(OGRE_BUILD_LIBS_AS_FRAMEWORKS)
set(OGRE_OSX_BUILD_CONFIGURATION "${CMAKE_OSX_SYSROOT}/$(CONFIGURATION)")
add_custom_command(TARGET OgreMain POST_BUILD
COMMAND mkdir ARGS -p ${PROJECT_BINARY_DIR}/lib/${OGRE_OSX_BUILD_CONFIGURATION}/Ogre.framework/Headers/Threading
COMMAND ditto
${PROJECT_SOURCE_DIR}/OgreMain/include/Threading/*.h ${PROJECT_BINARY_DIR}/lib/${OGRE_OSX_BUILD_CONFIGURATION}/Ogre.framework/Headers/Threading
COMMAND cd ${PROJECT_BINARY_DIR}/lib/${OGRE_OSX_BUILD_CONFIGURATION}/Ogre.framework/Headers
)
foreach(HEADER_PATH ${THREAD_HEADER_FILES})
get_filename_component(HEADER_FILE ${HEADER_PATH} NAME)
set(FWK_HEADER_PATH ${PROJECT_BINARY_DIR}/lib/${OGRE_OSX_BUILD_CONFIGURATION}/Ogre.framework/Headers/${HEADER_FILE})
add_custom_command(TARGET OgreMain POST_BUILD
COMMAND rm -f ${FWK_HEADER_PATH}
)
endforeach()
endif()
ogre_config_framework(OgreMain)
endif ()
if(OGRE_BUILD_LIBS_AS_FRAMEWORKS)
# Framework is called 'Ogre'
set_target_properties(OgreMain PROPERTIES OUTPUT_NAME Ogre)
endif()
endif ()
target_link_libraries(OgreMain PUBLIC ${PLATFORM_LIBS} PRIVATE ${LIBRARIES} ${CMAKE_DL_LIBS})
# specify a precompiled header to use
add_native_precompiled_header(OgreMain "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/src/OgreStableHeaders.h>")
# install OgreMain
ogre_config_lib(OgreMain TRUE)
install(FILES ${HEADER_FILES}
DESTINATION include/OGRE
)
install(FILES ${PLATFORM_HEADERS}
DESTINATION include/OGRE/${PLATFORM_HEADER_INSTALL}
)
install(FILES ${THREAD_HEADER_FILES}
DESTINATION include/OGRE/Threading
)