From 8471dc05d30092a7967b30f26f2f1e68c624d2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=88=B1=E7=9C=8B=E4=B9=A6=E7=9A=84=E7=8C=AB?= Date: Wed, 13 Nov 2024 01:13:14 +0000 Subject: [PATCH] =?UTF-8?q?update=20CMakeLists.txt.=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86CMakeLists.txt=E6=96=87=E4=BB=B6=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E9=87=8C=E8=BE=B9=E5=88=A4=E6=96=AD=E4=BA=86CXX=E6=89=80?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E6=A0=87=E5=87=86=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E5=B0=8F=E4=BA=8E13=EF=BC=8C=E5=88=99=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E8=AE=BE=E7=BD=AECMAKE=5FENABLE=5FTEST=E4=B8=BAOFF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 爱看书的猫 --- CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ecd5504..6443890 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) -- Gitee