Add optional natvis link

This commit is contained in:
Aleksandr Orefkov 2025-12-02 11:05:41 +03:00
parent 1301597229
commit bca4664d1a
1 changed files with 18 additions and 11 deletions

View File

@ -21,8 +21,13 @@ elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
set(CLANG_COMPILER ON) set(CLANG_COMPILER ON)
endif() endif()
option(SIMSTR_BUILD_TESTS "Построить тесты" ON) if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC OR "${CMAKE_CXX_SIMULATE_ID} " STREQUAL "MSVC ")
option(SIMSTR_BENCHMARKS "Построить замеры производительности" Off) set(CAN_LINK_NATVIS On)
endif()
option(SIMSTR_BUILD_TESTS "Build tests" ON)
option(SIMSTR_BENCHMARKS "Build benchmarks" Off)
cmake_dependent_option(SIMSTR_LINK_NATVIS "Link natvis file" On CAN_LINK_NATVIS Off)
add_library(simstr_simstr add_library(simstr_simstr
src/sstring.cpp src/sstring.cpp
@ -50,8 +55,9 @@ endif(EMSCRIPTEN)
message("Configuring simstr for [${CMAKE_BUILD_TYPE}]") message("Configuring simstr for [${CMAKE_BUILD_TYPE}]")
# Для MSVC подключаем natvis файл для красивой отладки if (SIMSTR_LINK_NATVIS)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC OR "${CMAKE_CXX_SIMULATE_ID} " STREQUAL "MSVC ") # Для MSVC подключаем natvis файл для красивой отладки
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC OR "${CMAKE_CXX_SIMULATE_ID} " STREQUAL "MSVC ")
add_custom_command( add_custom_command(
TARGET simstr_simstr PRE_BUILD TARGET simstr_simstr PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy COMMAND ${CMAKE_COMMAND} -E copy
@ -59,6 +65,7 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC OR "${CMAKE_CXX_SIMULATE_ID} " STREQU
${CMAKE_BINARY_DIR}/simstr.natvis ${CMAKE_BINARY_DIR}/simstr.natvis
) )
target_link_options(simstr_simstr PUBLIC "/natvis:${CMAKE_BINARY_DIR}/simstr.natvis") target_link_options(simstr_simstr PUBLIC "/natvis:${CMAKE_BINARY_DIR}/simstr.natvis")
endif()
endif() endif()
set_target_properties( set_target_properties(