<commit_before># CMake will throw a cryptic message if an user unwittingly invokes it from
# this directory.
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
    message (FATAL_ERROR
        "qapitrace must be built from the top source directory.\n"
        "Read docs/INSTALL.markdown for detailed build instructions."
    )
endif ()

add_definitions (-DQT_FORCE_ASSERTS)

if (APPLE)
    # Recent builds of Qt no longer support i386 architecture
    set (CMAKE_OSX_ARCHITECTURES "x86_64")
endif()

add_library (qubjson STATIC
    qubjson.cpp
)

add_gtest (qubjson_test qubjson_test.cpp)
target_link_libraries (qubjson_test qubjson)

set(qapitrace_SRCS
   androiddevicedialog.cpp
   androidfiledialog.cpp
   androidretracer.cpp
   androidutils.cpp
   apisurface.cpp
   apitrace.cpp
   apicalldelegate.cpp
   apitracecall.cpp
   apitracefilter.cpp
   apitracemodel.cpp
   argumentseditor.cpp
   glsledit.cpp
   imageviewer.cpp
   jumpwidget.cpp
   mainwindow.cpp
   main.cpp
   pixelwidget.cpp
   profiledialog.cpp
   profiletablemodel.cpp
   retracer.cpp
   saverthread.cpp
   searchwidget.cpp
   settingsdialog.cpp
   shaderssourcewidget.cpp
   tracedialog.cpp
   traceloader.cpp
   traceprocess.cpp
   trimprocess.cpp
   vertexdatainterpreter.cpp
   leaktracethread.cpp
   graphing/frameaxiswidget.cpp
   graphing/graphwidget.cpp
   graphing/graphaxiswidget.cpp
   graphing/graphview.cpp
   graphing/heatmapview.cpp
   graphing/heatmapverticalaxiswidget.cpp
   graphing/histogramview.cpp
   graphing/timeaxiswidget.cpp
 )

qt5_add_resources(qapitrace_SRCS qapitrace.qrc)

set(qapitrace_UIS
   ui/androidfiledialog.ui
   ui/androiddevicedialog.ui
   ui/argumentseditor.ui
   ui/imageviewer.ui
   ui/jumpwidget.ui
   ui/mainwindow.ui
   ui/profiledialog.ui
   ui/profilereplaydialog.ui
   ui/retracerdialog.ui
   ui/settings.ui
   ui/tracedialog.ui
   ui/searchwidget.ui
   ui/shaderssourcewidget.ui
   )

set (CMAKE_AUTOMOC ON)
# Silence `Note: No relevant classes found. No output generated.`
set (CMAKE_AUTOMOC_MOC_OPTIONS "-nn")

QT5_WRAP_UI(qapitrace_UIS_H ${qapitrace_UIS})
set(CMAKE_INCLUDE_CURRENT_DIR ON)

#add_app_icon(qapitrace_SRCS ../icons/hi*-qapitrace.png)
include_directories(
    ${CMAKE_SOURCE_DIR} # for image/*
)

add_executable (qapitrace ${qapitrace_SRCS} ${qapitrace_UIS_H})

# Avoid qt5_use_modules. See also:
# - https://bugreports.qt.io/browse/QTBUG-39457
# - http://doc.qt.io/qt-5/cmake-manual.html
# - http://www.kdab.com/using-cmake-with-qt-5/
if (Qt5Core_VERSION_STRING VERSION_LESS 5.2.0)
    qt5_use_modules (qubjson Widgets)
    qt5_use_modules (qubjson_test Widgets)
    qt5_use_modules (qapitrace Widgets Network)
else ()
    target_link_libraries (qubjson Qt5::Widgets)
    target_link_libraries (qubjson_test Qt5::Widgets)
    target_link_libraries (qapitrace Qt5::Widgets Qt5::Network)
endif ()

target_link_libraries (qapitrace
    qubjson
    image
    common
    ${ZLIB_LIBRARIES}
    ${SNAPPY_LIBRARIES}
    ${CMAKE_THREAD_LIBS_INIT}
)

if (WIN32 AND NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
    # Use Windows subsystem (i.e., no console).
    set_target_properties (qapitrace PROPERTIES CMAKE_WIN32_EXECUTABLE TRUE)
    if (MSVC)
        # When the Windows subsystem is chosen by default MSVC expects WinMain()
        # entry point, but we rather use plain old main() everywhere.
        set_target_properties (qapitrace PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup")
    endif ()
endif ()


########### install files ###############

install (TARGETS qapitrace RUNTIME DESTINATION bin)
install_pdb (qapitrace RUNTIME DESTINATION bin)
#install (FILES qapitrace.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})<commit_msg>cmake: Run windeployqt when installing/packaging.<commit_after># CMake will throw a cryptic message if an user unwittingly invokes it from
# this directory.
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
    message (FATAL_ERROR
        "qapitrace must be built from the top source directory.\n"
        "Read docs/INSTALL.markdown for detailed build instructions."
    )
endif ()

add_definitions (-DQT_FORCE_ASSERTS)

if (APPLE)
    # Recent builds of Qt no longer support i386 architecture
    set (CMAKE_OSX_ARCHITECTURES "x86_64")
endif()

add_library (qubjson STATIC
    qubjson.cpp
)

add_gtest (qubjson_test qubjson_test.cpp)
target_link_libraries (qubjson_test qubjson)

set(qapitrace_SRCS
   androiddevicedialog.cpp
   androidfiledialog.cpp
   androidretracer.cpp
   androidutils.cpp
   apisurface.cpp
   apitrace.cpp
   apicalldelegate.cpp
   apitracecall.cpp
   apitracefilter.cpp
   apitracemodel.cpp
   argumentseditor.cpp
   glsledit.cpp
   imageviewer.cpp
   jumpwidget.cpp
   mainwindow.cpp
   main.cpp
   pixelwidget.cpp
   profiledialog.cpp
   profiletablemodel.cpp
   retracer.cpp
   saverthread.cpp
   searchwidget.cpp
   settingsdialog.cpp
   shaderssourcewidget.cpp
   tracedialog.cpp
   traceloader.cpp
   traceprocess.cpp
   trimprocess.cpp
   vertexdatainterpreter.cpp
   leaktracethread.cpp
   graphing/frameaxiswidget.cpp
   graphing/graphwidget.cpp
   graphing/graphaxiswidget.cpp
   graphing/graphview.cpp
   graphing/heatmapview.cpp
   graphing/heatmapverticalaxiswidget.cpp
   graphing/histogramview.cpp
   graphing/timeaxiswidget.cpp
 )

qt5_add_resources(qapitrace_SRCS qapitrace.qrc)

set(qapitrace_UIS
   ui/androidfiledialog.ui
   ui/androiddevicedialog.ui
   ui/argumentseditor.ui
   ui/imageviewer.ui
   ui/jumpwidget.ui
   ui/mainwindow.ui
   ui/profiledialog.ui
   ui/profilereplaydialog.ui
   ui/retracerdialog.ui
   ui/settings.ui
   ui/tracedialog.ui
   ui/searchwidget.ui
   ui/shaderssourcewidget.ui
   )

set (CMAKE_AUTOMOC ON)
# Silence `Note: No relevant classes found. No output generated.`
set (CMAKE_AUTOMOC_MOC_OPTIONS "-nn")

QT5_WRAP_UI(qapitrace_UIS_H ${qapitrace_UIS})
set(CMAKE_INCLUDE_CURRENT_DIR ON)

#add_app_icon(qapitrace_SRCS ../icons/hi*-qapitrace.png)
include_directories(
    ${CMAKE_SOURCE_DIR} # for image/*
)

add_executable (qapitrace ${qapitrace_SRCS} ${qapitrace_UIS_H})

# Avoid qt5_use_modules. See also:
# - https://bugreports.qt.io/browse/QTBUG-39457
# - http://doc.qt.io/qt-5/cmake-manual.html
# - http://www.kdab.com/using-cmake-with-qt-5/
if (Qt5Core_VERSION_STRING VERSION_LESS 5.2.0)
    qt5_use_modules (qubjson Widgets)
    qt5_use_modules (qubjson_test Widgets)
    qt5_use_modules (qapitrace Widgets Network)
else ()
    target_link_libraries (qubjson Qt5::Widgets)
    target_link_libraries (qubjson_test Qt5::Widgets)
    target_link_libraries (qapitrace Qt5::Widgets Qt5::Network)
endif ()

target_link_libraries (qapitrace
    qubjson
    image
    common
    ${ZLIB_LIBRARIES}
    ${SNAPPY_LIBRARIES}
    ${CMAKE_THREAD_LIBS_INIT}
)

if (WIN32 AND NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
    # Use Windows subsystem (i.e., no console).
    set_target_properties (qapitrace PROPERTIES CMAKE_WIN32_EXECUTABLE TRUE)
    if (MSVC)
        # When the Windows subsystem is chosen by default MSVC expects WinMain()
        # entry point, but we rather use plain old main() everywhere.
        set_target_properties (qapitrace PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup")
    endif ()
endif ()


########### install files ###############

install (TARGETS qapitrace RUNTIME DESTINATION bin)
install_pdb (qapitrace RUNTIME DESTINATION bin)
#install (FILES qapitrace.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})

# Deployt Qt dependencies
#
# See:
# - http://doc.qt.io/qt-5/windows-deployment.html
#
# XXX: windeployqt can fail if there's weird stuff in the Path env var, so we
# invoke it with a sanitized Path, via `cmake -E env` that was introduced in
# CMake 3.1.
if (WIN32 AND NOT CMAKE_CROSSCOMPILING AND NOT CMAKE_VERSION VERSION_LESS 3.1)
    # http://stackoverflow.com/a/24676432
    get_target_property (QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
    get_filename_component (QT_BIN_DIR "${QT_QMAKE_EXECUTABLE}" DIRECTORY)
    find_program (QT_WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}")
    if (QT_WINDEPLOYQT_EXECUTABLE)
        file (TO_NATIVE_PATH "${QT_BIN_DIR}" QT_BIN_DIR_NATIVE)
        # It's safer to use `\` separateors in the Path, but we need to escape them
        string (REPLACE "\\" "\\\\" QT_BIN_DIR_NATIVE "${QT_BIN_DIR_NATIVE}")
        install (CODE "
            message (STATUS \"Running Qt Deploy Tool...\")
            execute_process (COMMAND
                \"${CMAKE_COMMAND}\" -E env
                \"Path=${QT_BIN_DIR_NATIVE};\$ENV{SystemRoot}\\\\System32;\$ENV{SystemRoot}\"
                \"${QT_WINDEPLOYQT_EXECUTABLE}\"
                \"\${CMAKE_INSTALL_PREFIX}/bin/qapitrace.exe\"
                --verbose 0)
        ")
    endif ()
endif ()
{'fraction_non_alphanumeric': 0.0912236189597509, 'fraction_numerical': 0.009572137008418868, 'mean_word_length': 3.8773903262092237, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7513357', 'n_tokens_mistral': 3288, 'n_tokens_neox': 3137, 'n_words': 619}