diff options
author | Jordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com> | 2021-01-05 01:17:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-05 01:17:03 +0300 |
commit | 25bb4bd9489a28b72a77c016b7ac0c64345a7c88 (patch) | |
tree | 6262bc20b1c17be1476fb3b54451ec52d1d3f73c | |
parent | 1c509ad8e137813d99e23a06dbb3413bedc924a1 (diff) |
Revert "[cmake] Adding options for INSTALL and TEST (#964)" (#966)
This reverts commit eca0eca6f1ae12c80f73bdfb73bbcf912289fe34.
-rw-r--r-- | CMakeLists.txt | 63 | ||||
-rw-r--r-- | cmake/guidelineSupportLibrary.cmake | 55 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 4 |
3 files changed, 48 insertions, 74 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bb66444..7ad13f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,10 @@ 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 -) +project(GSL VERSION 3.1.0 LANGUAGES CXX) + +# Use GNUInstallDirs to provide the right locations on all platforms +include(GNUInstallDirs) # Creates a library GSL which is an interface (header files only) add_library(GSL INTERFACE) @@ -25,10 +25,6 @@ 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") @@ -38,21 +34,58 @@ else() gsl_client_set_cxx_standard(${gsl_min_cxx_standard}) endif() -# Setup the include directory -gsl_target_include_directories(${GSL_STANDALONE_PROJECT}) +# add include folders to the library and targets that consume it +# the SYSTEM keyword suppresses warnings for users of the library +if(GSL_STANDALONE_PROJECT) + target_include_directories(GSL INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> + ) +else() + target_include_directories(GSL SYSTEM INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> + ) +endif() # Add natvis file gsl_add_native_visualizer_support() -# Add packaging support -gsl_create_packaging_file() +install(TARGETS GSL EXPORT Microsoft.GSLConfig) +install( + DIRECTORY include/gsl + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) +# Make library importable by other projects +install(EXPORT Microsoft.GSLConfig NAMESPACE Microsoft.GSL:: DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Microsoft.GSL) +export(TARGETS GSL NAMESPACE Microsoft.GSL:: FILE Microsoft.GSLConfig.cmake) -if (GSL_INSTALL) - # Setup install/export logic - gsl_install_logic() +# Add find_package() versioning support. The version for +# generated Microsoft.GSLConfigVersion.cmake will be used from +# last project() command. The version's compatibility is set between all +# minor versions (as it was in prev. GSL releases). +include(CMakePackageConfigHelpers) +if(${CMAKE_VERSION} VERSION_LESS "3.14.0") + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake + COMPATIBILITY SameMajorVersion + ) +else() + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake + COMPATIBILITY SameMajorVersion + ARCH_INDEPENDENT + ) endif() +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Microsoft.GSL) +option(GSL_TEST "Generate tests." ${GSL_STANDALONE_PROJECT}) if (GSL_TEST) enable_testing() + if(IOS) + add_compile_definitions( + GTEST_HAS_DEATH_TEST=1 + ) + endif() add_subdirectory(tests) endif() diff --git a/cmake/guidelineSupportLibrary.cmake b/cmake/guidelineSupportLibrary.cmake index 2e72100..39d8920 100644 --- a/cmake/guidelineSupportLibrary.cmake +++ b/cmake/guidelineSupportLibrary.cmake @@ -9,9 +9,6 @@ if (DEFINED guideline_support_library_include_guard) endif() set(guideline_support_library_include_guard ON) -# Neccessary for 'write_basic_package_version_file' -include(CMakePackageConfigHelpers) - function(gsl_set_default_cxx_standard min_cxx_standard) set(GSL_CXX_STANDARD "${min_cxx_standard}" CACHE STRING "Use c++ standard") @@ -78,55 +75,3 @@ function(gsl_add_native_visualizer_support) endif() endif() endfunction() - -function(gsl_target_include_directories is_standalone) - # Add include folders to the library and targets that consume it - # the SYSTEM keyword suppresses warnings for users of the library - if(${is_standalone}) - target_include_directories(GSL INTERFACE - $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> - $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> - ) - else() - target_include_directories(GSL SYSTEM INTERFACE - $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> - $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> - ) - endif() -endfunction() - -function(gsl_install_logic) - # Use GNUInstallDirs to provide the right locations on all platforms - # NOTE: Including GNUInstallDirs automatically executes logic - include(GNUInstallDirs) - - install(TARGETS GSL EXPORT Microsoft.GSLConfig) - install( - DIRECTORY include/gsl - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - ) - # Make library importable by other projects - install(EXPORT Microsoft.GSLConfig NAMESPACE Microsoft.GSL:: DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Microsoft.GSL) - export(TARGETS GSL NAMESPACE Microsoft.GSL:: FILE Microsoft.GSLConfig.cmake) - - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Microsoft.GSL) -endfunction() - -# Add find_package() versioning support. The version for -# generated Microsoft.GSLConfigVersion.cmake will be used from -# last project() command. The version's compatibility is set between all -# minor versions (as it was in prev. GSL releases). -function(gsl_create_packaging_file) - if(${CMAKE_VERSION} VERSION_LESS "3.14.0") - write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake - COMPATIBILITY SameMajorVersion - ) - else() - write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/Microsoft.GSLConfigVersion.cmake - COMPATIBILITY SameMajorVersion - ARCH_INDEPENDENT - ) - endif() -endfunction() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1c7b03e..2e7c2dc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,10 +10,6 @@ find_package(Git REQUIRED QUIET) # will make visual studio generated project group files set_property(GLOBAL PROPERTY USE_FOLDERS ON) -if(IOS) - add_compile_definitions(GTEST_HAS_DEATH_TEST=1) -endif() - pkg_search_module(GTestMain gtest_main) if (NOT GTestMain_FOUND) configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) |