Menu

cppcheck 2.11 does not compile with CMake 3.24.3

2023-06-24
2023-06-29
  • Mohamed Aly

    Mohamed Aly - 2023-06-24

    Hi,

    Apologies in advance if there is a naive configuration leading to this issue.

    I am trying to compile cppcheck 2.11 from source using CMake v3.24.3 and I run into the following issue:

    [maly build]$ cmake ..
    -- The C compiler identification is GNU 4.8.5
    -- The CXX compiler identification is GNU 4.8.5
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /usr/bin/cc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    CMake Error at cmake/versions.cmake:6 (LIST):
      LIST index: 2 out of range (-2, 1)
    Call Stack (most recent call first):
      CMakeLists.txt:13 (include)
      - Performing Test CMAKE_HAVE_LIBC_PTHREAD
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - found
    -- Found Threads: TRUE  
    -- ------------------ General configuration for Cppcheck 2.11 -----------------
    -- 
    -- CMake Version =         3.24.3
    -- CMake Generator =       Unix Makefiles
    -- Compiler =              GNU
    -- Compiler Version =      4.8.5
    -- Build type =            Debug
    -- CMake C++ Standard =    11
    -- CMAKE_INSTALL_PREFIX =  /usr/local
    -- CMAKE_DISABLE_PRECOMPILE_HEADERS = Off
    -- C++ flags (General) =   
    -- C++ flags (Release) =   -O3 -DNDEBUG
    -- C++ flags (RelWithDebInfo) = -O2 -g -DNDEBUG
    -- C++ flags (Debug) =     -g
    -- CMAKE_EXE_LINKER_FLAGS = 
    -- CPPCHK_GLIBCXX_DEBUG =  ON
    -- COMPILE_DEFINITIONS (global) =  _GLIBCXX_DEBUG;FILESDIR="/usr/local/share/Cppcheck"
    -- COMPILE_OPTIONS (global) =  -pedantic;-Wall;-Wextra;-Wcast-qual;-Wfloat-equal;-Wmissing-declarations;-Wmissing-format-attribute;-Wno-long-long;-Wpacked;-Wredundant-decls;-Wundef;-Wno-missing-field-initializers;-Wno-missing-braces;-Wno-sign-compare;-Wno-multichar;-pipe;-Woverloaded-virtual;-Wno-maybe-uninitialized;-Wsuggest-attribute=noreturn;-Wno-shadow
    -- 
    -- ---------------------------------------------------------
    -- ANALYZE_MEMORY =        OFF
    -- ANALYZE_ADDRESS =       OFF
    -- ANALYZE_THREAD =        OFF
    -- ANALYZE_UNDEFINED =     OFF
    -- ANALYZE_DATAFLOW =      OFF
    -- WARNINGS_ARE_ERRORS =   OFF
    -- 
    -- USE_MATCHCOMPILER =     Auto
    -- USE_MATCHCOMPILER_OPT = Off
    -- 
    -- DISABLE_CRTDBG_MAP_ALLOC = OFF
    -- NO_UNIX_SIGNAL_HANDLING = OFF
    -- NO_UNIX_BACKTRACE_SUPPORT = OFF
    -- NO_WINDOWS_SEH =        OFF
    -- 
    -- BUILD_SHARED_LIBS =     OFF
    -- LIBXML2_XMLLINT_EXECUTABLE = /usr/bin/xmllint
    -- BUILD_CORE_DLL =        OFF
    -- BUILD_TESTS =           OFF
    -- ENABLE_CHECK_INTERNAL = OFF
    -- DISABLE_DMAKE =         OFF
    -- 
    -- BUILD_GUI =             OFF
    -- 
    -- HAVE_RULES =            OFF
    -- 
    -- USE_THREADS =           OFF
    -- CMAKE_THREAD_LIBS_INIT = -lpthread
    -- 
    -- USE_BUNDLED_TINYXML2 =  ON
    -- 
    -- USE_BOOST =             OFF
    -- USE_LIBCXX =            OFF
    -- 
    -- Using bundled version of tinyxml2
    -- Cannot use non-Clang compiler with clang-tidy when precompiled headers are enabled - skipping 'run-clang-tidy' target generation
    -- Configuring incomplete, errors occurred!
    

    Has anyone run into this issue?

     
  • Lieven de Cock

    Lieven de Cock - 2023-06-29

    also with cmake 3.26.4.

    The problem is cmake/versions.cmake

    SET(VERSION "2.11")
    STRING(REGEX MATCHALL "[0-9]+" VERSION_PARTS "${VERSION}")
    LIST(GET VERSION_PARTS 0 VERSION_MAJOR)
    LIST(GET VERSION_PARTS 1 VERSION_MINOR)
    LIST(GET VERSION_PARTS 2 VERSION_PATCH) <========== there is no 3rd field

    So as suggested above changing to "2.11.0" fixes the problem.

    Cmake error :

    CMake Error at cmake/versions.cmake:6 (LIST):
    LIST index: 2 out of range (-2, 1)
    Call Stack (most recent call first):
    CMakeLists.txt:13 (include)

    Can a new release be made, since we are building this in an automated way, and would want to avoid that I need to adjust the build script to 'sed' a solution ;-)

     
  • Daniel Marjamäki

    I have tagged 2.11.1 that should fix this

     

Log in to post a comment.