From de18551d5c828d24782c1b305c3c5d76e0c13e30 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Thu, 31 Mar 2011 09:00:37 +0200 Subject: [PATCH 1/2] Addition of a build option for rule support in a CMake script (bug #2679, #2524) A build option was added to the main CMake script which provides the feature selection if the support for check rules will be included in the generated software. http://sourceforge.net/apps/trac/cppcheck/ticket/2679 Signed-off-by: Markus Elfring --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 819d43186c4..cadb547d9a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,13 @@ PROJECT(CPPCHECK) set(CMAKE_MODULE_PATH "${CPPCHECK_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) +option(CPPCHECK_BUILD_USE_RULES "Would you like to use customised check rules? +See also: +http://sourceforge.net/projects/cppcheck/files/Articles/writing-rules-1.pdf/download +(Software components which support the processing of Perl-compatible regular +expressions will be required for the build system if this feature is enabled.)" + ON) + # 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 From c21c2d5ce99adb1fca40511fe6195186f2d21c4b Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Thu, 31 Mar 2011 09:16:07 +0200 Subject: [PATCH 2/2] Use of the build option for rule support in CMake scripts (bug #2679, #2524) The support for check rules will be included in the generated software if this feature was enabled by the corresponding build option. The compilation and link parameters will be adjusted accordingly. http://sourceforge.net/apps/trac/cppcheck/ticket/2679 Signed-off-by: Markus Elfring --- cli/CMakeLists.txt | 7 +++++++ lib/CMakeLists.txt | 10 ++++++++++ test/CMakeLists.txt | 7 +++++++ 3 files changed, 24 insertions(+) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 840d8a434db..ed8bf519bf8 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -1,5 +1,12 @@ # Minimal CMake build file to build cppcheck command line executable +if(CPPCHECK_BUILD_USE_RULES) + find_package(PCRE REQUIRED) + add_definitions(-DHAVE_RULES) + include_directories("${PCRE_INCLUDE_DIR}") + set(CHECK_LIBS ${PCRE_LIBRARIES}) +endif() + set(TINYXML_INCLUDE_DIR "${CPPCHECK_SOURCE_DIR}/externals/tinyxml/") SET(CHECKCLI_SRCS diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 5ea9334cd82..ebe2fbf8125 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -4,6 +4,12 @@ # - tests # - Qt GUI +if(CPPCHECK_BUILD_USE_RULES) + find_package(PCRE REQUIRED) + add_definitions(-DHAVE_RULES) + include_directories("${PCRE_INCLUDE_DIR}") +endif() + set(CPPCHECK_LIB_DIR "") include("library_sources.cmake") @@ -12,3 +18,7 @@ if (CMAKE_COMPILER_IS_GNUCXX) endif (CMAKE_COMPILER_IS_GNUCXX) add_library(checklib STATIC ${CPPCHECK_LIB_SOURCES}) + +if(CPPCHECK_BUILD_USE_RULES) + target_link_libraries(checklib ${PCRE_LIBRARIES}) +endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f0450172075..1aca646d72a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,12 @@ # Minimal CMake build file to build cppcheck test suite +if(CPPCHECK_BUILD_USE_RULES) + find_package(PCRE REQUIRED) + add_definitions(-DHAVE_RULES) + include_directories("${PCRE_INCLUDE_DIR}") + set(CHECK_LIBS ${PCRE_LIBRARIES}) +endif() + set(TINYXML_INCLUDE_DIR "${CPPCHECK_SOURCE_DIR}/externals/tinyxml/") SET(CHECKTEST_SRCS