]> git.cworth.org Git - apitrace/blobdiff - CMakeLists.txt
Don't assume pthreads is present.
[apitrace] / CMakeLists.txt
index 538ca8e80f08fc8ab837c9d29cd569c8a3f9f7b4..df4aed1d9199aa7a8c24d2be037381477f0145cc 100755 (executable)
@@ -32,6 +32,8 @@ set (CMAKE_USE_PYTHON_VERSION 2.7 2.6)
 find_package (PythonInterp REQUIRED)
 find_package (OpenGL REQUIRED)
 
+find_package (Threads)
+
 if (ENABLE_GUI)
     if (NOT (ENABLE_GUI STREQUAL "AUTO"))
         set (REQUIRE_GUI REQUIRED)
@@ -178,6 +180,12 @@ include_directories (${PNG_INCLUDE_DIR})
 add_definitions (${PNG_DEFINITIONS})
 link_libraries (${PNG_LIBRARIES})
 
+if (MSVC)
+    add_subdirectory (thirdparty/getopt EXCLUDE_FROM_ALL)
+    include_directories (${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/getopt)
+    set (GETOPT_LIBRARIES getopt_bundled)
+endif ()
+
 # The Qt website provides binaries for Windows and MacOSX, and they are
 # automatically found by cmake without any manual intervention.  The situation
 # for QJSON is substantially different: there are no binaries for QJSON
@@ -209,22 +217,14 @@ 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)
 else ()
     set (DOC_INSTALL_DIR share/doc/${CMAKE_PROJECT_NAME})
-endif ()
-
-set (LIB_INSTALL_DIR lib/apitrace)
-
-if (APPLE)
-    # MacOSX uses fat binaries, so no need to have per-architecture wrapper
-    # directories
-    set (LIB_ARCH_INSTALL_DIR ${LIB_INSTALL_DIR})
-else ()
-    set (LIB_ARCH_INSTALL_DIR ${LIB_INSTALL_DIR}/${CMAKE_SYSTEM_PROCESSOR})
+    set (LIB_INSTALL_DIR lib/${CMAKE_PROJECT_NAME})
 endif ()
 
 set(SCRIPTS_INSTALL_DIR ${LIB_INSTALL_DIR}/scripts)
-set(WRAPPER_INSTALL_DIR ${LIB_ARCH_INSTALL_DIR}/wrappers)
+set(WRAPPER_INSTALL_DIR ${LIB_INSTALL_DIR}/wrappers)
 
 # Expose the binary/install directories to source
 #
@@ -278,7 +278,6 @@ add_library (common STATIC
     common/trace_file_write.cpp
     common/trace_file_zlib.cpp
     common/trace_file_snappy.cpp
-    common/trace_copier.cpp
     common/trace_model.cpp
     common/trace_parser.cpp
     common/trace_parser_flags.cpp
@@ -427,7 +426,7 @@ elseif (APPLE)
     )
 
     target_link_libraries (cgltrace
-        pthread
+        ${CMAKE_THREAD_LIBS_INIT}
         dl
     )
 
@@ -460,7 +459,7 @@ elseif (X11_FOUND)
 
     target_link_libraries (glxtrace
         ${X11_X11_LIB}
-        pthread
+        ${CMAKE_THREAD_LIBS_INIT}
         dl
     )
 
@@ -501,7 +500,7 @@ if (EGL_FOUND)
     )
 
     target_link_libraries (egltrace
-        pthread
+        ${CMAKE_THREAD_LIBS_INIT}
         dl
     )
 
@@ -572,7 +571,7 @@ if (WIN32 OR APPLE OR X11_FOUND)
             # gdb doesn't like when pthreads is loaded through dlopen (which happens
             # when dlopen'ing libGL), so link pthreads to avoid this issue.  See also
             # http://stackoverflow.com/questions/2702628/gdb-cannot-find-new-threads-generic-error
-            pthread
+            ${CMAKE_THREAD_LIBS_INIT}
             dl
         )
 
@@ -604,7 +603,7 @@ if (EGL_FOUND AND X11_FOUND AND NOT WIN32 AND NOT APPLE)
     target_link_libraries (eglretrace
         common
         ${X11_X11_LIB}
-        pthread
+        ${CMAKE_THREAD_LIBS_INIT}
         dl
     )
 
@@ -625,7 +624,7 @@ add_subdirectory(cli)
 
 install (
     PROGRAMS
-        ${CMAKE_CURRENT_SOURCE_DIR}/scripts/tracediff.sh
+        ${CMAKE_CURRENT_SOURCE_DIR}/scripts/tracediff.py
         ${CMAKE_CURRENT_SOURCE_DIR}/scripts/jsondiff.py
         ${CMAKE_CURRENT_SOURCE_DIR}/scripts/snapdiff.py
     DESTINATION ${SCRIPTS_INSTALL_DIR}
@@ -652,7 +651,7 @@ install (
     DESTINATION ${DOC_INSTALL_DIR}
 )
 
-set (CPACK_PACKAGE_VERSION_MAJOR "2")
+set (CPACK_PACKAGE_VERSION_MAJOR "3")
 set (CPACK_PACKAGE_VERSION_MINOR "0")
 
 # Use current date in YYYYMMDD format as patch number 
@@ -661,6 +660,13 @@ execute_process (
     OUTPUT_VARIABLE CPACK_PACKAGE_VERSION_PATCH
 )
 
+# cpack mistakenly detects Mingw-w64 as win32
+if (MINGW)
+    if (CMAKE_SIZEOF_VOID_P EQUAL 8)
+        set (CPACK_SYSTEM_NAME win64)
+    endif ()
+endif ()
+
 # See http://www.vtk.org/Wiki/CMake:CPackPackageGenerators
 if (WIN32)
     set (CPACK_GENERATOR "ZIP")