Added CMake files

This commit is contained in:
Markus Elfring 2011-03-25 07:14:53 +01:00 committed by Daniel Marjamäki
parent 710eb8ffd9
commit 9301ee28a8
18 changed files with 716 additions and 110 deletions

103
CMake/xmlto.cmake Normal file
View File

@ -0,0 +1,103 @@
# - Convert XML docBook files to various formats
# This will convert XML docBook files to various formats like:
# man html txt dvi ps pdf
# macro XMLTO(outfiles infiles... MODES modes...)
set ( XmlTo_FOUND false )
find_program ( XMLTO_EXECUTABLE
NAMES xmlto
DOC "path to the xmlto docbook xslt frontend"
)
if ( XMLTO_EXECUTABLE )
set ( XmlTo_FOUND true )
endif ( XMLTO_EXECUTABLE )
if ( NOT XmlTo_FIND_QUIETLY )
if ( XmlTo_FIND_REQUIRED )
FATAL_ERROR ( "xmlto not found" )
endif ( XmlTo_FIND_REQUIRED )
endif ( NOT XmlTo_FIND_QUIETLY )
macro ( _XMLTO_FILE outfiles mode)
#special settings
set ( XMLTO_FILEEXT_man 1 )
set ( XMLTO_MODE_html xhtml-nochunks )
if ( NOT XMLTO_MODE_${mode})
set ( XMLTO_MODE_${mode} ${mode} )
endif ( NOT XMLTO_MODE_${mode} )
if ( NOT XMLTO_FILEEXT_${mode} )
set ( XMLTO_FILEEXT_${mode} ${mode} )
endif ( NOT XMLTO_FILEEXT_${mode} )
foreach ( dbFile ${ARGN} )
#TODO: set XMLTO_FILEEXT_man to value from <manvolnum>
if ( "${mode}" STREQUAL "man" )
file ( READ "${dbFile}" _DB_FILE_CONTENTS )
string ( REGEX MATCH "<manvolnum>[^<]*" XMLTO_FILEEXT_${mode} "${_DB_FILE_CONTENTS}" )
string ( REGEX REPLACE "^<manvolnum>" "" XMLTO_FILEEXT_${mode} "${XMLTO_FILEEXT_${mode}}" )
string ( REGEX REPLACE "[[:space:]]" "" XMLTO_FILEEXT_${mode} "${XMLTO_FILEEXT_${mode}}" )
endif ( "${mode}" STREQUAL "man" )
get_filename_component ( dbFilePath ${CMAKE_CURRENT_BINARY_DIR}/${dbFile} PATH )
get_filename_component ( dbFileWE ${dbFile} NAME_WE )
get_filename_component ( dbFileAbsWE ${dbFilePath}/${dbFileWE} ABSOLUTE )
add_custom_command (
OUTPUT ${dbFileAbsWE}.${XMLTO_FILEEXT_${mode}}
COMMAND ${XMLTO_EXECUTABLE} ${XMLTO_COMMAND_ARGS} -o ${CMAKE_CURRENT_BINARY_DIR}
${XMLTO_MODE_${mode}} "${CMAKE_CURRENT_SOURCE_DIR}/${dbFile}"
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${dbFile}
VERBATIM
)
set ( ${outfiles}
${${outfiles}}
${dbFileAbsWE}.${XMLTO_FILEEXT_${mode}}
)
endforeach ( dbFile )
endmacro ( _XMLTO_FILE outfiles )
macro ( XMLTO )
set ( XMLTO_MODES )
set ( XMLTO_FILES )
set ( XMLTO_HAS_MODES false )
set ( XMLTO_ADD_DEFAULT false )
foreach ( arg ${ARGN} )
if ( ${arg} STREQUAL "MODES" )
set ( XMLTO_HAS_MODES true )
elseif ( ${arg} STREQUAL "ALL" )
set ( XMLTO_ADD_DEFAULT true )
else ( ${arg} STREQUAL "MODES" )
if ( XMLTO_HAS_MODES )
set ( XMLTO_MODES ${XMLTO_MODES} ${arg} )
else ( XMLTO_HAS_MODES )
set ( XMLTO_FILES ${XMLTO_FILES} ${arg} )
endif ( XMLTO_HAS_MODES )
endif ( ${arg} STREQUAL "MODES" )
endforeach ( arg ${ARGN} )
if ( NOT XMLTO_MODES )
set ( XMLTO_MODES html )
endif ( NOT XMLTO_MODES )
foreach ( mode ${XMLTO_MODES} )
_xmlto_file ( XMLTO_FILES_${mode} ${mode} ${XMLTO_FILES} )
if ( XMLTO_ADD_DEFAULT )
add_custom_target ( ${mode} ALL
DEPENDS ${XMLTO_FILES_${mode}}
VERBATIM
)
else ( XMLTO_ADD_DEFAULT )
add_custom_target ( ${mode}
DEPENDS ${XMLTO_FILES_${mode}}
VERBATIM
)
endif ( XMLTO_ADD_DEFAULT )
endforeach ( mode )
set ( XMLTO_MODES )
set ( XMLTO_FILES )
endmacro ( XMLTO )

37
CMakeLists.txt Normal file
View File

@ -0,0 +1,37 @@
# Minimal CMake build file
# Builds:
# - static library from lib directory
# - commandline executable
# - test suite
# - Qt GUI
# To build with CMake:
# - install CMake 2.6 or later
# - $ cmake .
# - $ make
cmake_minimum_required (VERSION 2.6)
PROJECT(CPPCHECK)
set(CMAKE_MODULE_PATH "${CPPCHECK_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
# Building lib as static library is disabled due to bug
# #1299 CMake: The CheckClass is not used
# https://sourceforge.net/apps/trac/cppcheck/ticket/1299
# Instead lib code is included directly into cli and gui targets
# ADD_SUBDIRECTORY(lib)
ADD_SUBDIRECTORY(cli)
# Exclude tests from command line targets but include them to VS IDE targets.
# There is 'make check' -target for compiling and running tests from
# command line.
IF (MSVC_IDE)
ADD_SUBDIRECTORY(test)
ELSE (MSVC_IDE)
ADD_SUBDIRECTORY(test EXCLUDE_FROM_ALL)
ENDIF (MSVC_IDE)
ADD_SUBDIRECTORY(gui)
ADD_SUBDIRECTORY(man)

41
cli/CMakeLists.txt Normal file
View File

@ -0,0 +1,41 @@
# Minimal CMake build file to build cppcheck command line executable
find_package(PCRE REQUIRED)
set(TINYXML_INCLUDE_DIR "${CPPCHECK_SOURCE_DIR}/externals/tinyxml/")
SET(CHECKCLI_SRCS
cmdlineparser.cpp
cppcheckexecutor.cpp
filelister.cpp
main.cpp
threadexecutor.cpp
"${TINYXML_INCLUDE_DIR}tinystr.cpp"
"${TINYXML_INCLUDE_DIR}tinyxml.cpp"
"${TINYXML_INCLUDE_DIR}tinyxmlerror.cpp"
"${TINYXML_INCLUDE_DIR}tinyxmlparser.cpp")
set(CPPCHECK_LIB_DIR "${CPPCHECK_SOURCE_DIR}/lib/")
include("${CPPCHECK_LIB_DIR}library_sources.cmake")
if(WIN32)
# Add Windows resource file
set(CHECKCLI_SRCS ${CHECKCLI_SRCS} filelister_win32.cpp
cppcheck.rc)
if(NOT CYGWIN)
# Windows needs additional shlwapi library.
set(CHECK_LIBS ${CHECK_LIBS} shlwapi)
endif()
else()
set(CHECKCLI_SRCS ${CHECKCLI_SRCS} filelister_unix.cpp)
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wshadow -Wno-long-long -Wfloat-equal -Wcast-qual")
endif (CMAKE_COMPILER_IS_GNUCXX)
include_directories("${CPPCHECK_SOURCE_DIR}/lib"
"${PCRE_INCLUDE_DIR}"
"${TINYXML_INCLUDE_DIR}")
add_executable(cppcheck ${CHECKCLI_SRCS} ${CPPCHECK_LIB_SOURCES})
TARGET_LINK_LIBRARIES(cppcheck ${CHECK_LIBS} ${PCRE_LIBRARIES})

View File

@ -1,14 +1,15 @@
TEMPLATE = app
TARGET = cppcheck
DEPENDPATH += .
INCLUDEPATH += . ../lib
TINYXML_DIR = ../externals/tinyxml/
INCLUDEPATH += . ../lib $${TINYXML_DIR}
OBJECTS_DIR = temp
CONFIG += warn_on
CONFIG -= qt app_bundle
DEFINES += HAVE_RULES
BASEPATH = ../externals/tinyxml/
include($$PWD/../externals/tinyxml/tinyxml.pri)
BASEPATH = $${TINYXML_DIR}
include($$PWD/$${TINYXML_DIR}tinyxml.pri)
BASEPATH = ../lib/
include($$PWD/../lib/lib.pri)

View File

@ -19,7 +19,7 @@
UseOfMfc="0">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;.&quot;,&quot;..\lib&quot;,&quot;..\externals&quot;,&quot;..\externals\tinyxml&quot;,..\..\Qt\VS4.7.0\mkspecs\win32-msvc2008"
AdditionalIncludeDirectories="&quot;.&quot;,&quot;..\lib&quot;,&quot;..\externals\tinyxml&quot;,c:\Qt\VS4.7.0\mkspecs\win32-msvc2008"
AdditionalOptions="-Zm200 -w34100 -w34189"
AssemblerListingLocation="temp\"
BufferSecurityCheck="false"

View File

@ -50,7 +50,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;Debug|Win32&apos;">
<ClCompile>
<AdditionalIncludeDirectories>".";"..\lib";"..\externals";"..\externals\tinyxml";..\..\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>".";"..\lib";"..\externals\tinyxml";c:\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>-Zm200 -w34100 -w34189 %(AdditionalOptions)</AdditionalOptions>
<AssemblerListingLocation>temp\</AssemblerListingLocation>
<BrowseInformation>false</BrowseInformation>
@ -84,7 +84,11 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;Release|Win32&apos;">
<ClCompile>
<<<<<<< HEAD:cli/cppcheck.vcxproj
<AdditionalIncludeDirectories>".";"..\lib";"..\externals";"..\externals\tinyxml";..\..\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
=======
<AdditionalIncludeDirectories>".";"..\lib";"..\externals\tinyxml";c:\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
>>>>>>> 8e379f65ec6b29de134be4013536fafe4d760a1c:cli/cppcheck.vcxproj
<AdditionalOptions>-Zm200 -w34100 -w34189 %(AdditionalOptions)</AdditionalOptions>
<AssemblerListingLocation>temp\</AssemblerListingLocation>
<BrowseInformation>false</BrowseInformation>

View File

@ -0,0 +1,42 @@
# - Try to find the PCRE regular expression library
# Once done this will define
#
# PCRE_FOUND - system has the PCRE library
# PCRE_INCLUDE_DIR - the PCRE include directory
# PCRE_LIBRARIES - The libraries needed to use PCRE
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if (PCRE_INCLUDE_DIR AND PCRE_PCREPOSIX_LIBRARY AND PCRE_PCRE_LIBRARY)
# Already in cache, be silent
set(PCRE_FIND_QUIETLY TRUE)
endif (PCRE_INCLUDE_DIR AND PCRE_PCREPOSIX_LIBRARY AND PCRE_PCRE_LIBRARY)
if (NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig)
pkg_check_modules(PC_PCRE QUIET libpcre)
set(PCRE_DEFINITIONS ${PC_PCRE_CFLAGS_OTHER})
endif (NOT WIN32)
find_path(PCRE_INCLUDE_DIR pcre.h
HINTS "${PC_PCRE_INCLUDEDIR}" ${PC_PCRE_INCLUDE_DIRS}
PATH_SUFFIXES pcre)
find_library(PCRE_PCRE_LIBRARY NAMES pcre pcred HINTS "${PC_PCRE_LIBDIR}" ${PC_PCRE_LIBRARY_DIRS})
find_library(PCRE_PCREPOSIX_LIBRARY NAMES pcreposix pcreposixd HINTS "${PC_PCRE_LIBDIR}" ${PC_PCRE_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_INCLUDE_DIR PCRE_PCRE_LIBRARY PCRE_PCREPOSIX_LIBRARY )
set(PCRE_LIBRARIES "${PCRE_PCRE_LIBRARY}" "${PCRE_PCREPOSIX_LIBRARY}")
mark_as_advanced(PCRE_INCLUDE_DIR PCRE_LIBRARIES PCRE_PCREPOSIX_LIBRARY PCRE_PCRE_LIBRARY)

View File

@ -0,0 +1,105 @@
# Is Hendrik Sattler the original author of the following script?
# http://cmake.org/pipermail/cmake/2007-April/013545.html
# - Convert XML docBook files to various formats
# This will convert XML docBook files to various formats like:
# man html txt dvi ps pdf
# macro XMLTO(outfiles infiles... MODES modes...)
set ( XmlTo_FOUND false )
find_program ( XMLTO_EXECUTABLE NAMES xmlto
DOC "path to the xmlto docbook xslt frontend" )
if ( XMLTO_EXECUTABLE )
set ( XmlTo_FOUND true )
if ( NOT XmlTo_FIND_QUIETLY )
message ( STATUS "Found ${XMLTO_EXECUTABLE}" )
endif ( NOT XmlTo_FIND_QUIETLY )
else ( XMLTO_EXECUTABLE )
if ( XmlTo_FIND_REQUIRED )
message ( FATAL_ERROR "The xmlto program was not found." )
endif ( XmlTo_FIND_REQUIRED )
endif ( XMLTO_EXECUTABLE )
macro ( _XMLTO_FILE outfiles mode)
#special settings
set ( XMLTO_FILEEXT_man 1 )
set ( XMLTO_MODE_html xhtml-nochunks )
if ( NOT XMLTO_MODE_${mode})
set ( XMLTO_MODE_${mode} ${mode} )
endif ( NOT XMLTO_MODE_${mode} )
if ( NOT XMLTO_FILEEXT_${mode} )
set ( XMLTO_FILEEXT_${mode} ${mode} )
endif ( NOT XMLTO_FILEEXT_${mode} )
foreach ( dbFile ${ARGN} )
#TODO: set XMLTO_FILEEXT_man to value from <manvolnum>
if ( "${mode}" STREQUAL "man" )
file ( READ "${dbFile}" _DB_FILE_CONTENTS )
string ( REGEX MATCH "<manvolnum>[^<]*" XMLTO_FILEEXT_${mode} "${_DB_FILE_CONTENTS}" )
string ( REGEX REPLACE "^<manvolnum>" "" XMLTO_FILEEXT_${mode} "${XMLTO_FILEEXT_${mode}}" )
string ( REGEX REPLACE "[[:space:]]" "" XMLTO_FILEEXT_${mode} "${XMLTO_FILEEXT_${mode}}" )
endif ( "${mode}" STREQUAL "man" )
get_filename_component ( dbFilePath "${CMAKE_CURRENT_BINARY_DIR}/${dbFile}" PATH )
get_filename_component ( dbFileWE "${dbFile}" NAME_WE )
get_filename_component ( dbFileAbsWE "${dbFilePath}/${dbFileWE}" ABSOLUTE )
add_custom_command (
OUTPUT "${dbFileAbsWE}.${XMLTO_FILEEXT_${mode}}"
COMMAND "${XMLTO_EXECUTABLE}" ${XMLTO_COMMAND_ARGS} -o "${CMAKE_CURRENT_BINARY_DIR}"
${XMLTO_MODE_${mode}} "${CMAKE_CURRENT_SOURCE_DIR}/${dbFile}"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${dbFile}"
VERBATIM
)
set ( ${outfiles}
${${outfiles}}
"${dbFileAbsWE}.${XMLTO_FILEEXT_${mode}}"
)
endforeach ( dbFile )
endmacro ( _XMLTO_FILE outfiles )
macro ( XMLTO )
set ( XMLTO_MODES )
set ( XMLTO_FILES )
set ( XMLTO_HAS_MODES false )
set ( XMLTO_ADD_DEFAULT false )
foreach ( arg ${ARGN} )
if ( ${arg} STREQUAL "MODES" )
set ( XMLTO_HAS_MODES true )
elseif ( ${arg} STREQUAL "ALL" )
set ( XMLTO_ADD_DEFAULT true )
else ( ${arg} STREQUAL "MODES" )
if ( XMLTO_HAS_MODES )
set ( XMLTO_MODES ${XMLTO_MODES} ${arg} )
else ( XMLTO_HAS_MODES )
set ( XMLTO_FILES ${XMLTO_FILES} ${arg} )
endif ( XMLTO_HAS_MODES )
endif ( ${arg} STREQUAL "MODES" )
endforeach ( arg ${ARGN} )
if ( NOT XMLTO_MODES )
set ( XMLTO_MODES html )
endif ( NOT XMLTO_MODES )
foreach ( mode ${XMLTO_MODES} )
_xmlto_file ( XMLTO_FILES_${mode} ${mode} ${XMLTO_FILES} )
if ( XMLTO_ADD_DEFAULT )
add_custom_target ( ${mode} ALL
DEPENDS ${XMLTO_FILES_${mode}}
VERBATIM
)
else ( XMLTO_ADD_DEFAULT )
add_custom_target ( ${mode}
DEPENDS ${XMLTO_FILES_${mode}}
VERBATIM
)
endif ( XMLTO_ADD_DEFAULT )
endforeach ( mode )
set ( XMLTO_MODES )
set ( XMLTO_FILES )
endmacro ( XMLTO )

152
gui/CMakeLists.txt Normal file
View File

@ -0,0 +1,152 @@
# Minimal CMake build file to build cppcheck Qt GUI
find_package(PCRE REQUIRED)
# find and setup Qt4 for this project
find_package(Qt4)
IF(QT4_FOUND)
# Add needed Qt modules
set(QT_USE_QTHELP TRUE)
set(QT_USE_QTMAIN TRUE)
set(QT_USE_QTXML TRUE)
include(${QT_USE_FILE})
include_directories("${CPPCHECK_SOURCE_DIR}/lib"
# Generated files (in build directory) need to know gui directory
"${CPPCHECK_SOURCE_DIR}/gui"
# Include binary directory where code from UI files gets created
"${CMAKE_CURRENT_BINARY_DIR}"
"${PCRE_INCLUDE_DIR}")
# Header files - listed for mocking
SET(CHECK_HEADERS
aboutdialog.h
applicationdialog.h
applicationlist.h
checkstatistics.h
checkthread.h
common.h
csvreport.h
erroritem.h
filelist.h
fileviewdialog.h
helpwindow.h
logview.h
mainwindow.h
project.h
projectfile.h
projectfiledialog.h
report.h
resultstree.h
resultsview.h
settingsdialog.h
statsdialog.h
threadhandler.h
threadresult.h
translationhandler.h
txtreport.h
xmlreport.h
)
# Source files
SET(CHECKGUI_SRCS
aboutdialog.cpp
applicationdialog.cpp
applicationlist.cpp
checkstatistics.cpp
checkthread.cpp
csvreport.cpp
erroritem.cpp
filelist.cpp
fileviewdialog.cpp
helpwindow.cpp
logview.cpp
main.cpp
mainwindow.cpp
project.cpp
projectfile.cpp
projectfiledialog.cpp
report.cpp
resultstree.cpp
resultsview.cpp
settingsdialog.cpp
statsdialog.cpp
threadhandler.cpp
threadresult.cpp
translationhandler.cpp
txtreport.cpp
xmlreport.cpp
)
# UI files
SET(CHECK_UIS
about.ui
application.ui
file.ui
helpwindow.ui
logview.ui
main.ui
projectfile.ui
resultsview.ui
settings.ui
stats.ui
)
# Translation files
SET(CHECK_TRANS
cppcheck_de.ts
cppcheck_en.ts
cppcheck_fi.ts
cppcheck_fr.ts
cppcheck_ja.ts
cppcheck_nl.ts
cppcheck_pl.ts
cppcheck_ru.ts
cppcheck_se.ts
cppcheck_sr.ts
)
SET(CHECK_RCCS gui.qrc)
set(CPPCHECK_LIB_DIR "${CPPCHECK_SOURCE_DIR}/lib/")
include("${CPPCHECK_LIB_DIR}library_sources.cmake")
if(WIN32)
# Add Windows resource file
set(CHECKGUI_SRCS ${CHECKGUI_SRCS} cppcheck-gui.rc)
if(NOT CYGWIN)
# Windows needs additional shlwapi library.
set(CHECK_LIBS ${CHECK_LIBS} shlwapi htmlhelp)
endif()
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif (CMAKE_COMPILER_IS_GNUCXX)
# Generate rules for building source files from the resources
QT4_ADD_RESOURCES(CHECK_RCC_SRCS ${CHECK_RCCS})
# Process UI files
QT4_WRAP_UI(CHECK_UIS_H ${CHECK_UIS})
# Mock header files
QT4_WRAP_CPP(CHECK_MOC_SRCS ${CHECK_HEADERS})
# add translations ...
QT4_ADD_TRANSLATION(CHECK_QM ${CHECK_TRANS})
# Create folders for Visual Studio IDE
SOURCE_GROUP("Header Files" FILES ${CHECK_HEADERS})
SOURCE_GROUP("Ui Files" ".ui$")
SOURCE_GROUP("Moc Files" "moc_.*cxx$")
ADD_EXECUTABLE(gui WIN32 ${CHECKGUI_SRCS} ${CHECK_MOC_SRCS} ${CHECK_HEADERS}
${CHECK_UIS_H} ${CHECK_RCC_SRCS} ${CPPCHECK_LIB_SOURCES})
TARGET_LINK_LIBRARIES(gui ${CHECK_LIBS} ${PCRE_LIBRARIES} ${QT_LIBRARIES})
ELSE(QT4_FOUND)
message("GUI not built since QT4 not found.")
ENDIF(QT4_FOUND)

17
lib/CMakeLists.txt Normal file
View File

@ -0,0 +1,17 @@
# Minimal CMake build file to build static cppcheck library
# This static library is used to build executables:
# - cli
# - tests
# - Qt GUI
find_package(PCRE REQUIRED)
include_directories("${PCRE_INCLUDE_DIR}")
set(CPPCHECK_LIB_DIR "")
include("library_sources.cmake")
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wshadow -Wno-long-long -Wfloat-equal -Wcast-qual")
endif (CMAKE_COMPILER_IS_GNUCXX)
add_library(checklib STATIC ${CPPCHECK_LIB_SOURCES})
target_link_libraries(checklib ${PCRE_LIBRARIES})

24
lib/library_sources.cmake Normal file
View File

@ -0,0 +1,24 @@
set(CPPCHECK_LIB_SOURCES
"${CPPCHECK_LIB_DIR}checkautovariables.cpp"
"${CPPCHECK_LIB_DIR}checkbufferoverrun.cpp"
"${CPPCHECK_LIB_DIR}checkclass.cpp"
"${CPPCHECK_LIB_DIR}checkexceptionsafety.cpp"
"${CPPCHECK_LIB_DIR}checkmemoryleak.cpp"
"${CPPCHECK_LIB_DIR}checknullpointer.cpp"
"${CPPCHECK_LIB_DIR}checkobsoletefunctions.cpp"
"${CPPCHECK_LIB_DIR}checkother.cpp"
"${CPPCHECK_LIB_DIR}checkpostfixoperator.cpp"
"${CPPCHECK_LIB_DIR}checkstl.cpp"
"${CPPCHECK_LIB_DIR}checkuninitvar.cpp"
"${CPPCHECK_LIB_DIR}checkunusedfunctions.cpp"
"${CPPCHECK_LIB_DIR}cppcheck.cpp"
"${CPPCHECK_LIB_DIR}errorlogger.cpp"
"${CPPCHECK_LIB_DIR}executionpath.cpp"
"${CPPCHECK_LIB_DIR}mathlib.cpp"
"${CPPCHECK_LIB_DIR}path.cpp"
"${CPPCHECK_LIB_DIR}preprocessor.cpp"
"${CPPCHECK_LIB_DIR}settings.cpp"
"${CPPCHECK_LIB_DIR}symboldatabase.cpp"
"${CPPCHECK_LIB_DIR}timer.cpp"
"${CPPCHECK_LIB_DIR}token.cpp"
"${CPPCHECK_LIB_DIR}tokenize.cpp")

View File

@ -1,22 +1,16 @@
# Build Docbook manual
# Run 'make html' to build manual
# Build manual in Linux/Cygwin - xmlto is not available in Windows
set(DOC_TARGETS "html")
SET(DOC_TARGETS "html")
if(CYGWIN)
# Build also htmlhelp in Cygwin - this can be used to build
# htmlhelp manual for Windows.
set(DOC_TARGETS ${DOC_TARGETS} "htmlhelp")
endif()
# Build also htmlhelp in Cygwin - this can be used to build
# htmlhelp manual for Windows.
IF (CYGWIN)
SET(DOC_TARGETS
${DOC_TARGETS}
"htmlhelp"
)
ENDIF(CYGWIN)
IF (UNIX OR CYGWIN)
#macro XMLTO(outfiles infiles... MODES modes...)
INCLUDE("../CMake/xmlto.cmake")
XMLTO("" "manual.docbook" MODES ${DOC_TARGETS})
ENDIF (UNIX OR CYGWIN)
if(UNIX OR CYGWIN)
# Build manual in Linux/Cygwin - xmlto is not available in Windows
find_package(XmlTo REQUIRED)
xmlto("" "manual.docbook" MODES ${DOC_TARGETS})
endif()

80
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,80 @@
# Minimal CMake build file to build cppcheck test suite
find_package(PCRE REQUIRED)
set(TINYXML_INCLUDE_DIR "${CPPCHECK_SOURCE_DIR}/externals/tinyxml/")
SET(CHECKTEST_SRCS
"${CPPCHECK_SOURCE_DIR}/cli/cmdlineparser.cpp"
"${CPPCHECK_SOURCE_DIR}/cli/cppcheckexecutor.cpp"
"${CPPCHECK_SOURCE_DIR}/cli/filelister.cpp"
"${CPPCHECK_SOURCE_DIR}/cli/threadexecutor.cpp"
options.cpp
testautovariables.cpp
testbufferoverrun.cpp
testcharvar.cpp
testclass.cpp
testcmdlineparser.cpp
testconstructors.cpp
testcppcheck.cpp
testdivision.cpp
testerrorlogger.cpp
testexceptionsafety.cpp
testincompletestatement.cpp
testmathlib.cpp
testmemleak.cpp
testnullpointer.cpp
testobsoletefunctions.cpp
testoptions.cpp
testother.cpp
testpath.cpp
testpostfixoperator.cpp
testpreprocessor.cpp
testrunner.cpp
testsettings.cpp
testsimplifytokens.cpp
teststl.cpp
testsuite.cpp
testsymboldatabase.cpp
testthreadexecutor.cpp
testtoken.cpp
testtokenize.cpp
testuninitvar.cpp
testunusedfunctions.cpp
testunusedprivfunc.cpp
testunusedvar.cpp
"${TINYXML_INCLUDE_DIR}tinystr.cpp"
"${TINYXML_INCLUDE_DIR}tinyxml.cpp"
"${TINYXML_INCLUDE_DIR}tinyxmlerror.cpp"
"${TINYXML_INCLUDE_DIR}tinyxmlparser.cpp")
set(CPPCHECK_LIB_DIR "${CPPCHECK_SOURCE_DIR}/lib/")
include("${CPPCHECK_LIB_DIR}library_sources.cmake")
if(WIN32)
set(CHECKTEST_SRCS ${CHECKTEST_SRCS}
"${CPPCHECK_SOURCE_DIR}/cli/filelister_win32.cpp")
if(NOT CYGWIN)
# Windows needs additional shlwapi library.
set(CHECK_LIBS ${CHECK_LIBS} shlwapi)
endif()
else()
set(CHECKTEST_SRCS ${CHECKTEST_SRCS} testfilelister_unix.cpp
"${CPPCHECK_SOURCE_DIR}/cli/filelister_unix.cpp")
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wshadow -Wno-long-long -Wfloat-equal -Wcast-qual")
endif (CMAKE_COMPILER_IS_GNUCXX)
include_directories("${CPPCHECK_SOURCE_DIR}/lib"
"${CPPCHECK_SOURCE_DIR}/cli"
"${PCRE_INCLUDE_DIR}"
"${TINYXML_INCLUDE_DIR}")
add_executable(test ${CHECKTEST_SRCS} ${CPPCHECK_LIB_SOURCES})
TARGET_LINK_LIBRARIES(test ${CHECK_LIBS} ${PCRE_LIBRARIES})
# Add custom 'make check' -target
# It compiles and runs tests
add_custom_target(check COMMAND test)
add_dependencies(check test)

View File

@ -2,7 +2,8 @@
TEMPLATE = app
TARGET = test
DEPENDPATH += .
INCLUDEPATH += . ../cli ../lib
TINYXML_DIR = ../externals/tinyxml/
INCLUDEPATH += . ../cli ../lib $${TINYXML_DIR}
OBJECTS_DIR = temp
CONFIG += warn_on console
CONFIG -= qt app_bundle
@ -10,8 +11,8 @@ win32 {
LIBS += -lshlwapi
}
BASEPATH = ../externals/tinyxml/
include(../externals/tinyxml/tinyxml.pri)
BASEPATH = $${TINYXML_DIR}
include($${TINYXML_DIR}tinyxml.pri)
BASEPATH = ../lib/
include(../lib/lib.pri)
@ -19,23 +20,17 @@ include(../lib/lib.pri)
SOURCES += ../cli/cmdlineparser.cpp \
../cli/cppcheckexecutor.cpp \
../cli/filelister.cpp \
../cli/pathmatch.cpp \
../cli/threadexecutor.cpp \
testpathmatch.cpp
../cli/filelister_unix.cpp \
../cli/filelister_win32.cpp \
../cli/threadexecutor.cpp
HEADERS += ../cli/cmdlineparser.h \
../cli/cppcheckexecutor.h \
../cli/filelister.h \
../cli/pathmatch.h \
../cli/filelister_unix.h \
../cli/filelister_win32.h \
../cli/threadexecutor.h
# test/*
# Note:
# testfilelister_unix.cpp omitted since there is test fail when run in QtCreator
# Test assumes the test (executable) is built from the test directory (or
# directory containing source files). But QtCreator builds to separate build
# directory. Hence the test does not find the source files.
HEADERS += options.h redirect.h testsuite.h
SOURCES += options.cpp \
testautovariables.cpp \
@ -56,7 +51,6 @@ SOURCES += options.cpp \
testoptions.cpp \
testother.cpp \
testpath.cpp \
testpathmatch.cpp \
testpostfixoperator.cpp \
testpreprocessor.cpp \
testrunner.cpp \
@ -64,7 +58,6 @@ SOURCES += options.cpp \
testsimplifytokens.cpp \
teststl.cpp \
testsuite.cpp \
testsymboldatabase.cpp \
testthreadexecutor.cpp \
testtoken.cpp \
testtokenize.cpp \
@ -79,3 +72,4 @@ contains(QMAKE_CXX, cl) {
QMAKE_CXXFLAGS_WARN_ON += -W4
DEFINES += _CRT_SECURE_NO_WARNINGS
}

View File

@ -19,7 +19,7 @@
UseOfMfc="0">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;.&quot;,&quot;..\cli&quot;,&quot;..\lib&quot;,&quot;..\externals&quot;,&quot;..\externals\tinyxml&quot;,..\..\Qt\VS4.7.0\mkspecs\win32-msvc2008"
AdditionalIncludeDirectories="&quot;.&quot;,&quot;..\cli&quot;,&quot;..\lib&quot;,&quot;..\externals\tinyxml&quot;,c:\Qt\VS4.7.0\mkspecs\win32-msvc2008"
AdditionalOptions="-Zm200 -w34100 -w34189"
AssemblerListingLocation="temp\"
BufferSecurityCheck="false"
@ -72,7 +72,11 @@
UseOfMfc="0">
<Tool
Name="VCCLCompilerTool"
<<<<<<< HEAD:test/test.vcproj
AdditionalIncludeDirectories="&quot;.&quot;,&quot;..\cli&quot;,&quot;..\lib&quot;,&quot;..\externals&quot;,&quot;..\externals\tinyxml&quot;,..\..\Qt\VS4.7.0\mkspecs\win32-msvc2008"
=======
AdditionalIncludeDirectories="&quot;.&quot;,&quot;..\cli&quot;,&quot;..\lib&quot;,&quot;..\externals\tinyxml&quot;,c:\Qt\VS4.7.0\mkspecs\win32-msvc2008"
>>>>>>> 8e379f65ec6b29de134be4013536fafe4d760a1c:test/test.vcproj
AdditionalOptions="-Zm200 -w34100 -w34189"
AssemblerListingLocation="temp\"
BufferSecurityCheck="false"

View File

@ -50,7 +50,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;Debug|Win32&apos;">
<ClCompile>
<AdditionalIncludeDirectories>".";"..\cli";"..\lib";"..\externals";"..\externals\tinyxml";..\..\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>".";"..\cli";"..\lib";"..\externals\tinyxml";c:\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>-Zm200 -w34100 -w34189 %(AdditionalOptions)</AdditionalOptions>
<AssemblerListingLocation>temp\</AssemblerListingLocation>
<BrowseInformation>false</BrowseInformation>
@ -84,7 +84,11 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="&apos;$(Configuration)|$(Platform)&apos;==&apos;Release|Win32&apos;">
<ClCompile>
<<<<<<< HEAD:test/test.vcxproj
<AdditionalIncludeDirectories>".";"..\cli";"..\lib";"..\externals";"..\externals\tinyxml";..\..\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
=======
<AdditionalIncludeDirectories>".";"..\cli";"..\lib";"..\externals\tinyxml";c:\Qt\VS4.7.0\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
>>>>>>> 8e379f65ec6b29de134be4013536fafe4d760a1c:test/test.vcxproj
<AdditionalOptions>-Zm200 -w34100 -w34189 %(AdditionalOptions)</AdditionalOptions>
<AssemblerListingLocation>temp\</AssemblerListingLocation>
<BrowseInformation>false</BrowseInformation>

View File

@ -32,7 +32,11 @@
#include <stdexcept>
// use tinyxml with STL
<<<<<<< HEAD:test/testcppcheck.cpp
#include <tinyxml.h>
=======
#include "tinyxml.h"
>>>>>>> 8e379f65ec6b29de134be4013536fafe4d760a1c:test/testcppcheck.cpp
extern std::ostringstream errout;
extern std::ostringstream output;

View File

@ -301,9 +301,9 @@ int main(int argc, char **argv)
fout << "\n###### Build\n\n";
compilefiles(fout, libfiles, "${INCLUDE_FOR_LIB}");
compilefiles(fout, clifiles, "${INCLUDE_FOR_CLI}");
compilefiles(fout, testfiles, "${INCLUDE_FOR_TEST}");
compilefiles(fout, libfiles, "-Ilib");
compilefiles(fout, clifiles, "-Ilib -Iexternals/tinyxml -Iexternals");
compilefiles(fout, testfiles, "-Ilib -Icli -Iexternals/tinyxml -Iexternals");
return 0;
}