mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
d0052f6320
It's much nicer and less error prone to just use add_subdirectory to establish the include directory. Hide the GNUInstallDirs module by placing it in the helper module. The intent being that the main CMakeLists.txt should have a little code as possible. So that readers can quickly understand the project. Use include_guard() when available in cmake 3.10+ Co-authored-by: Juan Ramos <juanr0911@gmail.com>
59 lines
1.6 KiB
CMake
59 lines
1.6 KiB
CMake
cmake_minimum_required(VERSION 3.1.3...3.16)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
|
include(guidelineSupportLibrary)
|
|
|
|
project(GSL
|
|
VERSION 3.1.0
|
|
LANGUAGES CXX
|
|
)
|
|
|
|
# Creates a library GSL which is an interface (header files only)
|
|
add_library(GSL INTERFACE)
|
|
|
|
# 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
|
|
set(GSL_STANDALONE_PROJECT OFF)
|
|
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|
set(GSL_STANDALONE_PROJECT ON)
|
|
endif()
|
|
|
|
### Project options
|
|
option(GSL_INSTALL "Generate and install GSL target" ${GSL_STANDALONE_PROJECT})
|
|
option(GSL_TEST "Build and perform GSL tests" ${GSL_STANDALONE_PROJECT})
|
|
|
|
# This GSL implementation generally assumes a platform that implements C++14 support.
|
|
set(gsl_min_cxx_standard "14")
|
|
|
|
if (GSL_STANDALONE_PROJECT)
|
|
gsl_set_default_cxx_standard(${gsl_min_cxx_standard})
|
|
else()
|
|
gsl_client_set_cxx_standard(${gsl_min_cxx_standard})
|
|
endif()
|
|
|
|
# Setup include directory
|
|
add_subdirectory(include)
|
|
|
|
# Add natvis file
|
|
gsl_add_native_visualizer_support()
|
|
|
|
# Add packaging support
|
|
gsl_create_packaging_file()
|
|
|
|
if (GSL_INSTALL)
|
|
# Setup install/export logic
|
|
gsl_install_logic()
|
|
endif()
|
|
|
|
if (GSL_TEST)
|
|
enable_testing()
|
|
add_subdirectory(tests)
|
|
endif()
|