diff --git a/CMakeLists.txt b/CMakeLists.txt index a14d173..64ae165 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,9 +8,6 @@ project(GSL 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) @@ -41,8 +38,8 @@ else() gsl_client_set_cxx_standard(${gsl_min_cxx_standard}) endif() -# Setup the include directory -gsl_target_include_directories(${GSL_STANDALONE_PROJECT}) +# Setup include directory +add_subdirectory(include) # Add natvis file gsl_add_native_visualizer_support() diff --git a/cmake/guidelineSupportLibrary.cmake b/cmake/guidelineSupportLibrary.cmake index bf24a79..341ba66 100644 --- a/cmake/guidelineSupportLibrary.cmake +++ b/cmake/guidelineSupportLibrary.cmake @@ -4,14 +4,21 @@ # for multiple versions of cmake. # # Any functions/macros should have a gsl_* prefix to avoid problems -if (DEFINED guideline_support_library_include_guard) - return() +if (CMAKE_VERSION VERSION_GREATER 3.10 OR CMAKE_VERSION VERSION_EQUAL 3.10) + include_guard() +else() + if (DEFINED guideline_support_library_include_guard) + return() + endif() + set(guideline_support_library_include_guard ON) endif() -set(guideline_support_library_include_guard ON) # Necessary for 'write_basic_package_version_file' include(CMakePackageConfigHelpers) +# Use GNUInstallDirs to provide the right locations on all platforms +include(GNUInstallDirs) + function(gsl_set_default_cxx_standard min_cxx_standard) set(GSL_CXX_STANDARD "${min_cxx_standard}" CACHE STRING "Use c++ standard") @@ -79,22 +86,6 @@ function(gsl_add_native_visualizer_support) 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 - $ - $ - ) - else() - target_include_directories(GSL SYSTEM INTERFACE - $ - $ - ) - endif() -endfunction() - function(gsl_install_logic) install(TARGETS GSL EXPORT Microsoft.GSLConfig) install( diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..ab90344 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,20 @@ + +# Add include folders to the library and targets that consume it +# the SYSTEM keyword suppresses warnings for users of the library +# +# By adding this directory as an include directory the user gets a +# namespace effect. +# +# IE: +# #include +if(GSL_STANDALONE_PROJECT) + target_include_directories(GSL INTERFACE + $ + $ + ) +else() + target_include_directories(GSL SYSTEM INTERFACE + $ + $ + ) +endif()