mirror of
https://github.com/wolfpld/tracy.git
synced 2026-01-18 17:11:26 +01:00
[build-system] Migrate test/ directory to CMakeLists
- remove MakeFile, replaced with equivalent CMakeLists.txt - add advanced option TRACY_DEMANGLE in client for CI testing
This commit is contained in:
37
test/CMakeLists.txt
Normal file
37
test/CMakeLists.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
option(USE_DEBUGINFOD "Compile with debuginfod integration" OFF)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake)
|
||||
|
||||
# we target C++11 for the client part
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
project(
|
||||
tracy-test
|
||||
LANGUAGES C CXX
|
||||
VERSION ${TRACY_VERSION_STRING})
|
||||
|
||||
# a bit weird but works: include the client cmake config coming from top-level
|
||||
# cmake needs us to specify the build subfolder -> client/ this way we can
|
||||
# simply link the test executable against TracyClient
|
||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/.. client/)
|
||||
|
||||
add_executable(tracy-test test.cpp)
|
||||
target_link_options(tracy-test PRIVATE -rdynamic)
|
||||
target_link_libraries(tracy-test TracyClient)
|
||||
|
||||
# OS-specific options
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND USE_DEBUGINFOD)
|
||||
target_compile_definitions(tracy-test PRIVATE TRACY_DEBUGINFOD)
|
||||
target_link_libraries(tracy-test "debuginfod")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
target_link_libraries(tracy-test "execinfo")
|
||||
endif()
|
||||
|
||||
|
||||
# copy image file in build folder
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/image.jpg image.jpg COPYONLY)
|
||||
@@ -1,47 +0,0 @@
|
||||
OPTFLAGS := -g3 -fmerge-constants
|
||||
CFLAGS := $(OPTFLAGS) -Wall -DTRACY_ENABLE
|
||||
CXXFLAGS := $(CFLAGS) -std=gnu++11
|
||||
DEFINES +=
|
||||
INCLUDES := -I../public/tracy
|
||||
LIBS := -lpthread -ldl
|
||||
LDFLAGS := -rdynamic
|
||||
IMAGE := tracy_test
|
||||
|
||||
SRC := \
|
||||
test.cpp \
|
||||
../public/TracyClient.cpp
|
||||
|
||||
OBJ := $(SRC:%.cpp=%.o)
|
||||
|
||||
ifeq ($(shell uname -o),FreeBSD)
|
||||
LIBS += -lexecinfo
|
||||
endif
|
||||
|
||||
ifeq ($(shell uname),Linux)
|
||||
DEFINES += -DTRACY_DEBUGINFOD
|
||||
LIBS += -ldebuginfod
|
||||
endif
|
||||
|
||||
all: $(IMAGE)
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
%.d : %.cpp
|
||||
@echo Resolving dependencies of $<
|
||||
@mkdir -p $(@D)
|
||||
@$(CXX) -MM $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< > $@.$$$$; \
|
||||
sed 's,.*\.o[ :]*,$(<:.cpp=.o) $@ : ,g' < $@.$$$$ > $@; \
|
||||
rm -f $@.$$$$
|
||||
|
||||
$(IMAGE): $(OBJ)
|
||||
$(CXX) $(CXXFLAGS) $(DEFINES) $(OBJ) $(LIBS) $(LDFLAGS) -o $@
|
||||
|
||||
ifneq "$(MAKECMDGOALS)" "clean"
|
||||
-include $(SRC:.cpp=.d)
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) $(SRC:.cpp=.d) $(IMAGE)
|
||||
|
||||
.PHONY: clean all
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <stdlib.h>
|
||||
#include "Tracy.hpp"
|
||||
#include "../common/TracySystem.hpp"
|
||||
#include "tracy/Tracy.hpp"
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STBI_ONLY_JPEG
|
||||
@@ -328,7 +328,10 @@ int main()
|
||||
|
||||
int x, y;
|
||||
auto image = stbi_load( "image.jpg", &x, &y, nullptr, 4 );
|
||||
|
||||
if(image == nullptr)
|
||||
{
|
||||
std::cerr << "Could not find image.jpg in the current working directory, skipping" << std::endl;
|
||||
}
|
||||
for(;;)
|
||||
{
|
||||
TracyMessageL( "Tick" );
|
||||
@@ -337,7 +340,10 @@ int main()
|
||||
ZoneScoped;
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 2 ) );
|
||||
}
|
||||
FrameImage( image, x, y, 0, false );
|
||||
if(image != nullptr)
|
||||
{
|
||||
FrameImage( image, x, y, 0, false );
|
||||
}
|
||||
FrameMark;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user