Add CMake example

This commit is contained in:
Alex Hirsch
2020-11-26 21:56:26 +01:00
parent eb0ea94898
commit 353e06c941
10 changed files with 17982 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
# Note that functions are also prefixed with the project name to prevent
# collisions.
function(mylib_cxx_flags target)
# Instead of setting a specific standard directly, we use the *compile
# features* to require (at least) C++17 standard.
target_compile_features(${target} PRIVATE cxx_std_17)
# Furthermore, we turn off compiler extensions.
set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF)
# We enable some warnings, although only if we know the compiler actually
# supports these flags. The `$<...>` syntax is a *generator expression*.
target_compile_options(${target} PRIVATE
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wall -Wextra -pedantic>)
endfunction()