blob: 5db3128dbc5c1e36be9b9326e9ede73ee6ad8262 [file] [log] [blame]
Jose Fonsecad335cfb2016-04-08 17:37:30 +01001if (MSVC)
Jose Fonseca67f05812017-10-05 15:09:30 +01002 cmake_minimum_required (VERSION 3.7.0)
Jose Fonsecad335cfb2016-04-08 17:37:30 +01003else ()
4 cmake_minimum_required (VERSION 2.8.11)
5endif ()
José Fonseca83178a02010-11-14 00:35:05 +00006
José Fonseca76efdcb2012-10-24 13:43:06 +01007
José Fonsecaf2ad6182014-12-02 11:33:07 +00008if (CMAKE_GENERATOR STREQUAL "Xcode")
9 message (FATAL_ERROR "Xcode generator is not supported. Please build with \"Unix Makefiles\" or \"Ninja\" generators.")
10endif ()
11
José Fonseca9adffcf2014-12-04 22:07:48 +000012# http://www.cmake.org/cmake/help/v3.0/policy/CMP0042.html
13if (POLICY CMP0042)
14 cmake_policy (SET CMP0042 NEW)
15endif()
16
José Fonseca76efdcb2012-10-24 13:43:06 +010017
José Fonseca83178a02010-11-14 00:35:05 +000018project (apitrace)
19
José Fonseca17311e82011-05-08 11:12:08 +010020
21##############################################################################
José Fonsecae68c87f2011-07-28 00:32:54 +010022# Options
José Fonseca5971d6a2011-09-27 14:13:56 +010023
José Fonsecae68c87f2011-07-28 00:32:54 +010024# We use a cached string variable instead of the standard (boolean) OPTION
25# command so that we can default to auto-detecting optional depencies, while
26# still providing a mechanism to force/disable these optional dependencies, as
José Fonsecaab310da2011-07-28 19:07:50 +010027# prescribed in http://www.gentoo.org/proj/en/qa/automagic.xml
Zack Rusina8426522011-07-29 00:07:43 -040028set (ENABLE_GUI "AUTO" CACHE STRING "Enable Qt GUI.")
José Fonsecae68c87f2011-07-28 00:32:54 +010029
Jose Fonseca6a9a4322015-01-24 19:23:57 +000030option (ENABLE_CLI "Enable command Line interface." ON)
José Fonsecaef0c6972012-03-10 16:05:09 +000031
Adrian Negreanu9b9eb3d2018-05-23 17:23:26 +030032option (ENABLE_X11 "Enable X11 support." ON)
33
Jose Fonseca6a9a4322015-01-24 19:23:57 +000034option (ENABLE_EGL "Enable EGL support." ON)
José Fonseca82da2422011-11-17 15:45:10 +000035
Jose Fonseca6a9a4322015-01-24 19:23:57 +000036option (ENABLE_WAFFLE "Enable WAFFLE support." OFF)
José Fonseca7c388482013-11-29 19:32:54 +000037
Jose Fonseca0a1967d2017-11-23 15:05:13 +000038option (ENABLE_SSE42 "Enable SSE 4.2 intrinsics." OFF)
39
Jose Fonseca6a9a4322015-01-24 19:23:57 +000040option (ENABLE_FRAME_POINTER "Disable frame pointer omission" ON)
José Fonseca42945ef2014-09-03 22:32:18 +010041
Jose Fonseca49dfaaf2016-04-16 15:08:43 +010042option (ENABLE_ASAN "Enable Address Sanitizer" OFF)
43
Jose Fonsecacbb48c52017-06-01 14:37:12 +010044option (ENABLE_TESTS "Enable additional tests" OFF)
45
Jose Fonsecae3509be2017-04-11 14:18:47 +010046if (ANDROID)
Jose Fonseca22645462017-06-03 21:59:09 +010047 message (FATAL_ERROR "Android is no longer supported (https://git.io/vH2gW)")
Jose Fonsecae3509be2017-04-11 14:18:47 +010048endif ()
49
Jose Fonseca21e685f2015-03-12 23:27:56 +000050# Proprietary Linux games often ship their own libraries (zlib, libstdc++,
51# etc.) in order to ship a single set of binaries across multiple
52# distributions. Given that apitrace wrapper modules will be loaded into those
53# processes, they must not depend on any shared object that could also be
54# provided by such applications. See also
55# http://lists.freedesktop.org/archives/mesa-dev/2015-March/079121.html
Jose Fonsecab132f862015-03-12 23:53:10 +000056if (NOT ANDROID)
57 option (ENABLE_STATIC_SNAPPY "Statically link against snappy" ON)
Jose Fonsecab132f862015-03-12 23:53:10 +000058 if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
Jose Fonsecabdd03ca2015-04-26 21:43:01 +010059 option (ENABLE_STATIC_LIBGCC "Statically link LD_PRELOAD wrappers against libgcc" ON)
60 option (ENABLE_STATIC_LIBSTDCXX "Statically link LD_PRELOAD wrappers against libstdc++" ON)
61 if (NOT (ENABLE_STATIC_LIBGCC AND
62 ENABLE_STATIC_LIBSTDCXX AND
63 ENABLE_STATIC_SNAPPY))
64 # XXX: Should probably throw a run-time too.
65 message (WARNING
66 "LD_PRELOAD wrappers not statically linked against all "
67 "dependencies, therefore will fail to work with many "
68 "third-party applications built on different Linux "
69 "distributions and that ship their own shared-object "
70 "dependencies."
71 )
72 endif ()
Jose Fonseca0e781b62015-11-19 22:45:15 +000073 option (ENABLE_STATIC_EXE "Statically link executables" OFF)
Jose Fonsecab132f862015-03-12 23:53:10 +000074 endif ()
Jose Fonseca21e685f2015-03-12 23:27:56 +000075endif ()
76
José Fonsecae68c87f2011-07-28 00:32:54 +010077
78##############################################################################
José Fonseca17311e82011-05-08 11:12:08 +010079# Find dependencies
80
Jose Fonsecac7ad25b2017-01-24 11:56:31 +000081include (CheckCXXSourceCompiles)
82
José Fonseca8917aea2013-04-23 10:12:12 +010083# Check for compiler TLS support. We don't use compiler TLS support on Windows
84# because, even if the compiler supports it, Windows XP does not support TLS on
85# DLLs.
86if (NOT WIN32)
José Fonseca7e41fcf2015-03-26 23:03:56 +000087 check_cxx_source_compiles ("__thread int i; int main() { return 0; }" HAVE_COMPILER_TLS)
88 if (NOT HAVE_COMPILER_TLS)
89 message (FATAL_ERROR "C++ compiler does not support __thread keyword.")
José Fonseca8917aea2013-04-23 10:12:12 +010090 endif ()
91endif ()
92
Yann E. MORINafa31e52017-03-04 14:16:58 +010093list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
José Fonsecac56b9ac2014-06-25 13:46:35 +010094include (ConvenienceLibrary)
José Fonseca01e5c852014-10-02 15:48:35 +010095include (InstallPDB)
José Fonsecab460bf32010-11-19 18:57:51 +000096
George Wrighta4a643e2012-02-23 14:54:49 -050097if (ANDROID)
98 set (ENABLE_GUI false)
George Wrighta4a643e2012-02-23 14:54:49 -050099else ()
100 macro (find_host_package)
101 find_package (${ARGN})
102 endmacro()
103endif ()
104
Robert Tarasov6ccf5bb2020-01-10 12:31:25 -0800105if (CMAKE_VERSION VERSION_LESS 3.12)
106 find_host_package (PythonInterp 3 REQUIRED)
107 if (NOT PYTHON_VERSION_MAJOR EQUAL 3)
108 message (FATAL_ERROR "Python 3.x required and requested, but Python ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} found.")
109 endif ()
110 set (Python3_EXECUTABLE "${PYTHON_EXECUTABLE}")
111else ()
112 find_host_package (Python3 REQUIRED)
Jose Fonsecae91fb542019-04-14 22:22:24 +0900113endif ()
José Fonseca994fa9a2014-06-03 16:03:45 +0100114
José Fonsecae86846f2012-03-10 16:02:49 +0000115find_package (Threads)
116
Jose Fonseca0e781b62015-11-19 22:45:15 +0000117if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ENABLE_STATIC_EXE)
José Fonseca39072d22014-11-11 22:22:57 +0000118 find_package (procps)
Jose Fonsecacc41a482015-03-13 10:35:27 +0000119 if (PROCPS_FOUND)
José Fonseca39072d22014-11-11 22:22:57 +0000120 add_definitions (-DHAVE_READPROC_H)
121 endif ()
122endif ()
123
José Fonsecae68c87f2011-07-28 00:32:54 +0100124if (ENABLE_GUI)
125 if (NOT (ENABLE_GUI STREQUAL "AUTO"))
126 set (REQUIRE_GUI REQUIRED)
127 endif ()
José Fonseca3f4cd302015-01-14 12:02:06 +0000128 if (POLICY CMP0020)
129 cmake_policy (SET CMP0020 NEW)
130 endif()
131 find_package (Qt5Widgets ${REQUIRE_GUI})
Jose Fonseca3b7e9c02016-03-21 14:20:55 +0000132 find_package (Qt5Network ${REQUIRE_GUI})
José Fonsecae68c87f2011-07-28 00:32:54 +0100133endif ()
José Fonseca83178a02010-11-14 00:35:05 +0000134
Jose Fonseca38d9d4d2015-08-10 14:13:05 +0100135if (MSVC)
Jose Fonseca67f05812017-10-05 15:09:30 +0100136 if (${MSVC_VERSION} LESS 1910)
137 message (FATAL_ERROR "Visual Studio 2017 or later required")
Jose Fonseca38d9d4d2015-08-10 14:13:05 +0100138 endif ()
Jose Fonseca38d9d4d2015-08-10 14:13:05 +0100139endif ()
140
José Fonsecae8fec0f2011-06-06 21:06:29 +0100141if (WIN32)
Jose Fonseca7e3f22a2016-04-10 15:56:46 +0100142 # http://msdn.microsoft.com/en-us/library/aa383745.aspx
Jose Fonseca16b76a22017-03-20 12:50:52 +0000143 # Windows 8
144 add_definitions (-D_WIN32_WINNT=0x0602 -DWINVER=0x0602)
Jose Fonseca7e3f22a2016-04-10 15:56:46 +0100145
José Fonsecae8fec0f2011-06-06 21:06:29 +0100146 find_package (DirectX)
Jose Fonseca4713c3b2015-08-12 11:06:34 +0100147
Jose Fonsecaa0870ec2018-12-05 10:45:00 +0000148 if (MSVC)
149 # Log Windows SDK version
150 unset (WINDOWS_SDK_VERSION)
151 if (DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
152 set (WINDOWS_SDK_VERSION ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})
153 elseif (DEFINED ENV{WindowsSDKLibVersion})
154 string (REGEX REPLACE "\\\\$" "" WINDOWS_SDK_VERSION "$ENV{WindowsSDKLibVersion}")
155 endif ()
156 if (DEFINED WINDOWS_SDK_VERSION)
157 message (STATUS "Using Windows SDK ${WINDOWS_SDK_VERSION}")
158 endif ()
Jose Fonseca9b91d132017-10-13 13:35:41 +0100159
Jose Fonsecaa0870ec2018-12-05 10:45:00 +0000160 # https://developer.microsoft.com/en-us/windows/projects/campaigns/windows-dev-essentials-how-windows-10-sdks-ship
161 set (REQUIRED_WINDOWS_SDK 10.0.14393.0)
162 if (NOT DirectX_D3D11_4_INCLUDE_FOUND)
163 if (CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
164 message (SEND_ERROR
165 "Windows ${REQUIRED_WINDOWS_SDK} SDK required, but ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} found.\n"
166 "Install it then select it by configuring with -DCMAKE_SYSTEM_VERSION=${REQUIRED_WINDOWS_SDK} option.")
167
168 else ()
169 message (SEND_ERROR
170 "Windows ${REQUIRED_WINDOWS_SDK} SDK required.\n"
171 "Install it then select it by invoking `vcvarsall.bat <arch> ${REQUIRED_WINDOWS_SDK}`"
172 )
173 endif ()
Jose Fonseca9b91d132017-10-13 13:35:41 +0100174 endif ()
Jose Fonseca4713c3b2015-08-12 11:06:34 +0100175 endif ()
176
José Fonsecae319ab42012-03-10 15:37:43 +0000177 set (ENABLE_EGL false)
José Fonsecaf4608e32011-10-10 20:17:35 +0100178elseif (APPLE)
José Fonsecae319ab42012-03-10 15:37:43 +0000179 set (ENABLE_EGL false)
Jose Fonsecafa104c72018-12-06 12:13:42 +0000180 add_definitions (-DGL_SILENCE_DEPRECATION)
Adrian Negreanu9b9eb3d2018-05-23 17:23:26 +0300181elseif (ENABLE_X11)
Arnaud Vrac6ac796e2011-12-19 02:44:24 +0100182 find_package (X11)
José Fonsecaa62e12f2011-10-07 15:33:48 +0100183
Arnaud Vrac6ac796e2011-12-19 02:44:24 +0100184 if (X11_FOUND)
185 include_directories (${X11_INCLUDE_DIR})
186 add_definitions (-DHAVE_X11)
José Fonseca8d1d5322012-10-28 10:48:22 +0000187 else ()
188 # Print a clear message when X11 is not found
189 include (FindPackageMessage)
190 find_package_message (X11 "Could not find X11" "")
Arnaud Vrac6ac796e2011-12-19 02:44:24 +0100191 endif ()
José Fonsecaa62e12f2011-10-07 15:33:48 +0100192endif ()
José Fonsecae8fec0f2011-06-06 21:06:29 +0100193
Jose Fonsecab68e16a2015-09-14 18:32:16 +0100194if (ENABLE_EGL AND ENABLE_WAFFLE)
195 # Use Waffle for eglretrace
Jose Fonseca6507ac52019-11-26 13:13:50 +0000196 find_package (Waffle REQUIRED)
José Fonseca7c388482013-11-29 19:32:54 +0000197endif ()
198
Robert Tarasov6ccf5bb2020-01-10 12:31:25 -0800199if (ENABLE_EGL AND NOT ENABLE_X11)
200 add_definitions (-DEGL_NO_X11)
201endif ()
202
José Fonseca17311e82011-05-08 11:12:08 +0100203
204##############################################################################
205# Set global build options
206
207include (CheckCXXCompilerFlag)
José Fonseca1c6c2bc2014-02-25 15:28:03 +0000208include (CheckIncludeFileCXX)
José Fonseca17311e82011-05-08 11:12:08 +0100209
José Fonseca7ed2ef32015-01-29 15:51:22 +0000210macro (add_compiler_flags)
Jose Fonseca6d437fb2015-03-27 10:53:06 +0000211 string (REPLACE ";" " " _FLAGS "${ARGV}")
212 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAGS}")
213 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_FLAGS}")
José Fonseca7ed2ef32015-01-29 15:51:22 +0000214endmacro ()
215
José Fonsecacb084e12014-09-11 18:13:58 +0100216macro (add_linker_flags)
Jose Fonseca6d437fb2015-03-27 10:53:06 +0000217 string (REPLACE ";" " " _FLAGS "${ARGV}")
218 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_FLAGS}")
219 set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${_FLAGS}")
220 set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${_FLAGS}")
José Fonsecacb084e12014-09-11 18:13:58 +0100221endmacro ()
222
Jose Fonseca4ba12ac2015-05-18 15:17:05 +0100223add_definitions (
224 -D__STDC_LIMIT_MACROS
Jose Fonseca27d80732015-08-13 12:21:46 +0100225 -D__STDC_FORMAT_MACROS
Jose Fonseca4ba12ac2015-05-18 15:17:05 +0100226)
227
José Fonseca5aff9b02010-11-22 13:00:54 +0000228if (WIN32)
José Fonseca23691292011-04-22 10:40:25 +0100229else (WIN32)
230 CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" CXX_COMPILER_FLAG_VISIBILITY)
231 if (CXX_COMPILER_FLAG_VISIBILITY)
Jose Fonseca6d437fb2015-03-27 10:53:06 +0000232 add_compiler_flags (-fvisibility=hidden)
José Fonseca5b6fb752012-04-14 14:56:45 +0100233 endif ()
234endif ()
José Fonseca83178a02010-11-14 00:35:05 +0000235
236if (MSVC)
Nigel Stewart673d32a2013-07-19 09:32:47 -0500237 # No RTTI required
José Fonsecaaec30832014-05-13 17:29:40 +0100238 string (REGEX REPLACE "/GR *" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
239 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
Nigel Stewart673d32a2013-07-19 09:32:47 -0500240
José Fonsecac354ea02015-03-20 07:01:16 +0000241 # Disable C++ exceptions
242 add_definitions (-D_HAS_EXCEPTIONS=0)
243 string (REGEX REPLACE "/EHsc *" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
244 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c-")
245
José Fonseca03f63612010-12-04 10:59:52 +0000246 # Enable math constants defines
247 add_definitions (-D_USE_MATH_DEFINES)
José Fonseca83178a02010-11-14 00:35:05 +0000248
José Fonseca2af485a2011-04-15 20:49:21 +0100249 # No min/max macros
250 add_definitions (-DNOMINMAX)
251
José Fonseca03f63612010-12-04 10:59:52 +0000252 # Adjust warnings
253 add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
254 add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
José Fonseca7ed2ef32015-01-29 15:51:22 +0000255 add_compiler_flags (-W3)
José Fonsecaaf7fc5c2012-04-23 12:19:53 +0100256 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
José Fonseca7ed2ef32015-01-29 15:51:22 +0000257 add_compiler_flags (-wd4018) # signed/unsigned mismatch
258 add_compiler_flags (-wd4063) # not a valid value for switch of enum
259 add_compiler_flags (-wd4100) # unreferenced formal parameter
260 add_compiler_flags (-wd4127) # conditional expression is constant
261 add_compiler_flags (-wd4244) # conversion from 'type1' to 'type2', possible loss of data
262 add_compiler_flags (-wd4267) # conversion from 'type1' to 'type2', possible loss of data
263 add_compiler_flags (-wd4505) # unreferenced local function has been removed
264 add_compiler_flags (-wd4512) # assignment operator could not be generated
Jose Fonseca67f05812017-10-05 15:09:30 +0100265 add_compiler_flags (-wd4577) # 'noexcept' used with no exception handling mode specified
José Fonseca7ed2ef32015-01-29 15:51:22 +0000266 add_compiler_flags (-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
José Fonseca03f63612010-12-04 10:59:52 +0000267
268 # Use static runtime
269 # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
270 foreach (flag_var
271 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
272 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
273 )
274 if (${flag_var} MATCHES "/MD")
275 string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
José Fonseca5b6fb752012-04-14 14:56:45 +0100276 endif ()
José Fonseca03f63612010-12-04 10:59:52 +0000277 endforeach (flag_var)
José Fonseca1791f622010-11-15 16:09:40 +0000278else ()
Jose Fonseca02c5d502015-03-08 20:51:11 +0000279 # Enable and require C++11
280 #
281 # We must use `-std=gnu++11` instead `-std=c++11` as the latter defines
Jose Fonsecaeabf02d2015-03-08 21:57:30 +0000282 # __STRICT_ANSI__ which prevents _isnan from being declared with MinGW.
Jose Fonseca02c5d502015-03-08 20:51:11 +0000283 #
284 # See also:
285 # - https://gcc.gnu.org/projects/cxx0x.html
286 # - http://clang.llvm.org/cxx_status.html
287 check_cxx_compiler_flag ("-std=gnu++11" CXX_COMPILER_FLAG_STD_GNUXX11)
José Fonseca1a1e3262015-03-12 14:20:19 +0000288 if (CXX_COMPILER_FLAG_STD_GNUXX11)
Jose Fonseca02c5d502015-03-08 20:51:11 +0000289 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
José Fonseca47de2eb2015-03-12 14:15:30 +0000290 else ()
291 message (FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} compiler does not support C++11")
Jose Fonseca02c5d502015-03-08 20:51:11 +0000292 endif ()
293
Jose Fonseca5de68562015-08-13 19:33:08 +0100294 # We require at least GCC 4.9 for decent C++11 support
295 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
296 CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
Jose Fonseca2940c642016-05-09 17:24:25 -0700297 message (FATAL_ERROR "GCC 4.9 or later required -- https://github.com/apitrace/apitrace/wiki/GCC")
Jose Fonseca5de68562015-08-13 19:33:08 +0100298 endif ()
299
José Fonseca03f63612010-12-04 10:59:52 +0000300 # Adjust warnings
José Fonseca7ed2ef32015-01-29 15:51:22 +0000301 add_compiler_flags (-Wall)
José Fonseca03f63612010-12-04 10:59:52 +0000302 # XXX: it's safer to use ssize_t everywhere instead of disabling warning
José Fonseca7ed2ef32015-01-29 15:51:22 +0000303 add_compiler_flags (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
Imre Deak33b9a0f2012-04-20 16:34:31 +0300304
Jose Fonseca8e5e3792015-03-15 07:49:36 +0000305 # Disable strict aliasing assumptions. We generate a lot of C++ code, and
306 # it's not always easy to guarantee or spot when strict aliasing
307 # assumptions are violated. Above all, the benefit is not worth the risk.
Jose Fonseca6d437fb2015-03-27 10:53:06 +0000308 add_compiler_flags (-fno-strict-aliasing)
Jose Fonseca8e5e3792015-03-15 07:49:36 +0000309
Nigel Stewart673d32a2013-07-19 09:32:47 -0500310 # No RTTI required
José Fonseca5cebfd82015-03-20 07:00:53 +0000311 # XXX: there's a dynamic_cast in Android
312 if (NOT ANDROID)
313 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
314 endif ()
Nigel Stewart673d32a2013-07-19 09:32:47 -0500315
José Fonsecac354ea02015-03-20 07:01:16 +0000316 # Disable C++ exceptions
Jose Fonseca2d70fdf2015-12-03 10:50:55 +0000317 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
José Fonsecac354ea02015-03-20 07:01:16 +0000318
Jose Fonseca49dfaaf2016-04-16 15:08:43 +0100319 # Enable Address Sanitizer
320 if (ENABLE_ASAN)
321 add_compiler_flags (-fsanitize=address)
322 add_linker_flags (-fsanitize=address)
José Fonseca4c3da7c2014-09-12 08:36:06 +0100323 endif ()
324
José Fonseca7ddb0702014-08-29 18:24:19 +0100325 # Enable SSE2 intrinsics on x86
Jose Fonsecad94ea962015-10-27 11:42:46 +0000326 if (MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4)
Jose Fonseca16c8fc62016-02-01 14:52:32 +0000327 add_compiler_flags (-msse2 -mfpmath=sse)
José Fonsecad591f962015-01-29 16:01:53 +0000328
Jose Fonseca16c8fc62016-02-01 14:52:32 +0000329 # And tell GCC to assume 4 bytes alignment, many Linux/Windows
330 # applications only guarantee that, but not on systems where ABI
331 # clearly states otherwise.
332 #
333 # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38496
334 if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
335 add_compiler_flags (-mstackrealign)
336 else ()
337 add_compiler_flags (-mincoming-stack-boundary=2)
338 endif ()
José Fonseca7ddb0702014-08-29 18:24:19 +0100339 endif ()
340
Jose Fonseca0a1967d2017-11-23 15:05:13 +0000341 if (ENABLE_SSE42)
342 if (MINGW)
343 add_compiler_flags (-msse4.2)
344 endif ()
345 add_definitions (-DENABLE_SSE42)
346 endif ()
347
José Fonseca43894cb2012-10-19 18:43:46 +0100348 # Be nice to Eclipse
José Fonseca7ed2ef32015-01-29 15:51:22 +0000349 add_compiler_flags (-fmessage-length=0)
José Fonseca1791f622010-11-15 16:09:40 +0000350endif ()
José Fonseca83178a02010-11-14 00:35:05 +0000351
Jose Fonsecac7ad25b2017-01-24 11:56:31 +0000352if (APPLE)
353 check_cxx_source_compiles ("#include <AvailabilityMacros.h>\n#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200\nint main() { return 0; }\n#endif" HAVE_MACOSX_10_12_SDK)
354 if (NOT HAVE_MACOSX_10_12_SDK)
355 message (FATAL_ERROR "macOS 10.12 SDK or newer (i.e. Xcode 8.0 or newer) required")
356 endif ()
Jose Fonsecad172b022015-06-07 21:02:58 +0100357endif ()
358
José Fonsecaaa5681e2011-10-11 19:32:30 +0100359if (MINGW)
360 # Avoid depending on MinGW runtime DLLs
Jose Fonseca6d437fb2015-03-27 10:53:06 +0000361 add_linker_flags (-static-libgcc -static-libstdc++)
Jose Fonseca0e781b62015-11-19 22:45:15 +0000362elseif (ENABLE_STATIC_EXE)
363 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
José Fonsecaaa5681e2011-10-11 19:32:30 +0100364endif ()
365
José Fonseca42945ef2014-09-03 22:32:18 +0100366if (ENABLE_FRAME_POINTER)
367 # disable frame pointer omission
368 if (MSVC)
José Fonseca7ed2ef32015-01-29 15:51:22 +0000369 add_compiler_flags (/Oy-)
José Fonseca42945ef2014-09-03 22:32:18 +0100370 else ()
José Fonseca7ed2ef32015-01-29 15:51:22 +0000371 add_compiler_flags (-fno-omit-frame-pointer)
José Fonseca42945ef2014-09-03 22:32:18 +0100372 endif ()
373endif ()
374
José Fonsecae632a702014-09-11 18:14:32 +0100375if (WIN32)
Jose Fonseca42526632017-10-05 16:22:39 +0100376 # Increase number of sections in obj files
377 if (MSVC)
378 add_compiler_flags (-bigobj)
379 else ()
380 add_compiler_flags (-Wa,-mbig-obj)
381 endif ()
382
Jose Fonseca849af142016-12-09 14:25:00 +0000383 # Enable Data Execution Prevention and Address Space Layout Randomization
José Fonsecae632a702014-09-11 18:14:32 +0100384 if (MSVC)
Jose Fonseca6d437fb2015-03-27 10:53:06 +0000385 add_linker_flags (/NXCOMPAT /DYNAMICBASE)
José Fonsecae632a702014-09-11 18:14:32 +0100386 else ()
Jose Fonseca6d437fb2015-03-27 10:53:06 +0000387 add_linker_flags (-Wl,--nxcompat -Wl,--dynamicbase)
José Fonsecae632a702014-09-11 18:14:32 +0100388 endif ()
Jose Fonseca849af142016-12-09 14:25:00 +0000389
390 # Use more than 2GB virtual memory address space for 32-bits processes
391 # where available (3GB on 32-bits Windows with 4GT, 4GB on 64-bits Windows)
392 if (CMAKE_SIZEOF_VOID_P EQUAL 4)
393 if (MSVC)
394 add_linker_flags (/LARGEADDRESSAWARE)
395 else ()
396 add_linker_flags (-Wl,--large-address-aware)
397 endif ()
398 endif ()
José Fonsecae632a702014-09-11 18:14:32 +0100399endif ()
400
Jose Fonseca94c0b7c2015-03-12 21:13:05 +0000401if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
José Fonseca6c383112013-05-04 09:33:41 +0100402 # For RTLD_DEFAULT and RTLD_NEXT
403 add_definitions (-D_GNU_SOURCE)
404endif ()
405
Jose Fonsecaf67e3c12015-05-01 17:42:03 +0100406include (TestBigEndian)
407test_big_endian (HAVE_BIGENDIAN)
408if (HAVE_BIGENDIAN)
409 add_definitions (-DHAVE_BIGENDIAN)
410endif ()
411
Jose Fonseca50d5e202016-03-26 13:01:21 +0000412# Force certain components to always be built as release
413macro (force_release_build)
414 if (MSVC)
415 # TODO: Needs special care due since runtime must match
416 else ()
417 set (CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_RELWITHDEBINFO})
418 set (CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
419 endif ()
420endmacro ()
421
José Fonseca44721292011-04-21 08:24:57 +0100422# Put all executables into the same top level build directory, regardless of
423# which subdirectory they are declared
José Fonseca5d4e2a12011-07-01 11:58:16 +0100424set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
José Fonseca44721292011-04-21 08:24:57 +0100425
Jose Fonsecae11395e2016-01-27 12:12:32 +0000426enable_testing ()
427if (CMAKE_CROSSCOMPILING)
428 add_custom_target (check)
429elseif (DEFINED CMAKE_BUILD_TYPE)
430 # Single configuration
431 add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
432else ()
433 # Multiple configuration
434 add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} -C "$<CONFIG>" --output-on-failure)
435endif ()
436
José Fonseca17311e82011-05-08 11:12:08 +0100437
438##############################################################################
José Fonseca27440922011-11-01 08:27:12 +0000439# Installation directories
440
Jose Fonseca94c0b7c2015-03-12 21:13:05 +0000441if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
Michal Suchanek96851e02012-05-07 16:07:16 +0200442 # Debian multiarch support
443 execute_process(COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
444 OUTPUT_VARIABLE ARCH_SUBDIR
445 ERROR_QUIET
446 OUTPUT_STRIP_TRAILING_WHITESPACE
447 )
448endif()
449
José Fonseca27440922011-11-01 08:27:12 +0000450if (WIN32 OR APPLE)
451 # On Windows/MacOSX, applications are usually installed on a directory of
452 # their own
Jose Fonseca686fc5a2016-04-13 10:35:12 +0100453 set (DOC_DEFAULT_INSTALL_DIR doc)
José Fonsecaab6ded72012-03-02 10:31:19 +0000454 set (LIB_INSTALL_DIR lib)
Michal Suchanek96851e02012-05-07 16:07:16 +0200455 set (LIB_ARCH_INSTALL_DIR lib)
José Fonseca27440922011-11-01 08:27:12 +0000456else ()
Jose Fonseca686fc5a2016-04-13 10:35:12 +0100457 set (DOC_DEFAULT_INSTALL_DIR share/doc/${CMAKE_PROJECT_NAME})
Sandro Mani41245852013-11-20 21:27:29 +0100458 set (LIB_INSTALL_DIR lib${LIB_SUFFIX}/${CMAKE_PROJECT_NAME})
Michal Suchanek96851e02012-05-07 16:07:16 +0200459 if (ARCH_SUBDIR)
460 set (LIB_ARCH_INSTALL_DIR lib/${ARCH_SUBDIR}/${CMAKE_PROJECT_NAME})
461 else ()
Sandro Mani41245852013-11-20 21:27:29 +0100462 set (LIB_ARCH_INSTALL_DIR lib${LIB_SUFFIX}/${CMAKE_PROJECT_NAME})
Michal Suchanek96851e02012-05-07 16:07:16 +0200463 endif ()
José Fonseca27440922011-11-01 08:27:12 +0000464endif ()
465
Jose Fonseca686fc5a2016-04-13 10:35:12 +0100466# Allow customization of the doc installation dir (Slackware uses different
467# location)
468set (DOC_INSTALL_DIR "${DOC_DEFAULT_INSTALL_DIR}" CACHE STRING "Documentation installation directory")
469
José Fonseca7c3ea252012-05-08 15:02:51 +0100470set (SCRIPTS_INSTALL_DIR ${LIB_INSTALL_DIR}/scripts)
Michal Suchanek96851e02012-05-07 16:07:16 +0200471set (WRAPPER_INSTALL_DIR ${LIB_ARCH_INSTALL_DIR}/wrappers)
Carl Worth26cca9b2011-11-04 15:42:02 -0700472
José Fonseca27440922011-11-01 08:27:12 +0000473
474##############################################################################
José Fonseca8fae49d2012-12-11 07:22:16 +0000475# Bundled dependencies
476#
Jose Fonsecab132f862015-03-12 23:53:10 +0000477# We prefer to bundle and statically link against many dependencies:
José Fonseca8fae49d2012-12-11 07:22:16 +0000478# - on Windows to make it easy to deploy the wrappers DLLs
479# - on unices to prevent symbol collisions when tracing applications that link
480# against other versions of these libraries
481
Jose Fonseca71a85c92016-02-25 21:37:42 +0000482include_directories (${CMAKE_CURRENT_SOURCE_DIR}/compat)
483
Jose Fonsecab132f862015-03-12 23:53:10 +0000484if (NOT ENABLE_STATIC_SNAPPY)
485 find_package (SNAPPY)
486endif ()
487if (ENABLE_STATIC_SNAPPY OR NOT SNAPPY_FOUND)
Jose Fonsecae1a50a22015-09-01 23:45:43 +0100488 message (STATUS "Using bundled SNAPPY")
Jose Fonsecab132f862015-03-12 23:53:10 +0000489 set (SNAPPY_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/snappy)
490 set (SNAPPY_LIBRARIES snappy_bundled)
491 add_subdirectory (thirdparty/snappy)
492endif ()
José Fonseca8fae49d2012-12-11 07:22:16 +0000493include_directories (${SNAPPY_INCLUDE_DIRS})
494
Jose Fonsecada5c63c2018-02-14 11:36:14 +0000495include_directories (${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/brotli/c/include)
Jose Fonseca1d9af7a2016-03-23 12:40:09 +0000496add_subdirectory (thirdparty/brotli)
497
Jose Fonseca0e781b62015-11-19 22:45:15 +0000498if (NOT WIN32 AND NOT ENABLE_STATIC_EXE)
Jose Fonseca33d5be12015-03-15 19:09:13 +0000499 # zlib 1.2.4-1.2.5 made it impossible to read the last block of incomplete
500 # gzip traces (e.g., apitrace-tests/traces/zlib-no-eof.trace).
501 find_package (ZLIB 1.2.6)
Jose Fonsecab132f862015-03-12 23:53:10 +0000502endif ()
Jose Fonseca63e5f392015-03-15 10:33:32 +0000503if (NOT ZLIB_FOUND)
Jose Fonsecae1a50a22015-09-01 23:45:43 +0100504 message (STATUS "Using bundled ZLIB")
Jose Fonsecab132f862015-03-12 23:53:10 +0000505 set (ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zlib)
506 set (ZLIB_LIBRARIES z_bundled)
507 add_subdirectory (thirdparty/zlib)
508endif ()
509include_directories (${ZLIB_INCLUDE_DIRS})
José Fonseca8fae49d2012-12-11 07:22:16 +0000510
Jose Fonseca40f5ce12015-03-15 22:35:22 +0000511# FindPNG.cmake will search ZLIB internally (without requiring any particular
512# version), adding its include dirs and libraries, and overwriting ZLIB_FOUND.
513# So if the system's ZLIB was did not meet the our requirements, then there's
514# no safe way to use the system's PNG library.
Jose Fonsecad83ab102017-01-12 23:41:37 +0000515if (NOT WIN32 AND NOT APPLE AND NOT ENABLE_STATIC_EXE AND ZLIB_FOUND)
Jose Fonsecab132f862015-03-12 23:53:10 +0000516 find_package (PNG)
517endif ()
Jose Fonseca63e5f392015-03-15 10:33:32 +0000518if (NOT PNG_FOUND)
Jose Fonsecae1a50a22015-09-01 23:45:43 +0100519 message (STATUS "Using bundled PNG")
Jose Fonsecab132f862015-03-12 23:53:10 +0000520 set (PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libpng)
521 set (PNG_DEFINITIONS "")
522 set (PNG_LIBRARIES png_bundled)
523 add_subdirectory (thirdparty/libpng)
524endif ()
José Fonseca8fae49d2012-12-11 07:22:16 +0000525
526if (MSVC)
527 add_subdirectory (thirdparty/getopt)
528 include_directories (${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/getopt)
529 set (GETOPT_LIBRARIES getopt_bundled)
530endif ()
531
532if (WIN32)
José Fonseca3b74a952015-02-09 11:52:29 +0000533 add_subdirectory (thirdparty/dxerr)
José Fonsecad7c738e2013-03-06 11:46:41 +0000534 add_subdirectory (thirdparty/directxtex)
José Fonsecae5b9a912014-09-25 21:28:59 +0100535 add_subdirectory (thirdparty/devcon)
Jose Fonseca6e1b4f82016-09-03 10:06:54 +0100536 add_subdirectory (thirdparty/mhook)
José Fonseca8fae49d2012-12-11 07:22:16 +0000537endif ()
538
José Fonseca620060f2015-02-23 16:49:21 +0000539add_subdirectory (thirdparty/crc32c)
540
Alexander Monakov9c8be7c2013-05-19 00:23:58 +0400541if (CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
542 add_subdirectory (thirdparty/libbacktrace)
543 include_directories (${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libbacktrace)
i.Dark_Templar1294f692019-04-30 22:19:08 +0300544 include_directories (${CMAKE_CURRENT_BINARY_DIR}/thirdparty/libbacktrace)
Harald Fernengel35d27502015-06-22 15:19:20 +0100545 set (LIBBACKTRACE_LIBRARIES ${CMAKE_DL_LIBS} backtrace)
José Fonsecad6c02fd2013-09-20 10:50:45 +0100546 add_definitions (-DHAVE_BACKTRACE=1)
Alexander Monakov9c8be7c2013-05-19 00:23:58 +0400547endif ()
548
Meng Mengmeng093cf112014-01-22 12:49:20 +0000549add_subdirectory (thirdparty/md5)
550set (MD5_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/md5)
551set (MD5_LIBRARIES md5_bundled)
552
José Fonseca8fae49d2012-12-11 07:22:16 +0000553# We use bundled headers for all Khronos APIs, to guarantee support for both
554# OpenGL and OpenGL ES at build time, because the OpenGL and OpenGL ES 1 APIs
555# are so intertwined that conditional compilation extremely difficult. This
556# also avoids missing/inconsistent declarations in system headers.
557include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/khronos)
558
Jose Fonseca6ab8d302015-05-22 00:05:11 +0100559# We use non-standard C++ flags, so we can't just use GTest's CMakeLists.txt
Jose Fonseca44172422018-02-14 13:20:56 +0000560add_definitions (-DGTEST_HAS_TR1_TUPLE=0)
David Aguilar85cf7c82018-04-18 13:34:08 -0700561include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gtest/include)
Jose Fonseca6ab8d302015-05-22 00:05:11 +0100562add_library (gtest ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gtest/src/gtest-all.cc)
563set_property (TARGET gtest APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gtest)
564target_link_libraries (gtest ${CMAKE_THREAD_LIBS_INIT})
565
Jose Fonseca1ee5efd2015-08-14 10:02:18 +0100566# Convenience macro for adding unit tests
567macro (add_gtest)
568 add_executable (${ARGV})
569 target_link_libraries (${ARGV0} gtest)
570 add_dependencies (check ${ARGV0})
571 add_test (NAME ${ARGV0} COMMAND $<TARGET_FILE:${ARGV0}>)
572endmacro ()
573
José Fonseca8fae49d2012-12-11 07:22:16 +0000574
575##############################################################################
José Fonseca17311e82011-05-08 11:12:08 +0100576# Common libraries / utilities
José Fonseca83178a02010-11-14 00:35:05 +0000577
José Fonsecaa8c164c2011-09-21 07:46:50 +0100578include_directories (
Jose Fonseca5e9a2b12016-05-05 15:20:03 +0100579 ${CMAKE_CURRENT_SOURCE_DIR}/lib/trace
Jose Fonsecaefc5d912016-05-05 13:55:29 +0100580 ${CMAKE_CURRENT_SOURCE_DIR}/lib/os
Jose Fonseca71a85c92016-02-25 21:37:42 +0000581 ${CMAKE_CURRENT_SOURCE_DIR}/compat
José Fonsecaa8c164c2011-09-21 07:46:50 +0100582)
José Fonseca5d4e2a12011-07-01 11:58:16 +0100583
Jose Fonseca79b8e8d2016-05-05 10:51:19 +0100584add_subdirectory (lib)
José Fonseca4f242f42012-04-14 18:13:25 +0100585add_subdirectory (dispatch)
José Fonseca3b186822012-11-27 15:25:21 +0000586add_subdirectory (helpers)
José Fonseca452d3252012-04-14 15:55:40 +0100587add_subdirectory (wrappers)
José Fonseca9d27a542012-04-14 17:22:57 +0100588add_subdirectory (retrace)
José Fonseca7e329022010-11-19 17:05:18 +0000589
José Fonseca8e3c2c02012-01-23 00:30:35 +0000590
Carl Worth6d543af2011-10-19 18:02:33 -0700591##############################################################################
592# CLI
593
José Fonsecaef0c6972012-03-10 16:05:09 +0000594if (ENABLE_CLI)
José Fonsecabd4937e2012-12-04 13:23:03 +0000595 if (WIN32)
596 add_subdirectory (inject)
597 endif ()
José Fonseca17a45412012-11-28 09:44:01 +0000598 add_subdirectory (cli)
Jose Fonsecac4ff1272016-01-27 08:25:20 +0000599 add_subdirectory (scripts)
José Fonsecaef0c6972012-03-10 16:05:09 +0000600endif ()
José Fonseca17311e82011-05-08 11:12:08 +0100601
Carl Worth32420d22011-11-04 15:45:09 -0700602
603##############################################################################
José Fonseca17311e82011-05-08 11:12:08 +0100604# GUI
605
Jose Fonseca3b7e9c02016-03-21 14:20:55 +0000606if (ENABLE_GUI AND Qt5Widgets_FOUND AND Qt5Network_FOUND)
Jose Fonsecacbb48c52017-06-01 14:37:12 +0100607 add_subdirectory (gui)
608endif ()
609
610
611##############################################################################
612# Additional tests
613
614if (ENABLE_TESTS)
615 if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt")
616 message (EMIT_ERROR
617 "tests/CMakeLists.txt is missing, please do\n"
618 " git clone https://github.com/apitrace/apitrace-tests tests")
619 else ()
620 add_subdirectory (tests)
621 endif ()
José Fonsecae68c87f2011-07-28 00:32:54 +0100622endif ()
José Fonseca17311e82011-05-08 11:12:08 +0100623
624
625##############################################################################
626# Packaging
627
José Fonseca05ba4192011-09-17 21:18:57 +0100628install (
629 FILES
José Fonseca21278192015-01-20 14:27:04 +0000630 README.markdown
José Fonsecac345e0d2015-01-20 14:22:54 +0000631 docs/BUGS.markdown
632 docs/NEWS.markdown
José Fonseca21278192015-01-20 14:27:04 +0000633 docs/USAGE.markdown
José Fonseca27440922011-11-01 08:27:12 +0000634 DESTINATION ${DOC_INSTALL_DIR}
Carl Worthe9236072011-10-18 16:06:05 -0700635)
José Fonseca8fae49d2012-12-11 07:22:16 +0000636install (
637 FILES LICENSE
638 DESTINATION ${DOC_INSTALL_DIR}
639 RENAME LICENSE.txt
640)
José Fonseca0dc84852011-05-14 10:46:24 +0100641
Jose Fonseca8bea5be2020-05-09 15:33:14 +0100642set (CPACK_PACKAGE_VERSION "latest")
643# https://www.appveyor.com/docs/environment-variables/
644if (($ENV{APPVEYOR}) AND ($ENV{APPVEYOR_REPO_TAG}))
645 set (CPACK_PACKAGE_VERSION "$ENV{APPVEYOR_REPO_TAG_NAME}")
646endif ()
647# https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
648if (($ENV{TRAVIS}) AND NOT "$ENV{TRAVIS_TAG}" STREQUAL "")
649 set (CPACK_PACKAGE_VERSION "$ENV{TRAVIS_TAG}")
650endif ()
José Fonseca17311e82011-05-08 11:12:08 +0100651
José Fonseca63c02f32012-02-29 10:55:55 +0000652# cpack mistakenly detects Mingw-w64 as win32
653if (MINGW)
654 if (CMAKE_SIZEOF_VOID_P EQUAL 8)
655 set (CPACK_SYSTEM_NAME win64)
656 endif ()
657endif ()
658
José Fonsecafa54c8a2011-06-02 14:48:38 +0100659# See http://www.vtk.org/Wiki/CMake:CPackPackageGenerators
José Fonseca17311e82011-05-08 11:12:08 +0100660if (WIN32)
José Fonseca99ff4a72015-03-18 15:13:30 +0000661 if (CMAKE_VERSION VERSION_LESS 3.1)
662 set (CPACK_GENERATOR "ZIP")
663 else ()
664 set (CPACK_GENERATOR "7Z")
665 endif ()
José Fonsecafa54c8a2011-06-02 14:48:38 +0100666elseif (APPLE)
667 set (CPACK_GENERATOR "DragNDrop")
668else ()
José Fonseca7e0b44f2011-06-06 19:36:37 +0100669 set (CPACK_GENERATOR "TBZ2")
José Fonsecafa54c8a2011-06-02 14:48:38 +0100670endif ()
José Fonseca17311e82011-05-08 11:12:08 +0100671
672include(CPack)