CMake file to build ghost tests again.
[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 # Libraries
39
40 # ghost
41 include(${CMAKE_SOURCE_DIR}/../CMakeLists.txt)
42 suffix_relpaths(INC_NEW "${INC}" "../")
43 suffix_relpaths(SRC_NEW "${SRC}" "../")
44 include_directories(${INC_NEW})
45 add_library(ghost_lib ${SRC_NEW})
46
47 # string
48 include(${CMAKE_SOURCE_DIR}/../../string/CMakeLists.txt)
49 suffix_relpaths(INC_NEW "${INC}" "../../string/")
50 suffix_relpaths(SRC_NEW "${SRC}" "../../string/")
51 include_directories(${INC_NEW})
52 add_library(string_lib ${SRC_NEW})
53
54 # guardedalloc
55 include(${CMAKE_SOURCE_DIR}/../../guardedalloc/CMakeLists.txt)
56 suffix_relpaths(INC_NEW "${INC}" "../../guardedalloc/")
57 suffix_relpaths(SRC_NEW "${SRC}" "../../guardedalloc/")
58 include_directories(${INC_NEW})
59 add_library(guardedalloc_lib ${SRC_NEW})
60
61
62 find_package(OpenGL REQUIRED)
63
64 include_directories(${CMAKE_SOURCE_DIR}/../)
65 include_directories(${OPENGL_INCLUDE_DIR})
66
67 if(UNIX AND NOT APPLE)
68         find_package(X11 REQUIRED)
69
70         set(PLATFORM_LINKLIBS
71                 ${X11_X11_LIB}
72                 ${X11_Xinput_LIB}
73         )
74 endif()
75
76 # -----------------------------------------------------------------------------
77 # Executables
78
79
80 # Gears (C)
81 add_executable(gears_c
82                 ${CMAKE_SOURCE_DIR}/gears/GHOST_C-Test.c)
83
84 target_link_libraries(gears_c
85                 ghost_lib
86                 string_lib
87                 ${OPENGL_gl_LIBRARY}
88                 ${OPENGL_glu_LIBRARY}
89                 ${PLATFORM_LINKLIBS}
90                 )
91
92
93 # Gears (C++)
94 add_executable(gears_cpp
95                 ${CMAKE_SOURCE_DIR}/gears/GHOST_Test.cpp)
96
97 target_link_libraries(gears_cpp
98                 ghost_lib
99                 string_lib
100                 ${OPENGL_gl_LIBRARY}
101                 ${OPENGL_glu_LIBRARY}
102                 ${PLATFORM_LINKLIBS}
103                 )
104
105
106 # MultiTest (C)
107 add_executable(multitest_c
108         ${CMAKE_SOURCE_DIR}/multitest/Basic.c
109         ${CMAKE_SOURCE_DIR}/multitest/EventToBuf.c
110         ${CMAKE_SOURCE_DIR}/multitest/MultiTest.c
111         ${CMAKE_SOURCE_DIR}/multitest/ScrollBar.c
112         ${CMAKE_SOURCE_DIR}/multitest/Util.c
113         ${CMAKE_SOURCE_DIR}/multitest/WindowData.c
114 )
115
116 target_link_libraries(multitest_c
117                 ghost_lib
118                 string_lib
119                 guardedalloc_lib
120                 ${OPENGL_gl_LIBRARY}
121                 ${OPENGL_glu_LIBRARY}
122                 ${PLATFORM_LINKLIBS}
123                 )