2020-01-13 17:11:20 -05:00
|
|
|
cmake_minimum_required(VERSION 3.1.3...3.16)
|
2015-08-20 21:09:14 -04:00
|
|
|
|
2020-11-16 17:05:33 -05:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
|
|
|
include(guidelineSupportLibrary)
|
|
|
|
|
2021-01-05 14:55:13 -05:00
|
|
|
project(GSL
|
|
|
|
VERSION 3.1.0
|
|
|
|
LANGUAGES CXX
|
|
|
|
)
|
2021-01-04 17:17:03 -05:00
|
|
|
|
2020-11-16 17:05:33 -05:00
|
|
|
# Creates a library GSL which is an interface (header files only)
|
2017-04-25 20:08:36 -04:00
|
|
|
add_library(GSL INTERFACE)
|
|
|
|
|
2020-11-16 17:05:33 -05:00
|
|
|
# NOTE: If you want to use GSL prefer to link against GSL using this alias target
|
|
|
|
# EX:
|
|
|
|
# target_link_libraries(foobar PRIVATE Microsoft.GSL::GSL)
|
|
|
|
#
|
|
|
|
# Add Microsoft.GSL::GSL alias for GSL so that dependents can be agnostic about
|
|
|
|
# whether GSL was added via `add_subdirectory` or `find_package`
|
|
|
|
add_library(Microsoft.GSL::GSL ALIAS GSL)
|
|
|
|
|
|
|
|
# Determine whether this is a standalone project or included by other projects
|
2017-09-06 20:50:30 -04:00
|
|
|
set(GSL_STANDALONE_PROJECT OFF)
|
|
|
|
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
2020-05-04 16:31:08 -04:00
|
|
|
set(GSL_STANDALONE_PROJECT ON)
|
2018-06-07 16:36:56 -04:00
|
|
|
endif()
|
|
|
|
|
2021-01-05 14:55:13 -05:00
|
|
|
### Project options
|
|
|
|
option(GSL_INSTALL "Generate and install GSL target" ${GSL_STANDALONE_PROJECT})
|
|
|
|
option(GSL_TEST "Build and perform GSL tests" ${GSL_STANDALONE_PROJECT})
|
|
|
|
|
2020-11-16 17:05:33 -05:00
|
|
|
# This GSL implementation generally assumes a platform that implements C++14 support.
|
|
|
|
set(gsl_min_cxx_standard "14")
|
2018-06-15 13:13:11 -04:00
|
|
|
|
2020-11-16 17:05:33 -05:00
|
|
|
if (GSL_STANDALONE_PROJECT)
|
|
|
|
gsl_set_default_cxx_standard(${gsl_min_cxx_standard})
|
|
|
|
else()
|
|
|
|
gsl_client_set_cxx_standard(${gsl_min_cxx_standard})
|
2017-04-25 20:08:36 -04:00
|
|
|
endif()
|
|
|
|
|
2021-01-08 12:56:04 -05:00
|
|
|
# Setup include directory
|
|
|
|
add_subdirectory(include)
|
2018-11-28 18:37:59 -05:00
|
|
|
|
2020-12-15 13:06:46 -05:00
|
|
|
# Add natvis file
|
|
|
|
gsl_add_native_visualizer_support()
|
2017-04-25 20:08:36 -04:00
|
|
|
|
2021-01-05 14:55:13 -05:00
|
|
|
# Add packaging support
|
|
|
|
gsl_create_packaging_file()
|
2015-11-21 14:13:21 -05:00
|
|
|
|
2021-01-05 14:55:13 -05:00
|
|
|
if (GSL_INSTALL)
|
|
|
|
# Setup install/export logic
|
|
|
|
gsl_install_logic()
|
2020-06-06 14:42:51 -04:00
|
|
|
endif()
|
2020-04-26 07:37:54 -04:00
|
|
|
|
2017-09-06 20:50:30 -04:00
|
|
|
if (GSL_TEST)
|
2020-05-04 16:31:08 -04:00
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(tests)
|
2020-12-15 13:06:46 -05:00
|
|
|
endif()
|