From 9ecda53ba3ea3057e8e0dc8540e05085527e3542 Mon Sep 17 00:00:00 2001 From: Giorge Koulin Date: Fri, 31 Mar 2023 09:08:48 +0100 Subject: [PATCH] Building profiler UI and utitily executables with CMake. Tracy UI server app. `csvexport` utitily executable. `capture` utitily executable. `update` utitily executable. --- CMakeLists.txt | 19 ++++++++- capture/CMakeLists.txt | 5 +++ cmake/defaults.cmake | 22 ++++++++++ csvexport/CMakeLists.txt | 5 +++ getopt/CMakeLists.txt | 1 + imgui/CMakeLists.txt | 11 +++++ nfd/CMakeLists.txt | 18 ++++++++ profiler/CMakeLists.txt | 38 +++++++++++++++++ public/CMakeLists.txt | 1 + public/common/CMakeLists.txt | 10 +++++ server/CMakeLists.txt | 74 +++++++++++++++++++++++++++++++++ server/TracySourceView.cpp | 2 +- server/TracyWorker.cpp | 2 +- update/CMakeLists.txt | 5 +++ zstd/CMakeLists.txt | 12 ++++++ zstd/common/CMakeLists.txt | 12 ++++++ zstd/compress/CMakeLists.txt | 19 +++++++++ zstd/decompress/CMakeLists.txt | 10 +++++ zstd/dictBuilder/CMakeLists.txt | 5 +++ 19 files changed, 267 insertions(+), 4 deletions(-) create mode 100644 capture/CMakeLists.txt create mode 100644 cmake/defaults.cmake create mode 100644 csvexport/CMakeLists.txt create mode 100644 getopt/CMakeLists.txt create mode 100644 imgui/CMakeLists.txt create mode 100644 nfd/CMakeLists.txt create mode 100644 profiler/CMakeLists.txt create mode 100644 public/CMakeLists.txt create mode 100644 public/common/CMakeLists.txt create mode 100644 server/CMakeLists.txt create mode 100644 update/CMakeLists.txt create mode 100644 zstd/CMakeLists.txt create mode 100644 zstd/common/CMakeLists.txt create mode 100644 zstd/compress/CMakeLists.txt create mode 100644 zstd/decompress/CMakeLists.txt create mode 100644 zstd/dictBuilder/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index d69f71eb..f9414a47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10) -project(Tracy LANGUAGES CXX) +project(Tracy LANGUAGES C CXX) if(${BUILD_SHARED_LIBS}) set(DEFAULT_STATIC OFF) @@ -130,7 +130,22 @@ set(common_includes ${TRACY_PUBLIC_DIR}/common/TracyUwp.hpp ${TRACY_PUBLIC_DIR}/common/TracyYield.hpp) -install(TARGETS TracyClient +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +include(defaults) + +add_subdirectory(capture) +add_subdirectory(csvexport) +add_subdirectory(getopt) +# TODO: consider using external imgui package. +add_subdirectory(imgui) +add_subdirectory(nfd) +add_subdirectory(profiler) +add_subdirectory(public) +add_subdirectory(server) +add_subdirectory(update) +add_subdirectory(zstd) + +install(TARGETS TracyClient Tracy update capture csvexport EXPORT TracyConfig RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/capture/CMakeLists.txt b/capture/CMakeLists.txt new file mode 100644 index 00000000..aef82b4d --- /dev/null +++ b/capture/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(capture src/capture.cpp) + +set_default_compile_options(capture) + +target_link_libraries(capture PRIVATE server getopt) diff --git a/cmake/defaults.cmake b/cmake/defaults.cmake new file mode 100644 index 00000000..89386ca1 --- /dev/null +++ b/cmake/defaults.cmake @@ -0,0 +1,22 @@ +function(set_default_compile_options TARGET_NAME) + # Set the C++ standard version. + target_compile_features(${TARGET_NAME} PRIVATE cxx_std_17) + + target_compile_definitions( + ${TARGET_NAME} + PRIVATE # Avoid `min|max` macros declared in windows.h from stamping over + # `std::numeric_limits::min|max()` declared in . + $<$:NOMINMAX>) + + # Set rpath + get_target_property(_target_type ${TARGET_NAME} TYPE) + if(_target_type STREQUAL "EXECUTABLE") + if(APPLE) + set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH + "@executable_path") + elseif(UNIX) + set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH + "$ORIGIN;$ORIGIN/../lib") + endif() + endif() +endfunction(set_default_compile_options) diff --git a/csvexport/CMakeLists.txt b/csvexport/CMakeLists.txt new file mode 100644 index 00000000..44816ea2 --- /dev/null +++ b/csvexport/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(csvexport src/csvexport.cpp) + +set_default_compile_options(csvexport) + +target_link_libraries(csvexport PRIVATE server getopt) diff --git a/getopt/CMakeLists.txt b/getopt/CMakeLists.txt new file mode 100644 index 00000000..d348fa90 --- /dev/null +++ b/getopt/CMakeLists.txt @@ -0,0 +1 @@ +add_library(getopt STATIC getopt.c) diff --git a/imgui/CMakeLists.txt b/imgui/CMakeLists.txt new file mode 100644 index 00000000..b167290f --- /dev/null +++ b/imgui/CMakeLists.txt @@ -0,0 +1,11 @@ +add_library( + imgui STATIC misc/freetype/imgui_freetype.cpp imgui_widgets.cpp imgui.cpp + imgui_tables.cpp imgui_demo.cpp imgui_draw.cpp) + +set_default_compile_options(imgui) + +target_include_directories(imgui PUBLIC "${CMAKE_SOURCE_DIR}/imgui") + +find_package(Freetype REQUIRED) + +target_link_libraries(imgui PUBLIC public.common Freetype::Freetype) diff --git a/nfd/CMakeLists.txt b/nfd/CMakeLists.txt new file mode 100644 index 00000000..1b2faa24 --- /dev/null +++ b/nfd/CMakeLists.txt @@ -0,0 +1,18 @@ +add_library( + nfd STATIC + $<$:nfd_win.cpp> + $<$:nfd_cocoa.m> + # To use Linux native file dialog based on freedesktop portal, you need to + # have one of the portal implementation installed, e.g. + # `xdg-desktop-portal-gtk` + $<$:nfd_portal.cpp>) + +set_default_compile_options(nfd) + +if(UNIX AND NOT APPLE) + include(FindPkgConfig) + pkg_check_modules(dbus REQUIRED dbus-1) + + target_link_libraries(nfd PRIVATE ${dbus_LIBRARIES}) + target_include_directories(nfd PRIVATE ${dbus_INCLUDE_DIRS}) +endif() diff --git a/profiler/CMakeLists.txt b/profiler/CMakeLists.txt new file mode 100644 index 00000000..b213cbc9 --- /dev/null +++ b/profiler/CMakeLists.txt @@ -0,0 +1,38 @@ +add_executable( + Tracy WIN32 + src/WindowPosition.cpp + src/ConnectionHistory.cpp + src/RunQueue.cpp + src/BackendGlfw.cpp + src/Fonts.cpp + src/imgui/imgui_impl_opengl3.cpp + src/imgui/imgui_impl_glfw.cpp + src/winmainArchDiscovery.cpp + src/winmain.cpp + src/ResolvService.cpp + src/Filters.cpp + src/ImGuiContext.cpp + src/main.cpp + src/HttpRequest.cpp + build/win32/Tracy.rc) + +set_default_compile_options(Tracy) + +find_package(glfw REQUIRED) + +target_link_libraries(Tracy PRIVATE server glfw::glfw imgui nfd) + +if(APPLE) + find_library(FRAMEWORK_COREFOUNDATION CoreFoundation REQUIRED) + find_library(FRAMEWORK_APPKIT AppKit REQUIRED) + # Available from macOS 11.0+ + find_library(FRAMEWORK_UTI UniformTypeIdentifiers) + + target_link_libraries( + Tracy + PRIVATE + ${FRAMEWORK_COREFOUNDATION} + ${FRAMEWORK_APPKIT} + $<$:${FRAMEWORK_UTI}> + ) +endif() diff --git a/public/CMakeLists.txt b/public/CMakeLists.txt new file mode 100644 index 00000000..e4717b2d --- /dev/null +++ b/public/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(common) diff --git a/public/common/CMakeLists.txt b/public/common/CMakeLists.txt new file mode 100644 index 00000000..a4010c28 --- /dev/null +++ b/public/common/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(public.common STATIC tracy_lz4.cpp tracy_lz4hc.cpp TracySocket.cpp + TracyStackFrames.cpp TracySystem.cpp) + +set_default_compile_options(public.common) + +if(WIN32) + find_library(Wsock32 wsock32 REQUIRED) + find_library(Ws2_32 ws2_32 REQUIRED) + target_link_libraries(public.common PUBLIC Wsock32 Ws2_32) +endif() diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt new file mode 100644 index 00000000..f0522500 --- /dev/null +++ b/server/CMakeLists.txt @@ -0,0 +1,74 @@ +add_library( + server STATIC + TracyBadVersion.cpp + TracyColor.cpp + TracyEventDebug.cpp + TracyFileselector.cpp + TracyFilesystem.cpp + TracyImGui.cpp + TracyMemory.cpp + TracyMicroArchitecture.cpp + TracyMmap.cpp + TracyMouse.cpp + TracyPrint.cpp + TracyProtoHistory.cpp + TracySourceContents.cpp + TracySourceTokenizer.cpp + TracySourceView.cpp + TracyStorage.cpp + TracyTaskDispatch.cpp + TracyTexture.cpp + TracyTextureCompression.cpp + TracyThreadCompress.cpp + TracyTimelineController.cpp + TracyTimelineItem.cpp + TracyTimelineItemCpuData.cpp + TracyTimelineItemGpu.cpp + TracyTimelineItemPlot.cpp + TracyTimelineItemThread.cpp + TracyUserData.cpp + TracyUtility.cpp + TracyView.cpp + TracyView_Annotations.cpp + TracyView_Callstack.cpp + TracyView_Compare.cpp + TracyView_ConnectionState.cpp + TracyView_ContextSwitch.cpp + TracyView_CpuData.cpp + TracyView_FindZone.cpp + TracyView_FrameOverview.cpp + TracyView_FrameTimeline.cpp + TracyView_FrameTree.cpp + TracyView_GpuTimeline.cpp + TracyView_Locks.cpp + TracyView_Memory.cpp + TracyView_Messages.cpp + TracyView_Navigation.cpp + TracyView_NotificationArea.cpp + TracyView_Options.cpp + TracyView_Playback.cpp + TracyView_Plots.cpp + TracyView_Ranges.cpp + TracyView_Samples.cpp + TracyView_Statistics.cpp + TracyView_Timeline.cpp + TracyView_TraceInfo.cpp + TracyView_Utility.cpp + TracyView_ZoneInfo.cpp + TracyView_ZoneTimeline.cpp + TracyWeb.cpp + TracyWorker.cpp) + +set_default_compile_options(server) + +find_package(Capstone REQUIRED) + +target_include_directories(server PUBLIC "${CMAKE_SOURCE_DIR}/imgui") +target_link_libraries(server PUBLIC capstone::capstone zstd public.common) + +if(UNIX AND NOT APPLE) + # On Linux std algorithms use tbb + find_package(TBB REQUIRED COMPONENTS tbb) + + target_link_libraries(server PUBLIC TBB::tbb Threads::Threads) +endif() diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index 2af1a170..dd2991f4 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "imgui.h" #include "TracyCharUtil.hpp" diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 6b670753..3f885818 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #define ZDICT_STATIC_LINKING_ONLY #include "../zstd/zdict.h" diff --git a/update/CMakeLists.txt b/update/CMakeLists.txt new file mode 100644 index 00000000..cae9910a --- /dev/null +++ b/update/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(update src/update.cpp) + +set_default_compile_options(update) + +target_link_libraries(update PRIVATE server getopt) diff --git a/zstd/CMakeLists.txt b/zstd/CMakeLists.txt new file mode 100644 index 00000000..edcdd44c --- /dev/null +++ b/zstd/CMakeLists.txt @@ -0,0 +1,12 @@ +add_subdirectory(common) + +add_subdirectory(compress) + +add_subdirectory(decompress) + +add_subdirectory(dictBuilder) + +add_library(zstd INTERFACE) + +target_link_libraries(zstd INTERFACE zstd.compress zstd.decompress + zstd.dictBuilder) diff --git a/zstd/common/CMakeLists.txt b/zstd/common/CMakeLists.txt new file mode 100644 index 00000000..113fa060 --- /dev/null +++ b/zstd/common/CMakeLists.txt @@ -0,0 +1,12 @@ +add_library( + zstd.common STATIC + entropy_common.c + fse_decompress.c + debug.c + xxhash.c + pool.c + threading.c + zstd_common.c + error_private.c) + +set_default_compile_options(zstd.common) diff --git a/zstd/compress/CMakeLists.txt b/zstd/compress/CMakeLists.txt new file mode 100644 index 00000000..4feba5f9 --- /dev/null +++ b/zstd/compress/CMakeLists.txt @@ -0,0 +1,19 @@ +add_library( + zstd.compress STATIC + zstd_compress_superblock.c + zstdmt_compress.c + zstd_double_fast.c + zstd_fast.c + zstd_compress_sequences.c + zstd_ldm.c + hist.c + zstd_compress.c + zstd_lazy.c + zstd_compress_literals.c + huf_compress.c + zstd_opt.c + fse_compress.c) + +set_default_compile_options(zstd.compress) + +target_link_libraries(zstd.compress PUBLIC zstd.common) diff --git a/zstd/decompress/CMakeLists.txt b/zstd/decompress/CMakeLists.txt new file mode 100644 index 00000000..ffeb570e --- /dev/null +++ b/zstd/decompress/CMakeLists.txt @@ -0,0 +1,10 @@ +enable_language(ASM) + +add_library( + zstd.decompress STATIC + zstd_ddict.c huf_decompress.c zstd_decompress.c zstd_decompress_block.c + $<$:huf_decompress_amd64.S>) + +set_default_compile_options(zstd.decompress) + +target_link_libraries(zstd.decompress PUBLIC zstd.common) diff --git a/zstd/dictBuilder/CMakeLists.txt b/zstd/dictBuilder/CMakeLists.txt new file mode 100644 index 00000000..d526e92f --- /dev/null +++ b/zstd/dictBuilder/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(zstd.dictBuilder STATIC cover.c divsufsort.c fastcover.c zdict.c) + +set_default_compile_options(zstd.dictBuilder) + +target_link_libraries(zstd.dictBuilder PUBLIC zstd.common)