From d15cb5fdbe0f9ef0cb896311891dbe7903bbe674 Mon Sep 17 00:00:00 2001 From: hdf89shfdfs <31327577+hdf89shfdfs@users.noreply.github.com> Date: Tue, 15 Dec 2020 13:06:46 -0500 Subject: [PATCH] Minor cmake changes (#961) Abstract adding natvis file. Move call to find_package(Git) as well as making it required/quiet. --- CMakeLists.txt | 22 +++------------------- cmake/guidelineSupportLibrary.cmake | 16 ++++++++++++++++ tests/CMakeLists.txt | 4 ++++ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f44425c..7ad13f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,6 @@ include(guidelineSupportLibrary) project(GSL VERSION 3.1.0 LANGUAGES CXX) -include(ExternalProject) -find_package(Git) - # Use GNUInstallDirs to provide the right locations on all platforms include(GNUInstallDirs) @@ -51,21 +48,8 @@ else() ) endif() - -if (CMAKE_VERSION VERSION_GREATER 3.7.8) - if (MSVC_IDE) - option(GSL_VS_ADD_NATIVE_VISUALIZERS "Configure project to use Visual Studio native visualizers" TRUE) - else() - set(GSL_VS_ADD_NATIVE_VISUALIZERS FALSE CACHE INTERNAL "Native visualizers are Visual Studio extension" FORCE) - endif() - - # add natvis file to the library so it will automatically be loaded into Visual Studio - if(GSL_VS_ADD_NATIVE_VISUALIZERS) - target_sources(GSL INTERFACE - $ - ) - endif() -endif() +# Add natvis file +gsl_add_native_visualizer_support() install(TARGETS GSL EXPORT Microsoft.GSLConfig) install( @@ -104,4 +88,4 @@ if (GSL_TEST) ) endif() add_subdirectory(tests) -endif () +endif() diff --git a/cmake/guidelineSupportLibrary.cmake b/cmake/guidelineSupportLibrary.cmake index e29e80c..39d8920 100644 --- a/cmake/guidelineSupportLibrary.cmake +++ b/cmake/guidelineSupportLibrary.cmake @@ -59,3 +59,19 @@ function(gsl_client_set_cxx_standard min_cxx_standard) # Otherwise pick a reasonable default gsl_set_default_cxx_standard(${min_cxx_standard}) endfunction() + +# Adding the GSL.natvis files improves the debugging experience for users of this library. +function(gsl_add_native_visualizer_support) + if (CMAKE_VERSION VERSION_GREATER 3.7.8) + if (MSVC_IDE) + option(GSL_VS_ADD_NATIVE_VISUALIZERS "Configure project to use Visual Studio native visualizers" TRUE) + else() + set(GSL_VS_ADD_NATIVE_VISUALIZERS FALSE CACHE INTERNAL "Native visualizers are Visual Studio extension" FORCE) + endif() + + # add natvis file to the library so it will automatically be loaded into Visual Studio + if(GSL_VS_ADD_NATIVE_VISUALIZERS) + target_sources(GSL INTERFACE $) + endif() + endif() +endfunction() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c323961..2e7c2dc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,7 +1,11 @@ cmake_minimum_required(VERSION 3.0.2) project(GSLTests CXX) + include(FindPkgConfig) +include(ExternalProject) + +find_package(Git REQUIRED QUIET) # will make visual studio generated project group files set_property(GLOBAL PROPERTY USE_FOLDERS ON)