Fix error in context menu when built without freestyle
[blender.git] / intern / ghost / test / CMakeLists.txt
1
2 # see "cmake --help-policy CMP0003"
3 # So library linking is more sane
4 cmake_policy(SET CMP0003 NEW)
5
6 # So BUILDINFO and BLENDERPATH strings are automatically quoted
7 cmake_policy(SET CMP0005 NEW)
8
9 # So syntax problems are errors
10 cmake_policy(SET CMP0010 NEW)
11
12 # Input directories must have CMakeLists.txt
13 cmake_policy(SET CMP0014 NEW)
14
15 cmake_minimum_required(VERSION 3.5)
16
17 project(GhostMultiTest)
18
19 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../build_files/cmake/Modules")
20
21 set(WITH_GUARDEDALLOC ON)
22
23 add_executable(datatoc
24   "${CMAKE_SOURCE_DIR}/../../../source/blender/datatoc/datatoc.c")
25
26 # Fake the current source dir for includes.
27 set(_CMAKE_CURRENT_SOURCE_DIR_INIT "${CMAKE_CURRENT_SOURCE_DIR}")
28
29 # -----------------------------------------------------------------------------
30 # Macros
31
32 # For data_to_c macro.
33 # include(../../../build_files/cmake/macros.cmake)
34
35 # stub macro, does nothing
36 macro(blender_add_lib
37   name
38   sources
39   includes
40   includes_sys
41   library_deps # ignored.
42   )
43
44 endmacro()
45
46 # suffix relative paths so we can use external cmake files
47 macro(suffix_relpaths
48   new_files files prefix)
49
50   set(${new_files})
51   foreach(_file ${files})
52     if(IS_ABSOLUTE "${_file}")
53       list(APPEND ${new_files} ${_file})
54     else()
55       set(_file_to "${prefix}${_file}")
56       list(APPEND ${new_files} ${_file_to})
57       get_source_file_property(_is_generated ${_file} GENERATED)
58       set_source_files_properties(${_file_to} PROPERTIES GENERATED ${_is_generated})
59       unset(_file_to)
60       unset(_is_generated)
61     endif()
62   endforeach()
63   unset(_file)
64 endmacro()
65
66 # -----------------------------------------------------------------------------
67 # Defines
68
69 # set the endian define
70 if(MSVC)
71   # for some reason this fails on msvc
72   add_definitions(-D__LITTLE_ENDIAN__)
73 else()
74   include(TestBigEndian)
75   test_big_endian(_SYSTEM_BIG_ENDIAN)
76   if(_SYSTEM_BIG_ENDIAN)
77     add_definitions(-D__BIG_ENDIAN__)
78   else()
79     add_definitions(-D__LITTLE_ENDIAN__)
80   endif()
81   unset(_SYSTEM_BIG_ENDIAN)
82 endif()
83
84 # -----------------------------------------------------------------------------
85 # Libraries
86
87 if(UNIX AND NOT APPLE)
88   set(WITH_GHOST_X11 ON)
89 endif()
90
91 # for now... default to this
92 add_definitions(-DWITH_GL_PROFILE_COMPAT)
93 # BLF needs this to ignore GPU library
94 add_definitions(-DBLF_STANDALONE)
95
96 # ghost
97 include(${CMAKE_SOURCE_DIR}/../CMakeLists.txt)
98 suffix_relpaths(INC_NEW "${INC}" "../")
99 suffix_relpaths(SRC_NEW "${SRC}" "../")
100 include_directories(${INC_NEW})
101 add_library(ghost_lib ${SRC_NEW})
102
103 # string
104 include(${CMAKE_SOURCE_DIR}/../../string/CMakeLists.txt)
105 suffix_relpaths(INC_NEW "${INC}" "../../string/")
106 suffix_relpaths(SRC_NEW "${SRC}" "../../string/")
107 include_directories(${INC_NEW})
108 add_library(string_lib ${SRC_NEW})
109
110 # numaapi (for 'bli_lib')
111 include(${CMAKE_SOURCE_DIR}/../../numaapi/CMakeLists.txt)
112 suffix_relpaths(INC_NEW "${INC}" "../../numaapi/")
113 suffix_relpaths(SRC_NEW "${SRC}" "../../numaapi/")
114 include_directories(${INC_NEW})
115 add_library(numaapi_lib ${SRC_NEW})
116
117 # guardedalloc
118 include(${CMAKE_SOURCE_DIR}/../../guardedalloc/CMakeLists.txt)
119 suffix_relpaths(INC_NEW "${INC}" "../../guardedalloc/")
120 suffix_relpaths(SRC_NEW "${SRC}" "../../guardedalloc/")
121 include_directories(${INC_NEW})
122 add_library(guardedalloc_lib ${SRC_NEW})
123
124 # gpu (used by blenfont)
125 add_definitions(-DGPU_STANDALONE)
126 set(CMAKE_CURRENT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../../source/blender/gpu")
127 include(${CMAKE_SOURCE_DIR}/../../../source/blender/gpu/CMakeLists.txt)
128 suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/gpu/")
129 suffix_relpaths(SRC_NEW "${SRC}" "../../../source/blender/gpu/")
130 include_directories(${INC_NEW})
131 add_library(gpu_lib ${SRC_NEW})
132 set(CMAKE_CURRENT_SOURCE_DIR "${_CMAKE_CURRENT_SOURCE_DIR_INIT}")
133
134 # imbuf (used by )
135 # set(CMAKE_CURRENT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../../source/blender/imbuf")
136 # include(${CMAKE_SOURCE_DIR}/../../../source/blender/imbuf/CMakeLists.txt)
137 # suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/imbuf/")
138 # suffix_relpaths(SRC_NEW "${SRC}" "../../../source/blender/imbuf/")
139 # include_directories(${INC_NEW})
140 # add_library(imbuf_lib ${SRC_NEW})
141 # set(CMAKE_CURRENT_SOURCE_DIR "${_CMAKE_CURRENT_SOURCE_DIR_INIT}")
142
143 # blenfont
144 include(${CMAKE_SOURCE_DIR}/../../../source/blender/blenfont/CMakeLists.txt)
145 suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/blenfont/")
146 suffix_relpaths(SRC_NEW "${SRC}" "../../../source/blender/blenfont/")
147 include_directories(${INC_NEW})
148 add_library(blenfont_lib ${SRC_NEW})
149
150 # wcwidth
151 include(${CMAKE_SOURCE_DIR}/../../../extern/wcwidth/CMakeLists.txt)
152 suffix_relpaths(INC_NEW "${INC}" "../../../extern/wcwidth/")
153 suffix_relpaths(SRC_NEW "${SRC}" "../../../extern/wcwidth/")
154 include_directories(${INC_NEW})
155 add_library(wcwidth_lib ${SRC_NEW})
156
157 # glew-mx
158 include(${CMAKE_SOURCE_DIR}/../../../intern/glew-mx/CMakeLists.txt)
159 suffix_relpaths(INC_NEW "${INC}" "../../../intern/glew-mx/")
160 suffix_relpaths(SRC_NEW "${SRC}" "../../../intern/glew-mx/")
161 include_directories(${INC_NEW})
162 add_library(glewmx_lib ${SRC_NEW})
163
164 # grr, blenfont needs BLI
165 include_directories(
166   "../../../source/blender/blenlib"
167 )
168
169 # Needed for math_matrix.c to avoid eigen_capi.h dep.
170 add_definitions(-DMATH_STANDALONE)
171
172 add_library(bli_lib
173   "../../../source/blender/blenlib/intern/fileops.c"
174   "../../../source/blender/blenlib/intern/gsqueue.c"
175   "../../../source/blender/blenlib/intern/rct.c"
176   "../../../source/blender/blenlib/intern/string.c"
177   "../../../source/blender/blenlib/intern/string_utf8.c"
178   "../../../source/blender/blenlib/intern/listbase.c"
179   "../../../source/blender/blenlib/intern/math_color.c"
180   "../../../source/blender/blenlib/intern/math_geom.c"
181   "../../../source/blender/blenlib/intern/math_matrix.c"
182   "../../../source/blender/blenlib/intern/math_rotation.c"
183   "../../../source/blender/blenlib/intern/math_vector.c"
184   "../../../source/blender/blenlib/intern/storage.c"
185   "../../../source/blender/blenlib/intern/task.c"
186   "../../../source/blender/blenlib/intern/threads.c"
187   "../../../source/blender/blenlib/intern/time.c"
188   "../../../source/blender/blenlib/intern/path_util.c"
189   "../../../source/blender/blenlib/intern/BLI_dynstr.c"
190   "../../../source/blender/blenlib/intern/BLI_ghash.c"
191   "../../../source/blender/blenlib/intern/BLI_ghash_utils.c"
192   "../../../source/blender/blenlib/intern/BLI_linklist.c"
193   "../../../source/blender/blenlib/intern/BLI_memarena.c"
194   "../../../source/blender/blenlib/intern/BLI_mempool.c"
195   "../../../source/blender/blenlib/intern/hash_mm2a.c"
196   "../../../source/blender/blenlib/intern/string_utils.c"
197   "../../../source/blender/blenlib/intern/system.c"
198 )
199
200 set(PLATFORM_CGLAGS)
201
202 find_package(OpenGL REQUIRED)
203
204 find_package(Freetype REQUIRED)
205
206 find_package(ZLIB REQUIRED)
207
208 include_directories(${CMAKE_SOURCE_DIR}/../)
209 include_directories(${OPENGL_INCLUDE_DIR})
210 include_directories(${FREETYPE_INCLUDE_DIRS})
211 include_directories(${CMAKE_SOURCE_DIR}/../../../source/blender/blenfont)
212
213 if(CMAKE_COMPILER_IS_GNUCC)
214   set(PLATFORM_CFLAGS "-funsigned-char")
215 endif()
216
217 if(UNIX AND NOT APPLE)
218   find_package(X11 REQUIRED)
219   find_package(GLEW)
220
221   if(NOT GLEW_FOUND)
222     message(FATAL_ERROR "GLEW is required to build blender, install it or disable WITH_SYSTEM_GLEW")
223   endif()
224
225   set(PLATFORM_LINKLIBS
226     ${X11_X11_LIB}
227     ${X11_Xinput_LIB}
228     ${GLEW_LIBRARY}
229     -lpthread
230   )
231 else()
232   # set(GLEW_LIBRARY "")  # unused
233   set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
234 endif()
235
236 string(APPEND CMAKE_C_FLAGS " ${PLATFORM_CFLAGS}")
237 string(APPEND CMAKE_CXX_FLAGS " ${PLATFORM_CFLAGS}")
238
239 # -----------------------------------------------------------------------------
240 # Executables
241
242 # Gears (C)
243 add_executable(gears_c
244     ${CMAKE_SOURCE_DIR}/gears/GHOST_C-Test.c)
245
246 target_link_libraries(gears_c
247     ghost_lib
248     glewmx_lib
249     string_lib
250     ${OPENGL_gl_LIBRARY}
251     ${CMAKE_DL_LIBS}
252     ${PLATFORM_LINKLIBS}
253     )
254
255
256 # Gears (C++)
257 add_executable(gears_cpp
258     ${CMAKE_SOURCE_DIR}/gears/GHOST_Test.cpp)
259
260 target_link_libraries(gears_cpp
261     ghost_lib
262     glewmx_lib
263     string_lib
264     ${OPENGL_gl_LIBRARY}
265     ${CMAKE_DL_LIBS}
266     ${PLATFORM_LINKLIBS}
267     )
268
269
270 # MultiTest (C)
271 add_executable(multitest_c
272   ${CMAKE_SOURCE_DIR}/multitest/Basic.c
273   ${CMAKE_SOURCE_DIR}/multitest/EventToBuf.c
274   ${CMAKE_SOURCE_DIR}/multitest/MultiTest.c
275   ${CMAKE_SOURCE_DIR}/multitest/ScrollBar.c
276   ${CMAKE_SOURCE_DIR}/multitest/Util.c
277   ${CMAKE_SOURCE_DIR}/multitest/WindowData.c
278   ${CMAKE_SOURCE_DIR}/multitest/stubs.c
279 )
280
281
282 target_link_libraries(multitest_c
283   blenfont_lib
284   bli_lib
285   gpu_lib
286   # imbuf_lib
287   ghost_lib
288   bli_lib  # again...
289   glewmx_lib
290   string_lib
291   numaapi_lib
292   guardedalloc_lib
293   wcwidth_lib
294   ${OPENGL_gl_LIBRARY}
295   ${FREETYPE_LIBRARY}
296   ${ZLIB_LIBRARIES}
297   ${CMAKE_DL_LIBS}
298   ${PLATFORM_LINKLIBS}
299 )