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>
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>
* [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>
* [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>
* 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
* 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
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.
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.
* 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
* 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
`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.
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
* 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.
* 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.
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)