Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CMakeLists.txt « test « ghost « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3f74f97f115aab6aea433f79cef5115b93015288 (plain)
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# SPDX-License-Identifier: GPL-2.0-or-later

# see "cmake --help-policy CMP0003"
# So library linking is more sane
cmake_policy(SET CMP0003 NEW)

# So BUILDINFO and BLENDERPATH strings are automatically quoted
cmake_policy(SET CMP0005 NEW)

# So syntax problems are errors
cmake_policy(SET CMP0010 NEW)

# Input directories must have CMakeLists.txt
cmake_policy(SET CMP0014 NEW)

cmake_minimum_required(VERSION 3.5)

project(GhostMultiTest)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../build_files/cmake/Modules")

set(WITH_GUARDEDALLOC ON)

add_executable(datatoc
  "${CMAKE_SOURCE_DIR}/../../../source/blender/datatoc/datatoc.c")

# Fake the current source dir for includes.
set(_CMAKE_CURRENT_SOURCE_DIR_INIT "${CMAKE_CURRENT_SOURCE_DIR}")

# -----------------------------------------------------------------------------
# Macros

# For data_to_c macro.
# include(../../../build_files/cmake/macros.cmake)

# stub macro, does nothing
macro(blender_add_lib
  name
  sources
  includes
  includes_sys
  library_deps # ignored.
  )

endmacro()

# suffix relative paths so we can use external cmake files
macro(suffix_relpaths
  new_files files prefix)

  set(${new_files})
  foreach(_file ${files})
    if(IS_ABSOLUTE "${_file}")
      list(APPEND ${new_files} ${_file})
    else()
      set(_file_to "${prefix}${_file}")
      list(APPEND ${new_files} ${_file_to})
      get_source_file_property(_is_generated ${_file} GENERATED)
      set_source_files_properties(${_file_to} PROPERTIES GENERATED ${_is_generated})
      unset(_file_to)
      unset(_is_generated)
    endif()
  endforeach()
  unset(_file)
endmacro()

# -----------------------------------------------------------------------------
# Defines

# set the endian define
if(MSVC)
  # for some reason this fails on msvc
  add_definitions(-D__LITTLE_ENDIAN__)
else()
  include(TestBigEndian)
  test_big_endian(_SYSTEM_BIG_ENDIAN)
  if(_SYSTEM_BIG_ENDIAN)
    add_definitions(-D__BIG_ENDIAN__)
  else()
    add_definitions(-D__LITTLE_ENDIAN__)
  endif()
  unset(_SYSTEM_BIG_ENDIAN)
endif()

# -----------------------------------------------------------------------------
# Libraries

if(UNIX AND NOT APPLE)
  set(WITH_GHOST_X11 ON)
endif()

# BLF needs this to ignore GPU library
add_definitions(-DBLF_STANDALONE)

# ghost
include(${CMAKE_SOURCE_DIR}/../CMakeLists.txt)
suffix_relpaths(INC_NEW "${INC}" "../")
suffix_relpaths(SRC_NEW "${SRC}" "../")
include_directories(${INC_NEW})
add_library(ghost_lib ${SRC_NEW})

# string
include(${CMAKE_SOURCE_DIR}/../../string/CMakeLists.txt)
suffix_relpaths(INC_NEW "${INC}" "../../string/")
suffix_relpaths(SRC_NEW "${SRC}" "../../string/")
include_directories(${INC_NEW})
add_library(string_lib ${SRC_NEW})

# numaapi (for 'bli_lib')
include(${CMAKE_SOURCE_DIR}/../../numaapi/CMakeLists.txt)
suffix_relpaths(INC_NEW "${INC}" "../../numaapi/")
suffix_relpaths(SRC_NEW "${SRC}" "../../numaapi/")
include_directories(${INC_NEW})
add_library(numaapi_lib ${SRC_NEW})

# guardedalloc
include(${CMAKE_SOURCE_DIR}/../../guardedalloc/CMakeLists.txt)
suffix_relpaths(INC_NEW "${INC}" "../../guardedalloc/")
suffix_relpaths(SRC_NEW "${SRC}" "../../guardedalloc/")
include_directories(${INC_NEW})
add_library(guardedalloc_lib ${SRC_NEW})

# gpu (used by blenfont)
add_definitions(-DGPU_STANDALONE)
set(CMAKE_CURRENT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../../source/blender/gpu")
include(${CMAKE_SOURCE_DIR}/../../../source/blender/gpu/CMakeLists.txt)
suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/gpu/")
suffix_relpaths(SRC_NEW "${SRC}" "../../../source/blender/gpu/")
include_directories(${INC_NEW})
add_library(gpu_lib ${SRC_NEW})
set(CMAKE_CURRENT_SOURCE_DIR "${_CMAKE_CURRENT_SOURCE_DIR_INIT}")

# imbuf (used by )
# set(CMAKE_CURRENT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../../source/blender/imbuf")
# include(${CMAKE_SOURCE_DIR}/../../../source/blender/imbuf/CMakeLists.txt)
# suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/imbuf/")
# suffix_relpaths(SRC_NEW "${SRC}" "../../../source/blender/imbuf/")
# include_directories(${INC_NEW})
# add_library(imbuf_lib ${SRC_NEW})
# set(CMAKE_CURRENT_SOURCE_DIR "${_CMAKE_CURRENT_SOURCE_DIR_INIT}")

# blenfont
include(${CMAKE_SOURCE_DIR}/../../../source/blender/blenfont/CMakeLists.txt)
suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/blenfont/")
suffix_relpaths(SRC_NEW "${SRC}" "../../../source/blender/blenfont/")
include_directories(${INC_NEW})
add_library(blenfont_lib ${SRC_NEW})

# wcwidth
include(${CMAKE_SOURCE_DIR}/../../../extern/wcwidth/CMakeLists.txt)
suffix_relpaths(INC_NEW "${INC}" "../../../extern/wcwidth/")
suffix_relpaths(SRC_NEW "${SRC}" "../../../extern/wcwidth/")
include_directories(${INC_NEW})
add_library(wcwidth_lib ${SRC_NEW})

# grr, blenfont needs BLI
include_directories(
  "../../../source/blender/blenlib"
)

# Needed for math_matrix.c to avoid eigen_capi.h dep.
add_definitions(-DMATH_STANDALONE)

add_library(bli_lib
  "../../../source/blender/blenlib/intern/fileops.c"
  "../../../source/blender/blenlib/intern/gsqueue.c"
  "../../../source/blender/blenlib/intern/rct.c"
  "../../../source/blender/blenlib/intern/string.c"
  "../../../source/blender/blenlib/intern/string_utf8.c"
  "../../../source/blender/blenlib/intern/listbase.c"
  "../../../source/blender/blenlib/intern/math_color.c"
  "../../../source/blender/blenlib/intern/math_geom.c"
  "../../../source/blender/blenlib/intern/math_matrix.c"
  "../../../source/blender/blenlib/intern/math_rotation.c"
  "../../../source/blender/blenlib/intern/math_vector.c"
  "../../../source/blender/blenlib/intern/storage.c"
  "../../../source/blender/blenlib/intern/task.c"
  "../../../source/blender/blenlib/intern/threads.c"
  "../../../source/blender/blenlib/intern/time.c"
  "../../../source/blender/blenlib/intern/path_util.c"
  "../../../source/blender/blenlib/intern/BLI_dynstr.c"
  "../../../source/blender/blenlib/intern/BLI_ghash.c"
  "../../../source/blender/blenlib/intern/BLI_ghash_utils.c"
  "../../../source/blender/blenlib/intern/BLI_linklist.c"
  "../../../source/blender/blenlib/intern/BLI_memarena.c"
  "../../../source/blender/blenlib/intern/BLI_mempool.c"
  "../../../source/blender/blenlib/intern/hash_mm2a.c"
  "../../../source/blender/blenlib/intern/string_utils.c"
  "../../../source/blender/blenlib/intern/system.c"
)

set(PLATFORM_CGLAGS)

find_package(OpenGL REQUIRED)

find_package(Freetype REQUIRED)

find_package(ZLIB REQUIRED)

include_directories(${CMAKE_SOURCE_DIR}/../)
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${FREETYPE_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/../../../source/blender/blenfont)

if(CMAKE_COMPILER_IS_GNUCC)
  set(PLATFORM_CFLAGS "-funsigned-char")
endif()

if(UNIX AND NOT APPLE)
  find_package(X11 REQUIRED)

  set(PLATFORM_LINKLIBS
    ${X11_X11_LIB}
    ${X11_Xinput_LIB}
    -lpthread
  )
endif()

string(APPEND CMAKE_C_FLAGS " ${PLATFORM_CFLAGS}")
string(APPEND CMAKE_CXX_FLAGS " ${PLATFORM_CFLAGS}")

# -----------------------------------------------------------------------------
# Executables

# Gears (C)
add_executable(gears_c
    ${CMAKE_SOURCE_DIR}/gears/GHOST_C-Test.c)

target_link_libraries(gears_c
    ghost_lib
    string_lib
    ${OPENGL_gl_LIBRARY}
    ${CMAKE_DL_LIBS}
    ${PLATFORM_LINKLIBS}
    )


# Gears (C++)
add_executable(gears_cpp
    ${CMAKE_SOURCE_DIR}/gears/GHOST_Test.cpp)

target_link_libraries(gears_cpp
    ghost_lib
    string_lib
    ${OPENGL_gl_LIBRARY}
    ${CMAKE_DL_LIBS}
    ${PLATFORM_LINKLIBS}
    )


# MultiTest (C)
add_executable(multitest_c
  ${CMAKE_SOURCE_DIR}/multitest/Basic.c
  ${CMAKE_SOURCE_DIR}/multitest/EventToBuf.c
  ${CMAKE_SOURCE_DIR}/multitest/MultiTest.c
  ${CMAKE_SOURCE_DIR}/multitest/ScrollBar.c
  ${CMAKE_SOURCE_DIR}/multitest/Util.c
  ${CMAKE_SOURCE_DIR}/multitest/WindowData.c
  ${CMAKE_SOURCE_DIR}/multitest/stubs.c
)


target_link_libraries(multitest_c
  blenfont_lib
  bli_lib
  gpu_lib
  # imbuf_lib
  ghost_lib
  bli_lib  # again...
  string_lib
  numaapi_lib
  guardedalloc_lib
  wcwidth_lib
  ${OPENGL_gl_LIBRARY}
  ${FREETYPE_LIBRARIES} ${BROTLI_LIBRARIES}
  ${ZLIB_LIBRARIES}
  ${CMAKE_DL_LIBS}
  ${PLATFORM_LINKLIBS}
)