fu7mu4’s diary

はてなダイアリーから移転しました。

CppCheck GUI on macOS High Sierra

Japanese Page is Here

requirement

  • cmake
  • pcre (header/lib)
  • cppcheck source (git)
note for macports user

To use qmake/lrelease, add qt5 or qt4 libexec dir to PATH.

export PATH=$PATH:/opt/local/libexec/qt5/bin/

and then check qmake to work well.

qmake --version

get source

In your WORK directory, get the latest source bu git.

git clone https://github.com/danmar/cppcheck.git

qmake

Use qmake instead of Xcode.

cd cppcheck
cd gui
qmake HAVE_RULES=yes

qmake says that.

Project MESSAGE: Rules enabled - to disable them and remove the dependency on PCRE, pass HAVE_RULES=no to qmake.
Project MESSAGE: Charts disabled - to enable it pass HAVE_QCHART=yes to qmake.

Note: I do not know about Charts, sorry.

edit Makefile if you HAVE_RULES=yes and pcre is not in standard PATH (macport user)

add pcre.h directory (ex. /opt/local/include) to INCPATH
and add pcre library directory (ex. /opt/local/lib) to LIBS

18c18
< INCPATH       = -I. -I. -I../lib -I../externals -I../externals/simplecpp -I../externals/tinyxml -I../lib -I/opt/local/libexec/qt5/lib/QtPrintSupport.framework/Headers -I/opt/local/libexec/qt5/lib/QtWidgets.framework/Headers -I/opt/local/libexec/qt5/lib/QtGui.framework/Headers -I/opt/local/libexec/qt5/lib/QtCore.framework/Headers -Itemp -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/AGL.framework/Headers -Itemp -I/opt/local/libexec/qt5/mkspecs/macx-clang -F/opt/local/libexec/qt5/lib
 ---
> INCPATH       = -I. -I. -I../lib -I../externals -I../externals/simplecpp -I../externals/tinyxml -I/opt/local/include -I../lib -I/opt/local/libexec/qt5/lib/QtPrintSupport.framework/Headers -I/opt/local/libexec/qt5/lib/QtWidgets.framework/Headers -I/opt/local/libexec/qt5/lib/QtGui.framework/Headers -I/opt/local/libexec/qt5/lib/QtCore.framework/Headers -Itemp -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/AGL.framework/Headers -Itemp -I/opt/local/libexec/qt5/mkspecs/macx-clang -F/opt/local/libexec/qt5/lib
41c41
< LIBS          = $(SUBLIBS) -F/opt/local/libexec/qt5/lib -L/Users/dote/Documents/work/cppcheckdoc/cppcheck/gui/../externals -L../externals -lpcre -framework QtPrintSupport -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL
 ---
> LIBS          = $(SUBLIBS) -F/opt/local/libexec/qt5/lib -L/opt/local/lib -L/Users/dote/Documents/work/cppcheckdoc/cppcheck/gui/../externals -L../externals -lpcre -framework QtPrintSupport -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL

generate cppcheck-gui.app

execute make to generate cppcheck-gui.app

make

add localization into cppcheck-gui.app

make a qm file from ts file in your language and put it in cppcheck-gui.app

In this example, I choosed japanese ts.

lrelease cppcheck_ja.ts -qm cppcheck_ja.qm
mv cppcheck_ja.qm cppcheck-gui.app/Contents/MacOS/

add cfg directory into cppcheck-gui.app

just copy cfg directory to cppcheck-gui.app

cp -R cfg cppcheck-gui.app/Contents/MacOS/

run cppcheck-gui.app

open cppcheck-gui.app