[LLVMbugs] [Bug 22798] New: CMAKE defines NDEBUG differently than Autoconf for Assertions.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Mar 4 17:23:35 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22798

            Bug ID: 22798
           Summary: CMAKE defines NDEBUG differently than Autoconf for
                    Assertions.
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: rfoos at codeaurora.org
                CC: llvmbugs at cs.uiuc.edu, ted.woodward at codeaurora.org,
                    zturner at google.com
    Classification: Unclassified

When going through _DEBUG, NDEBUG definitions found a difference between
autoconf and cmake.

    llvm/Makefile.rules (MSVC case not applicable)

        ifeq ($(DISABLE_ASSERTIONS),1)
          CPP.Defines += -DNDEBUG
        else
          BuildMode := $(BuildMode)+Asserts
          CPP.Defines += -D_DEBUG
        endif

    llvm/cmake/modules/HandleLLVMOptions.cmake

        if( LLVM_ENABLE_ASSERTIONS )
          # MSVC doesn't like _DEBUG on release builds. See PR 4379.
          if( NOT MSVC )
            add_definitions( -D_DEBUG )
          endif()
          # On non-Debug builds cmake automatically defines NDEBUG, so we
          # explicitly undefine it:
          if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
            add_definitions( -UNDEBUG )
            # Also remove /D NDEBUG to avoid MSVC warnings about conflicting
defines.
            foreach (flags_var_to_scrub
                CMAKE_CXX_FLAGS_RELEASE
                CMAKE_CXX_FLAGS_RELWITHDEBINFO
                CMAKE_CXX_FLAGS_MINSIZEREL
                CMAKE_C_FLAGS_RELEASE
                CMAKE_C_FLAGS_RELWITHDEBINFO
                CMAKE_C_FLAGS_MINSIZEREL)
              string (REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " "
                "${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
            endforeach()
          endif()
          --- BUG different than autoconf, if not msvc, -DNDEBUG
          if( NOT MSVC )
            add_definitions( -DNDEBUG )
          endif()
          ---
        endif()

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150305/b91b1ea3/attachment.html>


More information about the llvm-bugs mailing list