forked from bblanchon/ArduinoJson
CMake: gathered all build flags in a dedicated file
This commit is contained in:
@ -13,35 +13,7 @@ endif()
|
|||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||||
|
include(extras/CompileOptions.cmake)
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8)
|
|
||||||
add_compile_options(-g -Og)
|
|
||||||
else()
|
|
||||||
add_compile_options(-g -O0)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0)
|
|
||||||
add_compile_options(-g -Og)
|
|
||||||
else()
|
|
||||||
add_compile_options(-g -O0)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
|
|
||||||
add_compile_options(-g -Og)
|
|
||||||
else()
|
|
||||||
add_compile_options(-g -O0)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(${COVERAGE})
|
|
||||||
set(CMAKE_CXX_FLAGS "-fprofile-arcs -ftest-coverage")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_subdirectory(extras/tests)
|
add_subdirectory(extras/tests)
|
||||||
add_subdirectory(extras/fuzzing)
|
add_subdirectory(extras/fuzzing)
|
||||||
endif()
|
endif()
|
||||||
|
100
extras/CompileOptions.cmake
Normal file
100
extras/CompileOptions.cmake
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
|
||||||
|
add_compile_options(
|
||||||
|
-pedantic
|
||||||
|
-Wall
|
||||||
|
-Wcast-align
|
||||||
|
-Wcast-qual
|
||||||
|
-Wconversion
|
||||||
|
-Wctor-dtor-privacy
|
||||||
|
-Wdisabled-optimization
|
||||||
|
-Werror
|
||||||
|
-Wextra
|
||||||
|
-Wformat=2
|
||||||
|
-Winit-self
|
||||||
|
-Wmissing-include-dirs
|
||||||
|
-Wnon-virtual-dtor
|
||||||
|
-Wold-style-cast
|
||||||
|
-Woverloaded-virtual
|
||||||
|
-Wparentheses
|
||||||
|
-Wredundant-decls
|
||||||
|
-Wshadow
|
||||||
|
-Wsign-promo
|
||||||
|
-Wstrict-aliasing
|
||||||
|
-Wundef
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT MINGW)
|
||||||
|
add_compile_options(
|
||||||
|
-std=c++98
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(${COVERAGE})
|
||||||
|
set(CMAKE_CXX_FLAGS "-fprofile-arcs -ftest-coverage")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8)
|
||||||
|
add_compile_options(-g -Og)
|
||||||
|
else()
|
||||||
|
add_compile_options(-g -O0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_compile_options(
|
||||||
|
-Wstrict-null-sentinel
|
||||||
|
-Wno-vla # Allow VLA in tests
|
||||||
|
)
|
||||||
|
add_definitions(-DHAS_VARIABLE_LENGTH_ARRAY)
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.5)
|
||||||
|
add_compile_options(-Wlogical-op) # the flag exists in 4.4 but is buggy
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.6)
|
||||||
|
add_compile_options(-Wnoexcept)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
add_compile_options(
|
||||||
|
-Wc++11-compat
|
||||||
|
-Wdeprecated-register
|
||||||
|
-Wno-vla-extension # Allow VLA in tests
|
||||||
|
)
|
||||||
|
add_definitions(
|
||||||
|
-DHAS_VARIABLE_LENGTH_ARRAY
|
||||||
|
-DSUBSCRIPT_CONFLICTS_WITH_BUILTIN_OPERATOR
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0)
|
||||||
|
add_compile_options(-g -Og)
|
||||||
|
else()
|
||||||
|
add_compile_options(-g -O0)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||||
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
|
||||||
|
add_compile_options(-g -Og)
|
||||||
|
else()
|
||||||
|
add_compile_options(-g -O0)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
add_compile_options(
|
||||||
|
/W4 # Set warning level
|
||||||
|
/WX # Treats all compiler warnings as errors.
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT MSVC_VERSION LESS 1910) # >= Visual Studio 2017
|
||||||
|
add_compile_options(
|
||||||
|
/Zc:__cplusplus # Enable updated __cplusplus macro
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
@ -21,7 +21,7 @@ std::vector<uint8_t> read(const char* path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
size_t size = ftell(f);
|
size_t size = static_cast<size_t>(ftell(f));
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
std::vector<uint8_t> buffer(size);
|
std::vector<uint8_t> buffer(size);
|
||||||
|
@ -4,80 +4,6 @@
|
|||||||
|
|
||||||
add_subdirectory(catch)
|
add_subdirectory(catch)
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
|
|
||||||
add_compile_options(
|
|
||||||
-pedantic
|
|
||||||
-Wall
|
|
||||||
-Wcast-align
|
|
||||||
-Wcast-qual
|
|
||||||
-Wconversion
|
|
||||||
-Wctor-dtor-privacy
|
|
||||||
-Wdisabled-optimization
|
|
||||||
-Werror
|
|
||||||
-Wextra
|
|
||||||
-Wformat=2
|
|
||||||
-Winit-self
|
|
||||||
-Wmissing-include-dirs
|
|
||||||
-Wnon-virtual-dtor
|
|
||||||
-Wold-style-cast
|
|
||||||
-Woverloaded-virtual
|
|
||||||
-Wparentheses
|
|
||||||
-Wredundant-decls
|
|
||||||
-Wshadow
|
|
||||||
-Wsign-promo
|
|
||||||
-Wstrict-aliasing
|
|
||||||
-Wundef
|
|
||||||
)
|
|
||||||
|
|
||||||
if(NOT MINGW)
|
|
||||||
add_compile_options(
|
|
||||||
-std=c++98
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
||||||
add_compile_options(
|
|
||||||
-Wstrict-null-sentinel
|
|
||||||
-Wno-vla # Allow VLA in tests
|
|
||||||
)
|
|
||||||
add_definitions(-DHAS_VARIABLE_LENGTH_ARRAY)
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.5)
|
|
||||||
add_compile_options(-Wlogical-op) # the flag exists in 4.4 but is buggy
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.6)
|
|
||||||
add_compile_options(-Wnoexcept)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
||||||
add_compile_options(
|
|
||||||
-Wc++11-compat
|
|
||||||
-Wdeprecated-register
|
|
||||||
-Wno-vla-extension # Allow VLA in tests
|
|
||||||
)
|
|
||||||
add_definitions(
|
|
||||||
-DHAS_VARIABLE_LENGTH_ARRAY
|
|
||||||
-DSUBSCRIPT_CONFLICTS_WITH_BUILTIN_OPERATOR
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
||||||
add_compile_options(
|
|
||||||
/W4 # Set warning level
|
|
||||||
/WX # Treats all compiler warnings as errors.
|
|
||||||
)
|
|
||||||
|
|
||||||
if (NOT MSVC_VERSION LESS 1910) # >= Visual Studio 2017
|
|
||||||
add_compile_options(
|
|
||||||
/Zc:__cplusplus # Enable updated __cplusplus macro
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories(Helpers)
|
include_directories(Helpers)
|
||||||
add_subdirectory(ElementProxy)
|
add_subdirectory(ElementProxy)
|
||||||
add_subdirectory(IntegrationTests)
|
add_subdirectory(IntegrationTests)
|
||||||
|
Reference in New Issue
Block a user