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)
##############################################################################
# Find dependencies
+# Ensure __thread is support
+if (NOT MSVC)
+ include (CheckCXXSourceCompiles)
+ check_cxx_source_compiles("__thread int i; int main() { return 0; }" HAVE_COMPILER_TLS)
+ if (NOT HAVE_COMPILER_TLS)
+ if (APPLE)
+ message (FATAL_ERROR "C++ compiler does not support __thread keyword. Please install XCode 4.5 or higher.")
+ else (MINGW32)
+ message (FATAL_ERROR "C++ compiler does not support __thread keyword. Please use MinGW g++ version 4.4 or higher")
+ else ()
+ message (FATAL_ERROR "C++ compiler does not support __thread keyword.")
+ endif ()
+ endif ()
+endif ()
+
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set (CMAKE_USE_PYTHON_VERSION 2.7 2.6)
if (WIN32)
# http://msdn.microsoft.com/en-us/library/aa383745.aspx
- add_definitions (-D_WIN32_WINNT=0x0501 -DWINVER=0x0501)
+ add_definitions (-D_WIN32_WINNT=0x0601 -DWINVER=0x0601)
else (WIN32)
CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" CXX_COMPILER_FLAG_VISIBILITY)
if (CXX_COMPILER_FLAG_VISIBILITY)
add_definitions (-Wall)
# XXX: it's safer to use ssize_t everywhere instead of disabling warning
add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
+
+ # Use GDB extensions if available
+ if (CMAKE_COMPILER_IS_GNUC)
+ set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -O0")
+ set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ggdb")
+ endif ()
+ if (CMAKE_COMPILER_IS_GNUCXX)
+ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -O0")
+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ggdb")
+ endif ()
+
+ # Be nice to Eclipse
+ add_definitions (-fmessage-length=0)
endif ()
if (MINGW)
# also avoids missing/inconsistent declarations in system headers.
include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/khronos)
+
##############################################################################
# Installation directories
+if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+ # Debian multiarch support
+ execute_process(COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
+ OUTPUT_VARIABLE ARCH_SUBDIR
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+endif()
+
if (WIN32 OR APPLE)
# On Windows/MacOSX, applications are usually installed on a directory of
# their own
set (DOC_INSTALL_DIR doc)
set (LIB_INSTALL_DIR lib)
+ set (LIB_ARCH_INSTALL_DIR lib)
else ()
set (DOC_INSTALL_DIR share/doc/${CMAKE_PROJECT_NAME})
set (LIB_INSTALL_DIR lib/${CMAKE_PROJECT_NAME})
+ if (ARCH_SUBDIR)
+ set (LIB_ARCH_INSTALL_DIR lib/${ARCH_SUBDIR}/${CMAKE_PROJECT_NAME})
+ else ()
+ set (LIB_ARCH_INSTALL_DIR lib/${CMAKE_PROJECT_NAME})
+ endif ()
endif ()
-set(SCRIPTS_INSTALL_DIR ${LIB_INSTALL_DIR}/scripts)
-set(WRAPPER_INSTALL_DIR ${LIB_INSTALL_DIR}/wrappers)
+set (SCRIPTS_INSTALL_DIR ${LIB_INSTALL_DIR}/scripts)
+set (WRAPPER_INSTALL_DIR ${LIB_ARCH_INSTALL_DIR}/wrappers)
# Expose the binary/install directories to source
#
add_definitions(
-DAPITRACE_BINARY_DIR="${CMAKE_BINARY_DIR}"
-DAPITRACE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
- -DAPITRACE_WRAPPER_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${WRAPPER_INSTALL_DIR}"
+ -DAPITRACE_SCRIPTS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${SCRIPTS_INSTALL_DIR}"
+ -DAPITRACE_WRAPPERS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${WRAPPER_INSTALL_DIR}"
)
common/trace_loader.cpp
common/trace_resource.cpp
common/trace_tools_trace.cpp
+ common/trace_profiler.cpp
common/image.cpp
common/image_bmp.cpp
common/image_pnm.cpp
common/image_png.cpp
common/${os}
+ common/workqueue.cpp
)
set_target_properties (common PROPERTIES