]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Adapt C flags for the cmake build type
authorRichard Levitte <richard@levitte.org>
Tue, 11 May 2021 08:27:37 +0000 (10:27 +0200)
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>
Tue, 11 May 2021 10:59:56 +0000 (13:59 +0300)
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.

CMakeLists.txt

index 5054f769f500fa46752a243e607c32715373b29b..a6bb1785e8555bc0fbab6d99360b44a7f6588921 100644 (file)
@@ -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)