diff --git a/CMakeLists.txt b/CMakeLists.txt index ecd550440c835cd0a7f7b3745df423ff766491c0..64438908e2ed3c2f2c6eef59bbf9884cf8ff188b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,17 @@ option(TBOX_ENABLE_NLOHMANN_JSON "install nlohmann/json" ON) # option(CMAKE_ENABLE_TEST "Whether to enable unit tests" ON) +set(CMAKE_C_STANDARD 99) +set(CMAKE_CXX_STANDARD 11) +add_compile_options(-Wall -Wextra -Werror -Wno-missing-field-initializers) + +# compare the CXX Stanard to avoid the test module report error. +if(CMAKE_CXX_STANDARD LESS 13) + message("The CMAKE_CXX_STANDARD is less than 13,so set the CMAKE_ENABLE_TEST OFF.") + set(CMAKE_ENABLE_TEST OFF) + message("The CMAKE_ENABLE_TEST value is ${CMAKE_ENABLE_TEST}") +endif() + if(CMAKE_ENABLE_TEST) message(STATUS "Unit tests enabled") find_package(GTest REQUIRED) @@ -110,8 +121,7 @@ include(GNUInstallDirs) # # Compiler args # -set(CMAKE_C_STANDARD 99) -set(CMAKE_CXX_STANDARD 11) + add_compile_options(-Wall -Wextra -Werror -Wno-missing-field-initializers) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rd-party)