Skip to content

Commit bca4664

Browse files
committed
Add optional natvis link
1 parent 1301597 commit bca4664

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

CMakeLists.txt

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
2121
set(CLANG_COMPILER ON)
2222
endif()
2323

24-
option(SIMSTR_BUILD_TESTS "Построить тесты" ON)
25-
option(SIMSTR_BENCHMARKS "Построить замеры производительности" Off)
24+
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC OR "${CMAKE_CXX_SIMULATE_ID} " STREQUAL "MSVC ")
25+
set(CAN_LINK_NATVIS On)
26+
endif()
27+
28+
option(SIMSTR_BUILD_TESTS "Build tests" ON)
29+
option(SIMSTR_BENCHMARKS "Build benchmarks" Off)
30+
cmake_dependent_option(SIMSTR_LINK_NATVIS "Link natvis file" On CAN_LINK_NATVIS Off)
2631

2732
add_library(simstr_simstr
2833
src/sstring.cpp
@@ -50,15 +55,17 @@ endif(EMSCRIPTEN)
5055

5156
message("Configuring simstr for [${CMAKE_BUILD_TYPE}]")
5257

53-
# Для MSVC подключаем natvis файл для красивой отладки
54-
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC OR "${CMAKE_CXX_SIMULATE_ID} " STREQUAL "MSVC ")
55-
add_custom_command(
56-
TARGET simstr_simstr PRE_BUILD
57-
COMMAND ${CMAKE_COMMAND} -E copy
58-
${CMAKE_CURRENT_SOURCE_DIR}/for_debug/simstr.natvis
59-
${CMAKE_BINARY_DIR}/simstr.natvis
60-
)
61-
target_link_options(simstr_simstr PUBLIC "/natvis:${CMAKE_BINARY_DIR}/simstr.natvis")
58+
if (SIMSTR_LINK_NATVIS)
59+
# Для MSVC подключаем natvis файл для красивой отладки
60+
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC OR "${CMAKE_CXX_SIMULATE_ID} " STREQUAL "MSVC ")
61+
add_custom_command(
62+
TARGET simstr_simstr PRE_BUILD
63+
COMMAND ${CMAKE_COMMAND} -E copy
64+
${CMAKE_CURRENT_SOURCE_DIR}/for_debug/simstr.natvis
65+
${CMAKE_BINARY_DIR}/simstr.natvis
66+
)
67+
target_link_options(simstr_simstr PUBLIC "/natvis:${CMAKE_BINARY_DIR}/simstr.natvis")
68+
endif()
6269
endif()
6370

6471
set_target_properties(

0 commit comments

Comments
 (0)