]> git.cworth.org Git - apitrace-tests/blob - CMakeLists.txt
Make OpenGL/GLUT/GLEW optional.
[apitrace-tests] / CMakeLists.txt
1 cmake_minimum_required (VERSION 2.8)
2
3 project (apitrace-tests)
4
5 find_path (APITRACE_SOURCE_DIR NAMES cmake/FindDirectX.cmake PATHS .. ../.. DOC "apitrace source tree" NO_DEFAULT_PATH)
6 if (NOT EXISTS ${APITRACE_SOURCE_DIR})
7     message (SEND_ERROR "Please specify path to apitrace source tree via APITRACE_SOURCE_DIR")
8 endif ()
9
10 find_program (APITRACE_EXECUTABLE NAMES apitrace PATHS ${APITRACE_SOURCE_DIR} DOC "apitrace executable")
11 if (NOT EXISTS ${APITRACE_EXECUTABLE})
12     message (SEND_ERROR "Please specify path to apitrace executable via APITRACE_EXECUTABLE")
13 endif ()
14
15 include (FindPkgConfig)
16
17 set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
18
19 if (APITRACE_SOURCE_DIR)
20     set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${APITRACE_SOURCE_DIR}/cmake)
21     find_package (DirectX)
22 endif ()
23
24 # Set default built type
25 if (NOT CMAKE_BUILD_TYPE)
26    set (CMAKE_BUILD_TYPE Debug
27        CACHE
28        STRING "Choose the build type, options are: None, Debug, Release, RelWithDebInfo, or MinSizeRel."
29        FORCE)
30 endif (NOT CMAKE_BUILD_TYPE)
31
32 include (CMakeParseArguments)
33
34 find_package (OpenGL)
35 find_package (GLUT)
36 find_package (GLEW)
37
38 if (NOT WIN32)
39         pkg_check_modules (EGL egl)
40         pkg_check_modules (GLESV1 glesv1_cm)
41         pkg_check_modules (GLESV2 glesv2)
42 endif ()
43
44 if (UNIX)
45         link_libraries(m)
46 endif (UNIX)
47
48 if (WIN32)
49         # Nobody likes to include windows.h:
50         # - Microsoft's GL/gl.h header depends on windows.h but doesn't include it;
51         # - GLEW temporarily defines the necessary defines but undefines them later
52         # - certain GLUT distributions don't include it;
53         # - most of our programs are meant to be portable so don't include it.
54         #
55         # We could try to replicate the windows.h definitions required by
56         # GL/gl.h, but the build time savings don't compensate the constant
57         # headaches that brings, so instead we force windows.h to be included
58         # on every file.
59         if (MSVC)
60                 add_definitions (-FIwindows.h)
61         else (MSVC)
62                 add_definitions (--include windows.h)
63         endif (MSVC)
64
65         # Don't define min/max macros
66         add_definitions (-DNOMINMAX)
67
68         # MSVC & MinGW only define & use APIENTRY
69         add_definitions (-DGLAPIENTRY=__stdcall)
70 endif ()
71
72 if (MSVC)
73         # Enable math constants defines
74         add_definitions (-D_USE_MATH_DEFINES)
75
76         # Silence several MSVC pedantic warnings
77         add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
78         add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
79         add_definitions (-wd4244) # conversion' conversion from 'type1' to 'type2', possible loss of data
80 endif ()
81
82 enable_testing()
83
84 add_subdirectory (apps)
85 add_subdirectory (traces)
86