From 76efdcb9194d78a63307122570f9fa9c8ab62557 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 24 Oct 2012 13:43:06 +0100 Subject: [PATCH] Prefer clang on MacOSX. For __thread support. --- CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6329689..09633c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,14 @@ cmake_minimum_required (VERSION 2.8) + +# Use clang on MacOSX. gcc doesn't support __thread key, and Apple has +# abandoned it for clang. This must be done before the project is defined. +if (APPLE) + set (CMAKE_C_COMPILER "clang") + set (CMAKE_CXX_COMPILER "clang++") +endif () + + project (apitrace) @@ -25,6 +34,15 @@ set (ENABLE_EGL true CACHE BOOL "Enable EGL support.") ############################################################################## # Find dependencies +# Ensure __thread is support +if (APPLE) + include (CheckCXXSourceCompiles) + check_cxx_source_compiles("__thread int i; int main() { return 0; }" HAVE_COMPILER_TLS) + if (NOT HAVE_COMPILER_TLS) + message (FATAL_ERROR "C++ compiler does not support __thread keyword. Please install XCode 4.5 or higher.") + endif () +endif () + set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) set (CMAKE_USE_PYTHON_VERSION 2.7 2.6) -- 2.43.0