Commit Graph

47 Commits

Author SHA1 Message Date
jpr89
84aeb59f26
Fixing cmake developer warning (#972)
Here is the warning currently being produced:

CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.19/Modules/GNUInstallDirs.cmake:223 (message):
  Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
  target architecture is known.  Please enable at least one language before
  including GNUInstallDirs.
Call Stack (most recent call first):
  cmake/guidelineSupportLibrary.cmake:20 (include)
  CMakeLists.txt:4 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

I noted how I fixed the error. This is caused by GNUInstallDirs automatically executing code just by including it.

I also added -Werror=dev to the CI to ensure this never happens again.

Co-authored-by: Juan Ramos <juanr0911@gmail.com>
2021-01-19 13:41:25 -08:00
hdf89shfdfs
d0052f6320
Minor cmake nitpicks (#969)
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>
2021-01-08 09:56:04 -08:00
Jordan Maples [MSFT]
e427b02c89
Reintroduce CMake changes that were reverted in #966 (#967)
* [cmake] Adding options for INSTALL and TEST (#964)

* [cmake] Adding GSL_INSTALL option

Not all consumers of GSL automatically want to have this install logic.

It's good practice to gate install logic behind an option.
For an example look at magic_enum:
https://github.com/Neargye/magic_enum/blob/master/CMakeLists.txt

If the client wants to install GSL they still can. But they should ask
for it by overriding GSL_INSTALL.

* Update cmake/guidelineSupportLibrary.cmake

added nl@eof

* Update CMakeLists.txt

* Update CMakeLists.txt

Co-authored-by: Juan Ramos <juanr0911@gmail.com>
Co-authored-by: Jordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com>

* missing config line restored by moving GNUInstallDirs back to main file

Co-authored-by: hdf89shfdfs <31327577+hdf89shfdfs@users.noreply.github.com>
Co-authored-by: Juan Ramos <juanr0911@gmail.com>
2021-01-05 11:55:13 -08:00
Jordan Maples [MSFT]
25bb4bd948
Revert "[cmake] Adding options for INSTALL and TEST (#964)" (#966)
This reverts commit eca0eca6f1.
2021-01-04 14:17:03 -08:00
hdf89shfdfs
eca0eca6f1
[cmake] Adding options for INSTALL and TEST (#964)
* [cmake] Adding GSL_INSTALL option

Not all consumers of GSL automatically want to have this install logic.

It's good practice to gate install logic behind an option.
For an example look at magic_enum:
https://github.com/Neargye/magic_enum/blob/master/CMakeLists.txt

If the client wants to install GSL they still can. But they should ask
for it by overriding GSL_INSTALL.

* Update cmake/guidelineSupportLibrary.cmake

added nl@eof

* Update CMakeLists.txt

* Update CMakeLists.txt

Co-authored-by: Juan Ramos <juanr0911@gmail.com>
Co-authored-by: Jordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com>
2021-01-04 10:42:33 -08:00
hdf89shfdfs
d15cb5fdbe
Minor cmake changes (#961)
Abstract adding natvis file.

Move call to find_package(Git) as well as making it required/quiet.
2020-12-15 10:06:46 -08:00
hdf89shfdfs
ec6cd75d57
Remove unneccesssary compile definitions (#957) 2020-12-02 14:12:38 -08:00
hdf89shfdfs
475b785d2c
Use CMAKE_CXX_STANDARD when available (#953)
* Use CMAKE_CXX_STANDARD when available

If the use has provided the variable CMAKE_CXX_STANDARD use that instead of providing a default cache variable.

* Typo
2020-11-16 14:05:33 -08:00
Jordan Maples
cfb4db0c1e added GSL_ prefix to VS_ADD_NATIVE_VISUALIZERS 2020-10-22 15:40:27 -07:00
Vitaly Zaitsev
cfe9baf02e
Added ARCH_INDEPENDENT parameter to write_basic_package_version_file().
Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>
2020-06-07 16:02:27 +02:00
Jordan Maples
78744ed530 update cmake project version to reflect upcoming GSL 3.1.0 release 2020-06-03 16:52:20 -07:00
Jordan Maples [MSFT]
0843ea444f
Merge pull request #884 from dipidoo/master
reflects verification of iOS and Android support
2020-05-08 09:57:45 -07:00
Bas Hendri
91858ca3f3 forces GTEST_HAS_DEATH_TEST 2020-05-04 13:31:08 -07:00
leha-bot
de053645bb CMakeLists: Drop ARCH_INDEPENDENT as it does not supported via old CMake 2020-04-28 13:07:41 +03:00
Alex
879335cebf CMakeLists: add VERSION to project() and package
So the library consumers via find_package(Microsoft.GSL 3.0.2) could determine the actual library version.
2020-04-26 18:09:49 +03:00
Vitaly Zaitsev
aeb65efada
Fixed installation on GNU/Linux distributions.
Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>
2020-04-17 11:47:23 +02:00
Roelf-Jilling
30c068781f Merge branch 'master' into TravisCI 2020-03-26 16:24:19 +01:00
Hannes Steffenhagen
9c0c6b246c Add Microsoft.GSL::GSL alias for GSL
This ensures that dependents can be agnostic about
whether GSL was added via `add_subdirectory` or `find_package`
2020-02-08 12:58:25 +00:00
Hannes Steffenhagen
886fc95142 Remove PUBLIC_HEADER attribute from install command
Since we already explicitly install `include/gsl`, this
doesn’t do anything.
2020-02-08 12:55:19 +00:00
Hannes Steffenhagen
ebe8844344 Make GSL includes based on CMAKE_INSTALL_INCLUDEDIR
This is to avoid inconsistencies with the `install`
command which specifies this as the destination for includes.
2020-02-08 12:53:40 +00:00
Roelf-Jilling
5caf336e02 TravisCI: validate CMake configuration with all supported releases 2020-01-16 17:55:58 +01:00
Hannes Steffenhagen
0551cad467 Merge branch 'master' into hunterization 2019-05-09 18:09:21 +01:00
k-brac
be3c3c2731 Fixes CMAKE_VERSION check (#759)
* Fixes CMAKE_VERSION check

Fixes #758 by using the correct comparison operator for a version
See documentation at https://cmake.org/cmake/help/latest/command/if.html
Thanks to this change, gsl natvis is properly included in a visual studio solution

* cmake version check for cmake < 3.7
2019-01-14 16:43:17 -08:00
hannesweisbach
0f68d133fa Suppress Warnings in GSL Headers (#731)
Suppress warnings in GSL headers using the SYSTEM keyword for target_include_directories(). This enables developers to see warnings standalone builds but hides them from users in non-standalone builds.
2018-11-28 15:37:59 -08:00
Stefan Reinhold
e3ffe1c5cb Fix naming of exported CMake configuration file 2018-07-17 17:56:11 +02:00
Stefan Reinhold
e2b57d16f9 Export target GSL in namespace Microsoft.GSL
This is to avoid conflicts with GNU Scientific Library which also has an
exported target named GSL.
2018-07-17 17:43:54 +02:00
Stefan Reinhold
9e1645b990 Do not install .natvis files.
This fixes an issue where CMake complains about INTERFACE_SOURCES
containing a path which is prefixed in source directory on windows.
2018-07-17 13:07:27 +02:00
Stefan Reinhold
0a31a14d09 Fix INSTALL_INTERFACE for exported target
CMake war reporting: 'Target "GSL" INTERFACE_SOURCES property contains
path: "..." which is prefixed in the source directory'.
CMake was confused because the $<BUILD_INTERFACE: ...> had linebreaks
in it.
Putting everything in one line fixed the issue.
2018-07-17 11:56:38 +02:00
Stefan Reinhold
030454e3e9 Fix for Windows: CMake complains about INTERFACE_SOURCES directory 2018-07-17 11:09:58 +02:00
Stefan Reinhold
d452c3b061 Make library importable by CMake using find_package 2018-07-17 10:23:44 +02:00
Anna Gringauze
21cb6bb8b0
Added testing for c++17 to latest compilers with test with (#692)
* Added testing with std=c++17 for latest compilers

Added running latest compilers with -std=c++17 option to CI the test matrix,
Updated cmake configuration to allow passing c++ standard on the command line.

* attempt to fix appveyor break

* added clang6.0, removed c++17 tests for clang 5.0

* commented out tests for clang with c++17 die to issue #695

* Addresed comments
2018-06-15 10:13:11 -07:00
Anna Gringauze
cb2d1af89a
Added template argument deduction for not_null (#689)
* Added template  argument deduction for not_null

This allows compilers with c++17 support to infer template
instantiation types when calling not_null constructor:

    int foo(not_null<const int*> x);

    int main()
    {
        int t = 0;
        not_null x{ &t };
        return foo(not_null{ &t });
    }

* replaced deduction guides by a simple constructor

* Updated tests

* fixed check for availability of std::byte

* testing c++1z on clang

* fixed cmakelists extra endif

* include cstddef header for clang and gcc in pointers

* fixed a typo

* fix missing nullptr_t type

* fixed typo in CMakeLists.tst

* change approach to c++17 testing, step one: revert cmake testing, update clang5.0 package

removed using latest c++ due to clang5.0 failing,
update clang5.0 travis config to use llvm-toolchain-trusty-5.0

* addressed comments
2018-06-07 13:36:56 -07:00
Rian Quinn
d933e51b8b v2.0 Patch (#641)
Signed-off-by: Rian Quinn <rianquinn@gmail.com>
2018-04-27 12:56:25 -07:00
Jérémie Delaitre
30b1641ff4 Fix wrong check of the CMAKE_VERSION (#602)
`CMAKE_VERSION_MAJOR` is just the first component of the CMake version (e.g. 3 for 3.10.1) which compares less than `3.7.9` if it is less than 3. The proper variable to compare is `CMAKE_VERSION` which contains the full version number.
2018-02-13 17:26:44 -08:00
paweldac
210cc08a49 Visual Studio Debug Visualizers support (#575)
changes:
    - minimal cmake version updated to 3.7(first version with .natvis file handling)
    - updated cmake version in readme file
    - GSL.natvis file is added only to VS projects
2017-11-28 07:31:06 -08:00
bfierz
b01450878b Adds an option to disable test generation (#552)
When integrating the GSL as an external dependency, it is usually unnecessary to build and run the unit-tests.
2017-09-06 17:50:30 -07:00
Nicholas Guriev
e249f861e3 Allow to use system version of the catch test framework (#549) 2017-08-16 19:00:30 -07:00
Neil MacIntosh
b2ee484334 Move from unittest-cpp to catch for unit testing. (#533)
Many thanks to @rianquinn. This should fix #495, #494 and #529.
2017-07-13 13:53:56 -07:00
Tiago
8b320e3f5d Update CMake usage (#493)
* Refactor cmake file to have GSL as an interface

CMake supports header only libraries as INTERFACE libraries. Using
interfaces libraries make is easier for users to use the library because
one just need to "link" agaisnt the library and necessary include paths,
definitions, flags... will be taken care of.

This commit creates a new interface library called GSL. It then add the
following things to the GSL library:
- compiler flags ex: (-std=c++14)
- definitions ex: _SCL_SECURE_NO_WARNINGS
- include paths ex: include/gsl
- natvis file

Another project can now have the GSL project as a git submodule and one
only need to add the two following lines to their project to use the
GSL.
add_subdirectory(GSL)
target_link_libraries(<some target> GSL)

After cmake 3.8.0 a lot of the logic can be simplified. Right now the
cmake file has an if for version checking, but when the minimun required
version is 3.8.0 one can just delete the branching and keep the simpler
version.

* Cut support for c++11

Compiling on GCC6.2 with only the c++11 flag will generate compilation
errors. For example some of the errors are related to the use of
enable_if_t which is a c++14 feature.

To avoid compilation errors this comiit removes c++11 support on linux.

* Refactor code that pulls unittest-cpp

Two minor changes:
- uses cmake to find a proper installation of git (in case user does not
have it on the path)
- checks for the CMakeLists file instead. This is needed for the build
itself and seems like a better way to do the checking

* Refactor tests so they show together on VS

This commit will make a VS geenrated project to group all tests under
GSL_tests

* Refactor tests configuration

This creates a test configuration interface and add all the previous
compiler options to that interface. compiler options are now sorted so
it is easier to find them, and also one per line, so that modifications
are easier to track from git.
2017-04-25 17:08:36 -07:00
Casey Carter
4e8f95b418 Cleanup include structure, constexpr and noexcept compiler workarounds.
* Nest "gsl" directory inside a new "include" directory.

* Cleanup the _MSC_VER conditionals a bit; use constexpr on VS2017+.

* Don't #define noexcept on non-Microsoft implementations.

* Workaround VS2017 bug in multi_span. (Also implement == and != for static_bounds_dynamic_range_t because I'm an EoP semantic soundness snob.)

Fixes #441.
2017-02-07 15:59:37 -08:00
MikeGitb
d2dafe2ddf Add a copy() function for span. 2016-11-17 10:45:06 -08:00
Neil MacIntosh
a8c5004b70 Update CMakeLists.txt 2016-08-24 10:01:42 -07:00
Galik
222c2d85fd Removed .h extension from header files. 2016-08-10 17:24:00 +01:00
galik
f6cc5798a1 Renamed include/ folder to gsl/ to make including the library consistent
whether using it from the development folder, from the installation
folder or from being copied into a project. 

    #include <gsl/gsl.h>

Updated headers/tests/instructions/cmake build accordingly

This PR should address https://github.com/Microsoft/GSL/issues/277 (less
the renaming of gsl itself)
2016-08-09 15:04:58 +01:00
Jason Horsburgh
7505111329 Add CMake install target for header files 2015-11-21 19:37:21 +00:00
Tamas Kenez
9b454b7a9b add travis testing (gcc5, clang36)
- also relaxed CMake version to 2.8.7, the version default in travis
2015-09-23 17:43:36 +02:00
Neil MacIntosh
a9dcbe04ff Initial commit of library files. 2015-08-20 18:09:14 -07:00