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