当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 1 Fork 0

ShenMian/math
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 2.29 KB
一键复制 编辑 原始数据 按行查看 历史
ShenMian 提交于 2023-06-21 17:59 . refactor!: rename some functions
# Copyright 2023 ShenMian
# License(Apache-2.0)
cmake_minimum_required(VERSION 3.16)
project(math
VERSION 0.0.0
DESCRIPTION "A simple linear algebra header-only library."
HOMEPAGE_URL "https://github.com/ShenMian/math"
LANGUAGES CXX)
option(BUILD_TESTS "Build tests" ON)
include(scripts/display_info.cmake)
add_library(${PROJECT_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} INTERFACE
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/deps/gcem/include")
if(BUILD_TESTS)
enable_testing()
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") # 静态链接 MSVC 运行库
endif()
add_executable(${PROJECT_NAME}_unit_test)
# target_link_libraries(${PROJECT_NAME}_unit_test INTERFACE math)
file(GLOB_RECURSE SOURCES "tests/*.cpp" "tests/*.ixx")
target_sources(${PROJECT_NAME}_unit_test PRIVATE ${SOURCES})
target_include_directories(${PROJECT_NAME}_unit_test PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/deps/doctest"
"${PROJECT_SOURCE_DIR}/deps/gcem/include"
"${PROJECT_SOURCE_DIR}/deps/nanobench/src/include")
target_compile_features(${PROJECT_NAME}_unit_test PRIVATE cxx_std_20)
# set_property(TARGET ${PROJECT_NAME}_unit_test PROPERTY COMPILE_WARNING_AS_ERROR ON)
# 启用代码覆盖率测试
if ((CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "debug") AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
target_compile_options(${PROJECT_NAME}_unit_test PRIVATE --coverage)
target_link_options(${PROJECT_NAME}_unit_test PRIVATE --coverage)
endif()
if(WIN32)
target_compile_definitions(${PROJECT_NAME}_unit_test PUBLIC _CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS UNICODE _UNICODE NOMINMAX)
endif()
if(UNIX)
target_link_options(${PROJECT_NAME}_unit_test PRIVATE "-ldl")
endif()
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(${PROJECT_NAME}_unit_test PUBLIC OpenMP::OpenMP_CXX)
endif()
add_test(NAME unit_test COMMAND ${PROJECT_NAME}_unit_test)
add_test(NAME benchmark COMMAND ${PROJECT_NAME}_unit_test -ns -ts=benchmark)
endif()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/ShenMian/Math.git
git@gitee.com:ShenMian/Math.git
ShenMian
Math
math
main

搜索帮助