From a1c390ea3129089ad0e7472022e1becac83b9e52 Mon Sep 17 00:00:00 2001 From: Mikael Olenfalk Date: Sat, 21 Mar 2020 16:13:14 +0100 Subject: [PATCH] Require C++17 and force MSVC to treat source as UTF-8 Co-authored-by: Mikael Olenfalk Co-authored-by: ArthurSonzogni --- CMakeLists.txt | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 60287c4..90803ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,16 +69,32 @@ target_link_libraries(component PUBLIC dom Threads::Threads) foreach(lib screen dom component) target_include_directories(${lib} PUBLIC - $ + $ $ PRIVATE src ) + + # C++17 is used. We requires fold expression at least. set_property(TARGET ${lib} PROPERTY CXX_STANDARD 17) - target_compile_options(${lib} PRIVATE - $<$:/W4 /WX> - $<$>:-Wall -Wextra -pedantic -Werror -Wno-sign-compare> -) + + # Force Microsoft Visual Studio to decode sources files in UTF-8. This applies + # to the library and the library users. + if (MSVC) + target_compile_options(${lib} PUBLIC "/utf-8>") + endif() + + # Add as many warning as possible: + if (MSVC) + target_compile_options(${lib} PRIVATE "/W4") + target_compile_options(${lib} PRIVATE "/WX") + else() + target_compile_options(${lib} PRIVATE "-Wall") + target_compile_options(${lib} PRIVATE "-Wextra") + target_compile_options(${lib} PRIVATE "-pedantic") + target_compile_options(${lib} PRIVATE "-Werror") + target_compile_options(${lib} PRIVATE "-Wno-sign-compare") + endif() endforeach() if(FTXUI_ENABLE_INSTALL)