1 Star 0 Fork 0

zhangy/safe_numerics

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 4.88 KB
一键复制 编辑 原始数据 按行查看 历史
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# Generated by `boostdep --cmake safe_numerics`
# Copyright 2020, 2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.8...3.20)
project(boost_safe_numerics VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_safe_numerics INTERFACE)
add_library(Boost::safe_numerics ALIAS boost_safe_numerics)
target_include_directories(boost_safe_numerics INTERFACE include)
target_link_libraries(boost_safe_numerics
INTERFACE
Boost::concept_check
Boost::config
Boost::core
Boost::integer
Boost::logic
Boost::mp11
)
target_compile_features(boost_safe_numerics INTERFACE cxx_std_14)
else()
# CMake build control file for safe numerics Library Examples
cmake_minimum_required(VERSION 3.8.6)
project("SafeIntegers")
enable_language(CXX)
########################################################
# Create interface library
#
add_library(boost_safe_numerics INTERFACE)
add_library(Boost::safe_numerics ALIAS boost_safe_numerics)
target_include_directories(boost_safe_numerics INTERFACE "${Boost_INCLUDE_DIRS}")
target_compile_features(boost_safe_numerics INTERFACE cxx_std_14)
########################################################
# Compiler settings - special settings for known compilers
#
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
message(STATUS "compiler is ${CMAKE_CXX_COMPILER_ID}" )
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
add_compile_options(-Wnon-virtual-dtor -ansi -Wcast-align -Wchar-subscripts -Wall -Wextra -W -Wshadow -Wsign-compare )
add_compile_options( -ftemplate-depth=255 )
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
# warning level 4 and all warnings as errors
add_compile_options(/W4 /WX /wd4996 /wd4068)
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
add_compile_options(-Wnon-virtual-dtor -ansi -Wcast-align -Wchar-subscripts -Wall -Wextra -W -Wshadow -Wsign-compare )
add_compile_options( -ftemplate-depth=255 )
add_compile_options( -fbracket-depth=2048 )
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
add_compile_options(-Wnon-virtual-dtor -ansi -Wcast-align -Wchar-subscripts -Wall -Wextra -W -Wshadow -Wsign-compare )
add_compile_options( -ftemplate-depth=255 )
add_compile_options( -fbracket-depth=2048 )
endif()
#
# Project settings
#
find_package(Boost )
if(Boost_FOUND)
if( CMAKE_HOST_APPLE )
set(Boost_ADDRESS_MODEL 64 CACHE STRING "32/64 bits")
endif()
message(STATUS "Boost directories found at ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost version found is ${Boost_VERSION}")
include_directories("${Boost_INCLUDE_DIRS}") # note: sets header search path?
elseif()
message("Boost NOT Found!")
endif()
message(STATUS "include directories are:" )
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
message(STATUS " ${dir}")
endforeach()
#use folders in organization of the IDE
set(USE_FOLDERS TRUE)
###########################
# testing and submitting test results to the test dashboard
if(0)
## Create a file named CTestConfig.cmake adjacent to the current file.
## This new file should contain the following:
set(CTEST_PROJECT_NAME "Safe Numerics")
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "my.cdash.org")
# set(CTEST_DROP_LOCATION "/cdash/submit.php?project=MyProject")
set(CTEST_DROP_LOCATION "/index.php?project=Safe+Numerics")
set(CTEST_DROP_SITE_CDASH TRUE)
endif()
function(test_run_pass base_name )
message(STATUS ${base_name})
add_executable(${base_name} ${base_name}.cpp)
add_test(NAME ${base_name} COMMAND ${base_name})
endfunction(test_run_pass)
function(test_compile_pass base_name )
message(STATUS ${base_name} - compile only)
add_library(${base_name} OBJECT ${base_name})
endfunction(test_compile_pass)
function(test_compile_fail base_name )
message(STATUS ${base_name})
# Add failing-to-compile targets
add_executable(${base_name} ${base_name}.cpp)
# Avoid building these targets normally
set_target_properties(${base_name} PROPERTIES
EXCLUDE_FROM_ALL TRUE
EXCLUDE_FROM_DEFAULT_BUILD TRUE
)
# Add the tests. These invoke "cmake --build ..." which is a
# cross-platform way of building the given target.
add_test(NAME ${base_name}
COMMAND ${CMAKE_COMMAND} --build . --target ${base_name} --config $<CONFIGURATION>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
# Expect these tests to fail
# (i.e. cmake --build should return a non-zero value)
set_tests_properties(${base_name} PROPERTIES WILL_FAIL TRUE)
endfunction( test_compile_fail base_name )
########################################################
# End Compiler settings
#
enable_testing()
add_subdirectory("include/boost/safe_numerics")
add_subdirectory("example")
add_subdirectory("test")
endif()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zhang1021/safe_numerics.git
git@gitee.com:zhang1021/safe_numerics.git
zhang1021
safe_numerics
safe_numerics
master

搜索帮助