mirror of https://github.com/orefkov/simstr.git
Добавил прилинковку natvis для MSVC.
This commit is contained in:
parent
ce3d84445f
commit
b8296f5007
|
|
@ -1,9 +1,9 @@
|
|||
cmake_minimum_required (VERSION 3.20)
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
include(cmake/prelude.cmake)
|
||||
include(CMakeDependentOption)
|
||||
include(FetchContent)
|
||||
|
||||
project (
|
||||
project(
|
||||
simstr
|
||||
VERSION 1.0.0
|
||||
DESCRIPTION "Yet another string library"
|
||||
|
|
@ -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,10 +68,10 @@ set_target_properties(
|
|||
OUTPUT_NAME simstr
|
||||
)
|
||||
|
||||
function (Simdutf)
|
||||
set (SIMDUTF_TOOLS OFF)
|
||||
set (SIMDUTF_TESTS OFF)
|
||||
set (SIMDUTF_BENCHMARKS OFF)
|
||||
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
|
||||
|
|
@ -81,14 +86,14 @@ 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
|
||||
|
|
@ -102,7 +107,7 @@ if (SIMSTR_BUILD_TESTS)
|
|||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
function (GBencmark)
|
||||
function(GBencmark)
|
||||
# Load and build Google benchmarks
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
|
|
@ -110,22 +115,22 @@ function (GBencmark)
|
|||
# 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 ----
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue