From: Richard Levitte Date: Tue, 11 May 2021 08:27:37 +0000 (+0200) Subject: Adapt C flags for the cmake build type X-Git-Tag: v3.0.0~21 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=5ad6c77686b906a7f137d0955400cc64f7b70c70;p=openssl-gost%2Fengine.git Adapt C flags for the cmake build type The C flags were set to be highly optimized regardless of the cmake build type. This may make debugging difficult. To resolve that, we adapt the C flags to the cmake build type in a supported manner. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5054f76..a6bb178 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,14 +15,20 @@ message("-- Found OpenSSL application: ${OPENSSL_PROGRAM}") include_directories(${OPENSSL_INCLUDE_DIR}) if (CMAKE_C_COMPILER_ID MATCHES "Clang") - add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -ggdb -Qunused-arguments -Wno-deprecated-declarations) + set(CMAKE_C_FLAGS_RELEASE -O2) + set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -ggdb") + add_compile_options(-Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -Qunused-arguments -Wno-deprecated-declarations) elseif(CMAKE_C_COMPILER_ID MATCHES "GNU") - add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -ggdb -Wno-error=unknown-pragmas -Wno-error=pragmas -Wno-deprecated-declarations) + set(CMAKE_C_FLAGS_RELEASE -O2) + set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -ggdb") + add_compile_options(-Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -Wno-error=unknown-pragmas -Wno-error=pragmas -Wno-deprecated-declarations) elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS) - add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) - add_compile_options(/MP /WX /W4 /wd4100 /wd4267 /wd4206 /wd4706 /wd4244 /wd4115) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS) + add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) + add_compile_options(/MP /WX /W4 /wd4100 /wd4267 /wd4206 /wd4706 /wd4244 /wd4115) endif() if (ASAN)