From d6b17a8695b46062c8a071ce7358694a285c629f Mon Sep 17 00:00:00 2001 From: Mark Horvath Date: Fri, 1 Mar 2024 13:59:05 +0100 Subject: [PATCH] Fix debug build - Typo fixed for production library to turn off optimization and turn on debug symbols in case of debug mode. - Similar solution added for the test executables. --- intrinsiccv/CMakeLists.txt | 2 +- test/CMakeLists.txt | 8 +++++++- test/api/CMakeLists.txt | 2 +- test/framework/CMakeLists.txt | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/intrinsiccv/CMakeLists.txt b/intrinsiccv/CMakeLists.txt index 553f13acf..188b61fa3 100644 --- a/intrinsiccv/CMakeLists.txt +++ b/intrinsiccv/CMakeLists.txt @@ -117,7 +117,7 @@ if (INTRINSICCV_CHECK_BANNED_FUNCTIONS) list(APPEND INTRINSICCV_CXX_FLAGS "SHELL:-include intrinsiccv/unsafe.h") endif() -if (CMAKE_BUILD_TYPE EQUAL "DEBUG") +if (CMAKE_BUILD_TYPE STREQUAL "Debug") list(APPEND INTRINSICCV_CXX_FLAGS "-O0" "-g") else() list(APPEND INTRINSICCV_CXX_FLAGS "-O2" "-g0") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b22697f90..b0264496c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,13 +10,19 @@ set(INTRINSICCV_INCLUDE_DIR ) set(INTRINSICCV_TEST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(INTRINSICCV_WARNING_FLAGS +set(INTRINSICCV_TEST_CXX_FLAGS "-Werror" "-Wall" "-Wextra" "-Wold-style-cast" ) +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + list(APPEND INTRINSICCV_TEST_CXX_FLAGS "-O0" "-g") +else() + list(APPEND INTRINSICCV_TEST_CXX_FLAGS "-O2" "-g0") +endif() + set(INTRINSICCV_TEST_FRAMEWORK_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/framework/border.cpp ${CMAKE_CURRENT_SOURCE_DIR}/framework/test_main.cpp diff --git a/test/api/CMakeLists.txt b/test/api/CMakeLists.txt index 301715d38..483a4fad1 100644 --- a/test/api/CMakeLists.txt +++ b/test/api/CMakeLists.txt @@ -8,7 +8,7 @@ list(APPEND intrinsiccv_api_test_sources ${INTRINSICCV_TEST_FRAMEWORK_SOURCES}) set_source_files_properties( ${intrinsiccv_api_test_sources} - PROPERTIES COMPILE_OPTIONS "-O2;${INTRINSICCV_WARNING_FLAGS}" + PROPERTIES COMPILE_OPTIONS "${INTRINSICCV_TEST_CXX_FLAGS}" ) add_executable( diff --git a/test/framework/CMakeLists.txt b/test/framework/CMakeLists.txt index 20feeb2f8..ff60c11a6 100644 --- a/test/framework/CMakeLists.txt +++ b/test/framework/CMakeLists.txt @@ -8,7 +8,7 @@ list(APPEND intrinsiccv_framework_test_sources ${INTRINSICCV_TEST_FRAMEWORK_SOUR set_source_files_properties( ${intrinsiccv_framework_test_sources} - PROPERTIES COMPILE_OPTIONS "-O2;${INTRINSICCV_WARNING_FLAGS}" + PROPERTIES COMPILE_OPTIONS "${INTRINSICCV_TEST_CXX_FLAGS}" ) add_executable( -- GitLab