From 4897c30c479ef8c9ee0fc5ace2d6d4407fd7484f Mon Sep 17 00:00:00 2001 From: Lars Melchior Date: Wed, 15 Apr 2020 08:56:52 +0200 Subject: [PATCH] enforce standards conformance on MSVC --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2332cd..2913c6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ project(Greeter # ---- Include guards ---- -if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR}) +if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.") endif() @@ -35,17 +35,20 @@ CPMAddPackage( # ---- Create library ---- -# Note: for single header libraries create an interface target instead: +# Note: for header-only libraries change all PUBLIC flags to INTERFACE and create an interface target: # add_library(Greeter INTERFACE) # set_target_properties(Greeter PROPERTIES INTERFACE_COMPILE_FEATURES cxx_std_17) add_library(Greeter ${headers} ${sources}) + set_target_properties(Greeter PROPERTIES CXX_STANDARD 17) +# beeing a cross-platform target, we enforce enforce standards conformance on MSVC +target_compile_options(Greeter PUBLIC "$<$:/permissive->") + # Link dependencies (if required) # target_link_libraries(Greeter PUBLIC cxxopts) -# Note: change PUBLIC to INTERFACE for single header libraries target_include_directories(Greeter PUBLIC $