]> git.cworth.org Git - apitrace-tests/blob - CMakeLists.txt
Fix test to correctly use cmake feature to find python executable
[apitrace-tests] / CMakeLists.txt
1 cmake_minimum_required (VERSION 2.8)
2
3
4 # Use clang on MacOSX. gcc doesn't support __thread key, and Apple has
5 # abandoned it for clang.  This must be done before the project is defined.
6 if (APPLE)
7     set (CMAKE_C_COMPILER "clang")
8     set (CMAKE_CXX_COMPILER "clang++")
9 endif ()
10
11
12 project (apitrace-tests)
13
14 find_path (APITRACE_SOURCE_DIR NAMES cmake/FindDirectX.cmake PATHS .. ../.. DOC "apitrace source tree" NO_DEFAULT_PATH)
15 if (NOT EXISTS ${APITRACE_SOURCE_DIR})
16     message (WARNING "Please specify path to apitrace source tree via APITRACE_SOURCE_DIR")
17 endif ()
18
19 find_program (APITRACE_EXECUTABLE NAMES apitrace PATHS ${APITRACE_SOURCE_DIR} DOC "apitrace executable")
20 if (NOT EXISTS ${APITRACE_EXECUTABLE})
21     message (WARNING "Please specify path to apitrace executable via APITRACE_EXECUTABLE")
22 endif ()
23
24 include (FindPythonInterp)
25 include (FindPkgConfig)
26
27 set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
28
29 # Set default built type
30 if (NOT CMAKE_BUILD_TYPE)
31    set (CMAKE_BUILD_TYPE Debug
32        CACHE
33        STRING "Choose the build type, options are: None, Debug, Release, RelWithDebInfo, or MinSizeRel."
34        FORCE)
35 endif (NOT CMAKE_BUILD_TYPE)
36
37 include (CMakeParseArguments)
38
39 find_package (OpenGL)
40 find_package (GLUT)
41 find_package (GLEW)
42
43 if (WIN32)
44     find_package (DirectX)
45 elseif (PKG_CONFIG_FOUND)
46         pkg_check_modules (EGL egl)
47         pkg_check_modules (GLESV1 glesv1_cm)
48         pkg_check_modules (GLESV2 glesv2)
49 endif ()
50
51 # Check for the presence of several python packages, which are needed to build
52 # generated tests.
53 execute_process(
54     COMMAND ${PYTHON_EXECUTABLE} -c "import PIL"
55     OUTPUT_QUIET
56     ERROR_QUIET
57     RESULT_VARIABLE IMPORT_PIL_RESULT)
58 if (IMPORT_PIL_RESULT EQUAL 0)
59     set (PIL_FOUND 1)
60 else ()
61     message (STATUS "python PIL module not found")
62 endif ()
63
64 if (UNIX)
65         link_libraries(m)
66 endif (UNIX)
67
68 if (WIN32)
69         # Nobody likes to include windows.h:
70         # - Microsoft's GL/gl.h header depends on windows.h but doesn't include it;
71         # - GLEW temporarily defines the necessary defines but undefines them later
72         # - certain GLUT distributions don't include it;
73         # - most of our programs are meant to be portable so don't include it.
74         #
75         # We could try to replicate the windows.h definitions required by
76         # GL/gl.h, but the build time savings don't compensate the constant
77         # headaches that brings, so instead we force windows.h to be included
78         # on every file.
79         if (MSVC)
80                 add_definitions (-FIwindows.h)
81         else (MSVC)
82                 add_definitions (--include windows.h)
83         endif (MSVC)
84
85         # Don't define min/max macros
86         add_definitions (-DNOMINMAX)
87
88         # MSVC & MinGW only define & use APIENTRY
89         add_definitions (-DGLAPIENTRY=__stdcall)
90 endif ()
91
92 if (MSVC)
93         # Enable math constants defines
94         add_definitions (-D_USE_MATH_DEFINES)
95
96         # Silence several MSVC pedantic warnings
97         add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
98         add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
99         add_definitions (-wd4244) # conversion' conversion from 'type1' to 'type2', possible loss of data
100 endif ()
101
102 enable_testing()
103
104 add_subdirectory (apps)
105 add_subdirectory (traces)
106
107 # FIXME: The tests in the cli directory are intended to be high-level
108 # tests of the apitrace command-line interface which would ideally be
109 # portable across all platforms. However, these tests all rely on
110 # doing image comparisons and the current implementation of the
111 # "apitrace dump-images" command relies on direct invocation of the
112 # glretrace command.
113 #
114 # Someday, we should have more unified commands for replaying traces,
115 # dumping images, etc. At that point these cli tests should be usable
116 # with all targets so that we can drop the "if (OPENGL_FOUND)"
117 # condition here.
118 if (OPENGL_FOUND AND PIL_FOUND)
119     add_subdirectory (cli)
120     add_subdirectory (trim_stress)
121 endif ()