diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cc24cd9..c44e93c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,48 +1,87 @@ -project (Optick) -cmake_minimum_required (VERSION 3.0) +cmake_minimum_required(VERSION 3.2) +project(Optick LANGUAGES CXX) -# Options: GAPI -option(BUILD_VULKAN "Built-in support for Vulkan" OFF) -option(BUILD_D3D12 "Built-in support for DicrectX 12" OFF) -# Options: Other -option(BUILD_FIBERS "Built-in support for Fibers" OFF) -set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake") set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set(CMAKE_CXX_STANDARD 11) -set (CMAKE_CXX_STANDARD 11) -set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Build) -set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) +# hacks for standalone builds with visual studio +if(MSVC AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + message(STATUS "Standalone build") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Build") + set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) + set(standalone ON) +else() + set(standalone OFF) +endif() + + +# Sources +file(GLOB OPTICK_SRC "src/*.*") +source_group("OptickCore" FILES ${OPTICK_SRC}) + + +# Enabled +option(OPTICK_ENABLED "Enable profiling with Optick" ON) +if(NOT OPTICK_ENABLED) + message(STATUS "Optick is disabled") + # add dummy target as a replacement + add_library(OptickCore STATIC ${OPTICK_SRC}) + target_include_directories(OptickCore PUBLIC "src") + target_compile_definitions(OptickCore PUBLIC USE_OPTICK=0) + return() +endif() + -#OptickCore -file(GLOB OPTICK_SOURCE ${PROJECT_SOURCE_DIR}/src/*.*) -SET(OPTICK_SRC ${OPTICK_SOURCE}) -source_group("OptickCore" FILES ${OPTICK_SOURCE}) -include_directories ("${PROJECT_SOURCE_DIR}/src") +# Options +option(OPTICK_USE_VULKAN "Built-in support for Vulkan" OFF) +option(OPTICK_USE_D3D12 "Built-in support for DirectX 12" OFF) +option(OPTICK_BUILD_GUI_APP "Build Optick gui viewer app" OFF) +option(OPTICK_BUILD_CONSOLE_SAMPLE "Build Optick console sample app" ${standalone}) -if(BUILD_VULKAN) - include_directories("$(VULKAN_SDK)/Include") + +# OptickCore +add_library(OptickCore SHARED ${OPTICK_SRC}) +target_include_directories(OptickCore PUBLIC "src") +target_compile_definitions(OptickCore PUBLIC OPTICK_EXPORTS=1) +if(OPTICK_USE_VULKAN) + message(STATUS "Optick uses Vulkan") + target_include_directories(OptickCore PRIVATE "$(VULKAN_SDK)/Include") +else() + target_compile_definitions(OptickCore PRIVATE OPTICK_ENABLE_GPU_VULKAN=0) +endif() +if(OPTICK_USE_D3D12) + message(STATUS "Optick uses DirectX 12") +else() + target_compile_definitions(OptickCore PRIVATE OPTICK_ENABLE_GPU_D3D12=0) +endif() +if(OPTICK_USE_D3D12 OR OPTICK_USE_VULKAN) + target_compile_definitions(OptickCore PRIVATE OPTICK_ENABLE_GPU=1) else() - add_definitions(-DBRO_ENABLE_GPU_VULKAN=0) -endif() + target_compile_definitions(OptickCore PRIVATE OPTICK_ENABLE_GPU=0) +endif() + + +set(EXTRA_LIBS ${EXTRA_LIBS} OptickCore) +if(NOT MSVC) + set(EXTRA_LIBS ${EXTRA_LIBS} pthread) +endif() -if(!BUILD_D3D12) - add_definitions(-DBRO_ENABLE_GPU_D3D12=0) -endif() +# Gui App +if(MSVC AND OPTICK_BUILD_GUI_APP) + add_subdirectory(gui) +endif() -add_library(OptickCore ${OPTICK_SRC}) -set (EXTRA_LIBS ${EXTRA_LIBS} OptickCore pthread) +# Console App +if(OPTICK_BUILD_CONSOLE_SAMPLE) + file(GLOB TEST_ENGINE_SRC "samples/Common/TestEngine/*.*") + source_group("TestEngine" FILES ${TEST_ENGINE_SRC}) + add_executable(ConsoleApp "samples/ConsoleApp/main.cpp" ${TEST_ENGINE_SRC}) + target_include_directories(ConsoleApp PRIVATE "samples/Common/TestEngine") + target_link_libraries(ConsoleApp ${EXTRA_LIBS}) + set_target_properties(ConsoleApp PROPERTIES FOLDER Samples) +endif() -#ConsoleApp -file(GLOB TEST_ENGINE_SOURCE ${PROJECT_SOURCE_DIR}/samples/Common/TestEngine/*.*) -SET(TEST_ENGINE_SRC ${TEST_ENGINE_SOURCE}) -source_group("TestEngine" FILES ${TEST_ENGINE_SRC}) -include_directories("${PROJECT_SOURCE_DIR}/samples/Common/TestEngine") -add_executable(ConsoleApp ${PROJECT_SOURCE_DIR}/samples/ConsoleApp/main.cpp ${TEST_ENGINE_SRC}) -target_link_libraries (ConsoleApp ${EXTRA_LIBS}) -set_target_properties (ConsoleApp PROPERTIES - FOLDER Samples -) \ No newline at end of file diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt new file mode 100644 index 00000000..59a8c63f --- /dev/null +++ b/gui/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.8) +enable_language(CSharp) + +# TODO diff --git a/src/optick_core.win.h b/src/optick_core.win.h index 5a9f7342..1a9b6c9b 100644 --- a/src/optick_core.win.h +++ b/src/optick_core.win.h @@ -1239,7 +1239,7 @@ CaptureStatus::Type ETW::Start(Mode::Type mode, int frequency, const ThreadList& } ZeroMemory(&logFile, sizeof(EVENT_TRACE_LOGFILE)); - logFile.LoggerName = KERNEL_LOGGER_NAME; + logFile.LoggerName = (LPSTR)KERNEL_LOGGER_NAME; logFile.ProcessTraceMode = (PROCESS_TRACE_MODE_REAL_TIME | PROCESS_TRACE_MODE_EVENT_RECORD | PROCESS_TRACE_MODE_RAW_TIMESTAMP); logFile.EventRecordCallback = OnRecordEvent; logFile.BufferCallback = OnBufferRecord;