From cc4ed682714dda0b35b98190f0150a5b1caf8914 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 17 Mar 2024 12:55:48 +0100 Subject: [PATCH] Extract common set of server files to a separate cmake build file. Co-authored-by: Tom Atkinson --- cmake/server.cmake | 34 ++++++++++++++++++++++++++++++++++ profiler/CMakeLists.txt | 27 +++++++-------------------- 2 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 cmake/server.cmake diff --git a/cmake/server.cmake b/cmake/server.cmake new file mode 100644 index 00000000..e6211c57 --- /dev/null +++ b/cmake/server.cmake @@ -0,0 +1,34 @@ +set(TRACY_COMMON_DIR ${CMAKE_CURRENT_LIST_DIR}/../public/common) + +set(TRACY_COMMON_SOURCES + tracy_lz4.cpp + tracy_lz4hc.cpp + TracySocket.cpp + TracyStackFrames.cpp + TracySystem.cpp +) + +list(TRANSFORM TRACY_COMMON_SOURCES PREPEND "${TRACY_COMMON_DIR}/") + + +set(TRACY_SERVER_DIR ${CMAKE_CURRENT_LIST_DIR}/../server) + +set(TRACY_SERVER_SOURCES + TracyMemory.cpp + TracyMmap.cpp + TracyPrint.cpp + TracyTaskDispatch.cpp + TracyTextureCompression.cpp + TracyThreadCompress.cpp + TracyWorker.cpp +) + +list(TRANSFORM TRACY_SERVER_SOURCES PREPEND "${TRACY_SERVER_DIR}/") + + +add_library(TracyServer STATIC ${TRACY_COMMON_SOURCES} ${TRACY_SERVER_SOURCES}) +target_include_directories(TracyServer PUBLIC ${TRACY_COMMON_DIR} ${TRACY_SERVER_DIR}) +target_link_libraries(TracyServer PUBLIC TracyCapstone TracyZstd) +if(NO_STATISTICS) + target_compile_definitions(TracyServer PUBLIC TRACY_NO_STATISTICS) +endif() diff --git a/profiler/CMakeLists.txt b/profiler/CMakeLists.txt index f82edf3b..7dcac591 100644 --- a/profiler/CMakeLists.txt +++ b/profiler/CMakeLists.txt @@ -1,9 +1,10 @@ cmake_minimum_required(VERSION 3.16) -option(NO_FILESELECTOR "Disable the file selector") -option(GTK_FILESELECTOR "Use the GTK file selector on Linux instead of the xdg-portal one") -option(LEGACY "Instead of Wayland, use the legacy X11 backend on Linux") -option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)") +option(NO_FILESELECTOR "Disable the file selector" OFF) +option(GTK_FILESELECTOR "Use the GTK file selector on Linux instead of the xdg-portal one" OFF) +option(LEGACY "Instead of Wayland, use the legacy X11 backend on Linux" OFF) +option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF) +option(NO_STATISTICS "Disable calculation of statistics" OFF) include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) @@ -44,14 +45,7 @@ else() endif() include(${CMAKE_CURRENT_LIST_DIR}/../cmake/vendor.cmake) - -set(COMMON_FILES - ../public/common/tracy_lz4.cpp - ../public/common/tracy_lz4hc.cpp - ../public/common/TracySocket.cpp - ../public/common/TracyStackFrames.cpp - ../public/common/TracySystem.cpp -) +include(${CMAKE_CURRENT_LIST_DIR}/../cmake/server.cmake) set(SERVER_FILES ../server/TracyBadVersion.cpp @@ -60,20 +54,14 @@ set(SERVER_FILES ../server/TracyFileselector.cpp ../server/TracyFilesystem.cpp ../server/TracyImGui.cpp - ../server/TracyMemory.cpp ../server/TracyMicroArchitecture.cpp - ../server/TracyMmap.cpp ../server/TracyMouse.cpp - ../server/TracyPrint.cpp ../server/TracyProtoHistory.cpp ../server/TracySourceContents.cpp ../server/TracySourceTokenizer.cpp ../server/TracySourceView.cpp ../server/TracyStorage.cpp - ../server/TracyTaskDispatch.cpp ../server/TracyTexture.cpp - ../server/TracyTextureCompression.cpp - ../server/TracyThreadCompress.cpp ../server/TracyTimelineController.cpp ../server/TracyTimelineItem.cpp ../server/TracyTimelineItemCpuData.cpp @@ -111,7 +99,6 @@ set(SERVER_FILES ../server/TracyView_ZoneInfo.cpp ../server/TracyView_ZoneTimeline.cpp ../server/TracyWeb.cpp - ../server/TracyWorker.cpp ) set(PROFILER_FILES @@ -164,7 +151,7 @@ else() add_executable(${PROJECT_NAME} ${PROFILER_FILES} ${COMMON_FILES} ${SERVER_FILES}) endif() -target_link_libraries(${PROJECT_NAME} PRIVATE TracyImGui TracyCapstone TracyZstd TracyNfd) +target_link_libraries(${PROJECT_NAME} PRIVATE TracyServer TracyImGui TracyNfd) if(UNIX) target_link_libraries(${PROJECT_NAME} PRIVATE TracyTbb)