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