diff --git a/CMakeLists.txt b/CMakeLists.txt index ebf20ec..b730d86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,27 +23,27 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) # https://cmake.org/cmake/help/latest/prop_tgt/C_STANDARD.html # https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html if(CMAKE_HOST_UNIX) - set(CMAKE_C_STANDARD 23) + set(CMAKE_C_STANDARD 23) set(CMAKE_CXX_STANDARD 23) # https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c2x -Wall -Wextra") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++23 -Wall -Wextra") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-unused-variable -Wno-unused-parameter -O0 -g") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-unused-variable -Wno-unused-parameter -O0 -g") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wunused-variable -Wunused-parameter -O3") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c2x -Wall -Wextra") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++23 -Wall -Wextra") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-unused-variable -Wno-unused-parameter -O0 -g") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-unused-variable -Wno-unused-parameter -O0 -g") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wunused-variable -Wunused-parameter -O3") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wunused-variable -Wunused-parameter -O3") if(BUILD_SHARED_LIBS) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") endif() elseif(CMAKE_HOST_WIN32) if(MSVC) - set(CMAKE_C_STANDARD 17) + set(CMAKE_C_STANDARD 17) set(CMAKE_CXX_STANDARD 20) # https://learn.microsoft.com/zh-cn/cpp/build/reference/compiler-options-listed-by-category # /wd4804 = 忽略告警 # /wd4819 = 忽略告警 - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c17 /std:c++20 /wd4804 /wd4819") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c17 /std:c++20 /wd4804 /wd4819") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c17 /std:c++20 /wd4804 /wd4819") # add_compile_options("/J") add_compile_options("/utf-8") @@ -57,8 +57,14 @@ else() endif() message(STATUS "当前模式: ${CMAKE_BUILD_TYPE}") -message(STATUS "当前C编译参数: ${CMAKE_C_FLAGS}") -message(STATUS "当前C++编译参数: ${CMAKE_CXX_FLAGS}") + +if(CMAKE_BUILD_TYPE MATCHES "Debug") + message(STATUS "C_FLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}") + message(STATUS "C++FLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") +else() + message(STATUS "C_FLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}") + message(STATUS "C++_FLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") +endif() add_definitions(-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG)