mirror of https://github.com/orefkov/simstr.git
Добавил прилинковку natvis для MSVC.
This commit is contained in:
parent
ce3d84445f
commit
47a9a23bdb
115
CMakeLists.txt
115
CMakeLists.txt
|
|
@ -1,10 +1,10 @@
|
|||
cmake_minimum_required (VERSION 3.20)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
include(cmake/prelude.cmake)
|
||||
include(CMakeDependentOption)
|
||||
include(FetchContent)
|
||||
|
||||
project (
|
||||
simstr
|
||||
project(
|
||||
simstr
|
||||
VERSION 1.0.0
|
||||
DESCRIPTION "Yet another string library"
|
||||
HOMEPAGE_URL "https://github.com/orefkov/simstr"
|
||||
|
|
@ -14,28 +14,28 @@ project (
|
|||
include(cmake/project-is-top-level.cmake)
|
||||
include(cmake/variables.cmake)
|
||||
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
|
||||
set (MSVC_COMPILER ON)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /Zc:strictStrings")
|
||||
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
|
||||
set (CLANG_COMPILER ON)
|
||||
endif ()
|
||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
|
||||
set(MSVC_COMPILER ON)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /Zc:strictStrings")
|
||||
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
|
||||
set(CLANG_COMPILER ON)
|
||||
endif()
|
||||
|
||||
option(SIMSTR_BUILD_TESTS "Построить тесты" ON)
|
||||
option(SIMSTR_BENCHMARKS "Построить замеры производительности" ON)
|
||||
option(SIMSTR_SHARED "Функции simstr должны экспортироваться или импортироваться" OFF)
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
if(EMSCRIPTEN)
|
||||
option(SIMSTR_EMSCRIPTEN_MT "Использовать многопоточность в Emscripten" OFF)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-warn-absolute-paths -Wno-unknown-warning-option -msimd128 -msse4.2 -msse3")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-warn-absolute-paths -Wno-unknown-warning-option -msimd128 -msse4.2 -msse3")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-warn-absolute-paths -Wno-unknown-warning-option -msimd128 -msse4.2 -msse3")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-warn-absolute-paths -Wno-unknown-warning-option -msimd128 -msse4.2 -msse3")
|
||||
|
||||
if (SIMSTR_EMSCRIPTEN_MT)
|
||||
if(SIMSTR_EMSCRIPTEN_MT)
|
||||
message("Build MT emscripten")
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency-1")
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sENVIRONMENT=web,worker")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency-1")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sENVIRONMENT=web,worker")
|
||||
endif()
|
||||
endif(EMSCRIPTEN)
|
||||
|
||||
|
|
@ -53,6 +53,11 @@ target_include_directories(
|
|||
|
||||
target_compile_features(simstr_simstr PUBLIC cxx_std_20)
|
||||
|
||||
# Для MSVC подключаем natvis файл для красивой отладки
|
||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
|
||||
target_link_options(simstr_simstr PUBLIC "/natvis:${CMAKE_CURRENT_SOURCE_DIR}/for_debug/simstr.natvis")
|
||||
endif()
|
||||
|
||||
set_target_properties(
|
||||
simstr_simstr PROPERTIES
|
||||
CXX_VISIBILITY_PRESET hidden
|
||||
|
|
@ -63,37 +68,37 @@ set_target_properties(
|
|||
OUTPUT_NAME simstr
|
||||
)
|
||||
|
||||
function (Simdutf)
|
||||
set (SIMDUTF_TOOLS OFF)
|
||||
set (SIMDUTF_TESTS OFF)
|
||||
set (SIMDUTF_BENCHMARKS OFF)
|
||||
FetchContent_Declare(
|
||||
simdutf
|
||||
GIT_REPOSITORY https://github.com/simdutf/simdutf.git
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_TAG tags/v7.5.0
|
||||
FIND_PACKAGE_ARGS
|
||||
)
|
||||
FetchContent_MakeAvailable(simdutf)
|
||||
function(Simdutf)
|
||||
set(SIMDUTF_TOOLS OFF)
|
||||
set(SIMDUTF_TESTS OFF)
|
||||
set(SIMDUTF_BENCHMARKS OFF)
|
||||
FetchContent_Declare(
|
||||
simdutf
|
||||
GIT_REPOSITORY https://github.com/simdutf/simdutf.git
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_TAG tags/v7.5.0
|
||||
FIND_PACKAGE_ARGS
|
||||
)
|
||||
FetchContent_MakeAvailable(simdutf)
|
||||
endfunction()
|
||||
|
||||
Simdutf()
|
||||
|
||||
target_link_libraries(simstr_simstr PUBLIC simdutf::simdutf)
|
||||
|
||||
if (SIMSTR_SHARED)
|
||||
if(SIMSTR_SHARED)
|
||||
add_compile_definitions(SIMSTR_SHARED)
|
||||
target_compile_definitions(simstr_simstr PRIVATE SIMSTR_EXPORT)
|
||||
endif(SIMSTR_SHARED)
|
||||
|
||||
if (SIMSTR_BUILD_TESTS)
|
||||
if(SIMSTR_BUILD_TESTS)
|
||||
enable_testing()
|
||||
set (BUILD_TESTS ON)
|
||||
set(BUILD_TESTS ON)
|
||||
# Load and build GTest
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
# Specify the commit you depend on and update it regularly.
|
||||
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip
|
||||
googletest
|
||||
# Specify the commit you depend on and update it regularly.
|
||||
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip
|
||||
)
|
||||
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
|
|
@ -102,46 +107,46 @@ if (SIMSTR_BUILD_TESTS)
|
|||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
function (GBencmark)
|
||||
function(GBencmark)
|
||||
# Load and build Google benchmarks
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
googlebench
|
||||
# Specify the commit you depend on and update it regularly.
|
||||
URL https://github.com/google/benchmark/archive/refs/tags/v1.7.0.zip
|
||||
googlebench
|
||||
# Specify the commit you depend on and update it regularly.
|
||||
URL https://github.com/google/benchmark/archive/refs/tags/v1.7.0.zip
|
||||
)
|
||||
set (CMAKE_CXX_STANDARD 20)
|
||||
set (BENCHMARK_ENABLE_TESTING OFF)
|
||||
set (BENCHMARK_ENABLE_LTO OFF)
|
||||
set (BENCHMARK_ENABLE_INSTALL OFF)
|
||||
set (BENCHMARK_INSTALL_DOCS OFF)
|
||||
set (BENCHMARK_DOWNLOAD_DEPENDENCIES ON)
|
||||
set (BENCHMARK_ENABLE_GTEST_TESTS OFF)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(BENCHMARK_ENABLE_TESTING OFF)
|
||||
set(BENCHMARK_ENABLE_LTO OFF)
|
||||
set(BENCHMARK_ENABLE_INSTALL OFF)
|
||||
set(BENCHMARK_INSTALL_DOCS OFF)
|
||||
set(BENCHMARK_DOWNLOAD_DEPENDENCIES ON)
|
||||
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
|
||||
add_compile_definitions(BENCHMARK_STATIC_DEFINE)
|
||||
FetchContent_MakeAvailable(googlebench)
|
||||
endfunction()
|
||||
|
||||
if (SIMSTR_BENCHMARKS)# AND CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
set (BUILD_BENCHMARKS ON)
|
||||
if(SIMSTR_BENCHMARKS) # AND CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
set(BUILD_BENCHMARKS ON)
|
||||
GBencmark()
|
||||
add_subdirectory(bench)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# ---- Install rules ----
|
||||
|
||||
if(NOT CMAKE_SKIP_INSTALL_RULES)
|
||||
include(cmake/install-rules.cmake)
|
||||
include(cmake/install-rules.cmake)
|
||||
endif()
|
||||
|
||||
# ---- Developer mode ----
|
||||
|
||||
if(NOT simstr_DEVELOPER_MODE)
|
||||
return()
|
||||
return()
|
||||
elseif(NOT PROJECT_IS_TOP_LEVEL)
|
||||
message(
|
||||
AUTHOR_WARNING
|
||||
"Developer mode is intended for developers of simstr"
|
||||
)
|
||||
message(
|
||||
AUTHOR_WARNING
|
||||
"Developer mode is intended for developers of simstr"
|
||||
)
|
||||
endif()
|
||||
|
||||
include(cmake/dev-mode.cmake)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
simstr.natvis - для использования в отладчике MSVC, и simstr_pretty_print.py для работы с gdb.
|
||||
|
||||
# Объекты simstr в отладчиках
|
||||
Если вы работаете в MS Visual Studio - просто добавьте simstr.natvis в свой проект.
|
||||
Если вы работаете в MS Visual Studio simstr.natvis автоматически добавляется в pdb файл,
|
||||
и обеспечивает удобный просмотр строковых объектов simstr везде, где используется эта библиотека.
|
||||
|
||||
# Объекты simstr в Visual Studio Code
|
||||
## При работе в gdb
|
||||
|
|
|
|||
Loading…
Reference in New Issue