diff --git a/build-pcre.txt b/build-pcre.txt index b7ebf7b77..28893a92e 100644 --- a/build-pcre.txt +++ b/build-pcre.txt @@ -1,3 +1,21 @@ +PCRE is a library that is used by the optional "rules" feature. (It adds +some additional features to the command line client.) It's readily available +on Linux and Mac OS X, but must be obtained separately for Windows. + +If you're using qmake to generate makefiles, the following behavior applies: + +- If you're not on Windows, it assumes by default that you have PCRE and want + to enable rules support. + +- If you're not on Windows, you can disable rules support (removing the PCRE + dependency) by passing HAVE_RULES=no to qmake. + +- If you are on Windows, but have PCRE available, you can enable rules support + by passing HAVE_RULES=yes to qmake. + + - Note: This includes using build.bat since it calls qmake - to use PCRE and + build.bat, you need to run set HAVE_RULES=yes before each run of build.bat + Some temporary build instructions. This is work in progress. diff --git a/build.bat b/build.bat index e4abd27e5..326e1a7d2 100644 --- a/build.bat +++ b/build.bat @@ -7,6 +7,9 @@ REM where is any of cppcheck/gui/tests/all REM release or debug is the configuration REM all-target builds both cppcheck and gui. REM +REM Run the command before build.bat to enable rules using pcre: +REM set HAVE_RULES=yes +REM REM TODO: REM - run tests too @@ -36,7 +39,7 @@ goto help :cppcheck cd cli -qmake -config %TARGET% +qmake -config %TARGET% HAVE_RULES=%HAVE_RULES% %MAKE% cd .. if "%1" == "all" goto gui @@ -44,7 +47,7 @@ goto end :gui cd gui -qmake -config %TARGET% +qmake -config %TARGET% HAVE_RULES=%HAVE_RULES% %MAKE% lrelease gui.pro cd .. @@ -52,7 +55,7 @@ goto end :tests cd test -qmake -config %TARGET% +qmake -config %TARGET% HAVE_RULES=%HAVE_RULES% %MAKE% cd .. goto end diff --git a/cli/cli.pro b/cli/cli.pro index 3cd4dae43..7003c078e 100644 --- a/cli/cli.pro +++ b/cli/cli.pro @@ -5,7 +5,6 @@ INCLUDEPATH += . ../lib OBJECTS_DIR = temp CONFIG += warn_on CONFIG -= qt app_bundle -DEFINES += HAVE_RULES BASEPATH = ../externals/tinyxml/ include($$PWD/../externals/tinyxml/tinyxml.pri) diff --git a/lib/lib.pri b/lib/lib.pri index 831bf7d24..23f05e045 100644 --- a/lib/lib.pri +++ b/lib/lib.pri @@ -1,7 +1,7 @@ # no manual edits - this file is autogenerated by dmake -LIBS += -L../externals -lpcre -INCLUDEPATH += ../externals ../externals/tinyxml +include($$PWD/pcrerules.pri) +INCLUDEPATH += ../externals/tinyxml HEADERS += $${BASEPATH}check.h \ $${BASEPATH}check64bit.h \ $${BASEPATH}checkassignif.h \ diff --git a/lib/pcrerules.pri b/lib/pcrerules.pri new file mode 100644 index 000000000..9ff84c5be --- /dev/null +++ b/lib/pcrerules.pri @@ -0,0 +1,18 @@ +# On non-Windows, if the variable HAVE_RULES is empty, default to using PCRE and enabling rules +!win32:isEmpty(HAVE_RULES) { + CONFIG += use_pcre_rules +} + +# If HAVE_RULES=yes is passed to qmake, use PCRE and enable rules +contains(HAVE_RULES, [yY][eE][sS]) { + CONFIG += use_pcre_rules +} + +use_pcre_rules { + DEFINES += HAVE_RULES + LIBS += -L../externals -lpcre + INCLUDEPATH += ../externals + message("Rules enabled - to disable them and remove the dependency on PCRE, pass HAVE_RULES=no to qmake.") +} else { + message("Rules disabled - to enable them, make PCRE available and pass HAVE_RULES=yes to qmake.") +} diff --git a/tools/dmake.cpp b/tools/dmake.cpp index c7745cb7c..6ce39bd78 100644 --- a/tools/dmake.cpp +++ b/tools/dmake.cpp @@ -182,8 +182,8 @@ int main(int argc, char **argv) if (fout1.is_open()) { fout1 << "# no manual edits - this file is autogenerated by dmake\n\n"; - fout1 << "LIBS += -L../externals -lpcre\n"; - fout1 << "INCLUDEPATH += ../externals ../externals/tinyxml\n"; + fout1 << "include($$PWD/pcrerules.pri)\n"; + fout1 << "INCLUDEPATH += ../externals/tinyxml\n"; fout1 << "HEADERS += $${BASEPATH}check.h \\\n"; for (unsigned int i = 0; i < libfiles.size(); ++i) {