From cccde6324c3dfdc9df2b90fa899a046830609631 Mon Sep 17 00:00:00 2001 From: Davis King Date: Fri, 4 Nov 2016 20:30:03 -0400 Subject: [PATCH] Changed CMake so it doesn't automatically enable asserts in debug builds since this frustrates Visual Studio users who want to compile dlib as a static library. --- dlib/CMakeLists.txt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/dlib/CMakeLists.txt b/dlib/CMakeLists.txt index cff48c8e0..41459e671 100644 --- a/dlib/CMakeLists.txt +++ b/dlib/CMakeLists.txt @@ -33,12 +33,18 @@ endif() include(cmake_utils/add_global_compiler_switch.cmake) -# Make sure ENABLE_ASSERTS is defined for debug builds -if (NOT CMAKE_CXX_FLAGS_DEBUG MATCHES "-DENABLE_ASSERTS") - set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DENABLE_ASSERTS" - CACHE STRING "Flags used by the compiler during C++ debug builds." - FORCE) -endif () +if (DLIB_IN_PROJECT_BUILD) + # Make sure ENABLE_ASSERTS is defined for debug builds, but only for uses + # who are building an application. If they are just building dlib as a + # stand alone library then don't set this because it will conflict with the + # settings in config.h if we did. + if (NOT CMAKE_CXX_FLAGS_DEBUG MATCHES "-DENABLE_ASSERTS") + set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DENABLE_ASSERTS" + CACHE STRING "Flags used by the compiler during C++ debug builds." + FORCE) + endif() +endif() + macro (toggle_preprocessor_switch option_name) if (${option_name}) add_global_define(${option_name})