svn merge ^/trunk/blender -r43482:43524
[blender.git] / intern / ghost / test / CMakeLists.txt
1
2 cmake_policy(SET CMP0003 NEW)
3 cmake_policy(SET CMP0005 NEW)
4
5 cmake_minimum_required(VERSION 2.8)
6
7 # -----------------------------------------------------------------------------
8 # Macros
9
10
11 # stub macro, does nothing
12 macro(blender_add_lib
13         name
14         sources
15         includes
16         includes_sys
17         )
18
19 endmacro()
20
21 # suffix relative paths so we can use external cmake files
22 macro(suffix_relpaths
23         new_files files prefix)
24
25         set(${new_files})
26         foreach(_file ${files})
27                 if(IS_ABSOLUTE _file)
28                         list(APPEND ${new_files} ${_file})
29                 else()
30                         list(APPEND ${new_files} "${prefix}${_file}")
31                 endif()
32         endforeach()
33         unset(_file)
34 endmacro()
35
36
37 # -----------------------------------------------------------------------------
38 # Defines
39
40 # set the endian define
41 if(MSVC)
42         # for some reason this fails on msvc
43         add_definitions(-D__LITTLE_ENDIAN__)
44 else()
45         include(TestBigEndian)
46         test_big_endian(_SYSTEM_BIG_ENDIAN)
47         if(_SYSTEM_BIG_ENDIAN)
48                 add_definitions(-D__BIG_ENDIAN__)
49         else()
50                 add_definitions(-D__LITTLE_ENDIAN__)
51         endif()
52         unset(_SYSTEM_BIG_ENDIAN)
53 endif()
54
55
56 # -----------------------------------------------------------------------------
57 # Libraries
58
59 # ghost
60 include(${CMAKE_SOURCE_DIR}/../CMakeLists.txt)
61 suffix_relpaths(INC_NEW "${INC}" "../")
62 suffix_relpaths(SRC_NEW "${SRC}" "../")
63 include_directories(${INC_NEW})
64 add_library(ghost_lib ${SRC_NEW})
65
66 # string
67 include(${CMAKE_SOURCE_DIR}/../../string/CMakeLists.txt)
68 suffix_relpaths(INC_NEW "${INC}" "../../string/")
69 suffix_relpaths(SRC_NEW "${SRC}" "../../string/")
70 include_directories(${INC_NEW})
71 add_library(string_lib ${SRC_NEW})
72
73 # guardedalloc
74 include(${CMAKE_SOURCE_DIR}/../../guardedalloc/CMakeLists.txt)
75 suffix_relpaths(INC_NEW "${INC}" "../../guardedalloc/")
76 suffix_relpaths(SRC_NEW "${SRC}" "../../guardedalloc/")
77 include_directories(${INC_NEW})
78 add_library(guardedalloc_lib ${SRC_NEW})
79
80 # blenfont 
81 include(${CMAKE_SOURCE_DIR}/../../../source/blender/blenfont/CMakeLists.txt)
82 suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/blenfont/")
83 suffix_relpaths(SRC_NEW "${SRC}" "../../../source/blender/blenfont/")
84 include_directories(${INC_NEW})
85 add_library(blenfont_lib ${SRC_NEW})
86
87 # grr, blenfont needs BLI
88 include_directories(
89                 "../../../source/blender/blenlib"
90                 "../../../source/blender/blenloader"
91                 )
92 add_library(bli_lib 
93                 "../../../source/blender/blenlib/intern/fileops.c"
94                 "../../../source/blender/blenlib/intern/rct.c"
95                 "../../../source/blender/blenlib/intern/string.c"
96                 "../../../source/blender/blenlib/intern/string_utf8.c"
97                 "../../../source/blender/blenlib/intern/listbase.c"
98                 "../../../source/blender/blenlib/intern/storage.c"
99                 "../../../source/blender/blenlib/intern/path_util.c"
100                 "../../../source/blender/blenlib/intern/BLI_dynstr.c"
101                 "../../../source/blender/blenlib/intern/BLI_linklist.c"
102                 "../../../source/blender/blenlib/intern/BLI_memarena.c"
103                 )
104
105
106 find_package(OpenGL REQUIRED)
107
108 find_package(Freetype REQUIRED)
109
110 find_package(ZLIB REQUIRED)
111
112 include_directories(${CMAKE_SOURCE_DIR}/../)
113 include_directories(${OPENGL_INCLUDE_DIR})
114 include_directories(${FREETYPE_INCLUDE_DIRS})
115 include_directories(${CMAKE_SOURCE_DIR}/../../../source/blender/blenfont)
116
117 if(UNIX AND NOT APPLE)
118         find_package(X11 REQUIRED)
119
120         set(PLATFORM_LINKLIBS
121                 ${X11_X11_LIB}
122                 ${X11_Xinput_LIB}
123         )
124 endif()
125
126 # -----------------------------------------------------------------------------
127 # Executables
128
129
130 # Gears (C)
131 add_executable(gears_c
132                 ${CMAKE_SOURCE_DIR}/gears/GHOST_C-Test.c)
133
134 target_link_libraries(gears_c
135                 ghost_lib
136                 string_lib
137                 ${OPENGL_gl_LIBRARY}
138                 ${OPENGL_glu_LIBRARY}
139                 ${PLATFORM_LINKLIBS}
140                 )
141
142
143 # Gears (C++)
144 add_executable(gears_cpp
145                 ${CMAKE_SOURCE_DIR}/gears/GHOST_Test.cpp)
146
147 target_link_libraries(gears_cpp
148                 ghost_lib
149                 string_lib
150                 ${OPENGL_gl_LIBRARY}
151                 ${OPENGL_glu_LIBRARY}
152                 ${PLATFORM_LINKLIBS}
153                 )
154
155
156 # MultiTest (C)
157 add_executable(multitest_c
158         ${CMAKE_SOURCE_DIR}/../../../source/blender/editors/datafiles/bfont.ttf.c
159         ${CMAKE_SOURCE_DIR}/multitest/Basic.c
160         ${CMAKE_SOURCE_DIR}/multitest/EventToBuf.c
161         ${CMAKE_SOURCE_DIR}/multitest/MultiTest.c
162         ${CMAKE_SOURCE_DIR}/multitest/ScrollBar.c
163         ${CMAKE_SOURCE_DIR}/multitest/Util.c
164         ${CMAKE_SOURCE_DIR}/multitest/WindowData.c
165 )
166
167 target_link_libraries(multitest_c
168                 blenfont_lib
169                 bli_lib
170                 ghost_lib
171                 string_lib
172                 guardedalloc_lib
173                 ${OPENGL_gl_LIBRARY}
174                 ${OPENGL_glu_LIBRARY}
175                 ${FREETYPE_LIBRARY}
176                 ${ZLIB_LIBRARIES}
177                 ${PLATFORM_LINKLIBS}
178                 )