Merge pull request #248 from lukasberbuer/cmake-options-simplify

Simplify CMake option definition
This commit is contained in:
Bartosz Taudul 2021-08-01 13:25:12 +02:00 committed by GitHub
commit acccad2772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,19 +4,6 @@ project(Tracy LANGUAGES CXX)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
option(TRACY_ENABLE "Enable profiling" ON)
option(TRACY_ON_DEMAND "On-demand profiling" OFF)
option(TRACY_CALLSTACK "Collect call stacks" OFF)
option(TRACY_ONLY_LOCALHOST "Only listen on the localhost interface" OFF)
option(TRACY_NO_BROADCAST "Disable client discovery by broadcast to local network" OFF)
option(TRACY_NO_CODE_TRANSFER "Disable collection of source code" OFF)
option(TRACY_NO_CONTEXT_SWITCH "Disable capture of context switches" OFF)
option(TRACY_NO_EXIT "Client executable does not exit until all profile data is sent to server" OFF)
option(TRACY_NO_FRAME_IMAGE "Disable capture of frame images" OFF)
option(TRACE_NO_SAMPLING "Disable call stack sampling" OFF)
option(TRACY_NO_VERIFY "Disable zone validation for C API" OFF)
option(TRACY_NO_VSYNC_CAPTURE "Disable capture of hardware Vsync events" OFF)
add_library(TracyClient TracyClient.cpp) add_library(TracyClient TracyClient.cpp)
target_compile_features(TracyClient PUBLIC cxx_std_11) target_compile_features(TracyClient PUBLIC cxx_std_11)
target_include_directories(TracyClient PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(TracyClient PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
@ -34,24 +21,25 @@ endif()
add_library(Tracy::TracyClient ALIAS TracyClient) add_library(Tracy::TracyClient ALIAS TracyClient)
macro(set_option OPTION) macro(set_option option help value)
if(${OPTION}) option(${option} ${help} ${value})
message(STATUS "${OPTION}: ON") if(${option})
target_compile_definitions(TracyClient PUBLIC ${OPTION}) message(STATUS "${option}: ON")
target_compile_definitions(TracyClient PUBLIC ${option})
else() else()
message(STATUS "${OPTION}: OFF") message(STATUS "${option}: OFF")
endif() endif()
endmacro() endmacro()
set_option(TRACY_ENABLE) set_option(TRACY_ENABLE "Enable profiling" ON)
set_option(TRACY_ON_DEMAND) set_option(TRACY_ON_DEMAND "On-demand profiling" OFF)
set_option(TRACY_CALLSTACK) set_option(TRACY_CALLSTACK "Collect call stacks" OFF)
set_option(TRACY_ONLY_LOCALHOST) set_option(TRACY_ONLY_LOCALHOST "Only listen on the localhost interface" OFF)
set_option(TRACY_NO_BROADCAST) set_option(TRACY_NO_BROADCAST "Disable client discovery by broadcast to local network" OFF)
set_option(TRACY_NO_CODE_TRANSFER) set_option(TRACY_NO_CODE_TRANSFER "Disable collection of source code" OFF)
set_option(TRACY_NO_CONTEXT_SWITCH) set_option(TRACY_NO_CONTEXT_SWITCH "Disable capture of context switches" OFF)
set_option(TRACY_NO_EXIT) set_option(TRACY_NO_EXIT "Client executable does not exit until all profile data is sent to server" OFF)
set_option(TRACY_NO_FRAME_IMAGE) set_option(TRACY_NO_FRAME_IMAGE "Disable capture of frame images" OFF)
set_option(TRACE_NO_SAMPLING) set_option(TRACE_NO_SAMPLING "Disable call stack sampling" OFF)
set_option(TRACY_NO_VERIFY) set_option(TRACY_NO_VERIFY "Disable zone validation for C API" OFF)
set_option(TRACY_NO_VSYNC_CAPTURE) set_option(TRACY_NO_VSYNC_CAPTURE "Disable capture of hardware Vsync events" OFF)