From 21f27ec261aa152a3f3999313b379fb97fe7a462 Mon Sep 17 00:00:00 2001 From: Stefano Sanfilippo Date: Sun, 7 Jul 2019 10:06:50 +0200 Subject: [PATCH] Enable C++11 and strict checks for all code, msvc compatibility. --- CMakeLists.txt | 6 ++++++ cmake/FindRagel.cmake | 6 ++++-- src/CMakeLists.txt | 4 +--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8215105..d056c7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,12 @@ set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) include(CPack) include(Doxycelli) +if (MSVC) + add_compile_options(/W4 /WX) +else() + add_compile_options(-Wall -Wextra -pedantic -Werror) +endif() + add_subdirectory(src) install(FILES README.md LICENSE.txt DESTINATION doc/monicelli) diff --git a/cmake/FindRagel.cmake b/cmake/FindRagel.cmake index 24bcbd3..52c7501 100644 --- a/cmake/FindRagel.cmake +++ b/cmake/FindRagel.cmake @@ -29,8 +29,10 @@ function(add_ragel_library name ragel_source) CXX_STANDARD_REQUIRED true ) - # The lexer uses implicit fallthroughs all over, but it's OK. - target_compile_options(${name} PRIVATE -Wno-implicit-fallthrough) + if (NOT MSVC) + # The lexer uses implicit fallthroughs all over, but it's OK. + target_compile_options(${name} PRIVATE -Wno-implicit-fallthrough) + endif() target_include_directories(${name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) endfunction() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d61f2f..9d6fdce 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,14 +33,12 @@ add_executable(mcc operators.def ) -set_target_properties(mcc +set_target_properties(mcc lexer PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED true ) -target_compile_options(mcc PRIVATE -Wall -Wextra -Werror) - target_link_libraries(mcc PRIVATE lexer) llvm_config(mcc