I am setting up cppcheck development environment using VS Code on windows. I am interested in building and installing cppcheck on command line . I am planning to use this command line in VS Code "task". I am using cmake to generate build scripts. They work alright as far as build is concern but install tries to install it in "C:\Program Files\". For development purpose I don't prefer it to install there. I want to provide custom directory. So after some digging around I realized I need to use following command from inside directory "/cppcheck/build" to generate build scripts -
and to install cppcheck in <custom_install_directory> I need to run following command</custom_install_directory>
cmake -DBUILD_TYPE=Debug -P cmake_install.cmake
But to make this work I had to update file /cppcheck/cmake/compilerDefinitions.cmake to add line -
add_definitions(-DFILESDIR="${FILESDIR}") for Windows (MSVC).
Now it works perfect and I can easily integrate this with VS Code but I wanted to ask community over here if I am doing this right or is there better way of doing this. Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm not sure, as far as I know we rarelly use windows for development. But of course, it should work and feel free to do it.
I do not install Cppcheck during development. Not sure why you would do that? Can't you just execute Cppcheck directly?
I think it's possible that the windows installation in cmake is not used much and lacks some important feature. The FILESDIR is intended to be used when you have the binary in one place and data files in other places. In Windows the release binary and data files are put in the same place so FILESDIR is not used. So well why don't you install it to the same place?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
On Windows cppcheck.exe is generated in the folder
"/cppcheck/build/bin/Debug". It can't be used from that location as all
other files it depends on are in folder "/cppcheck". By the way directory
build is created by me under cppcheck.
I probably can copy cppcheck.exe to folder "/cppcheck" and it should work.
But I would be making assumption here and may run into mysterious behavior
in future if there are changes in dependencies. So I wanted to use install
script rather than one off copy of cppcheck.exe. What is your
recommendation? Thank you
I'm not sure, as far as I know we rarelly use windows for development. But
of course, it should work and feel free to do it.
I do not install Cppcheck during development. Not sure why you would do
that? Can't you just execute Cppcheck directly?
I think it's possible that the windows installation in cmake is not used
much and lacks some important feature. The FILESDIR is intended to be
used when you have the binary in one place and data files in other places.
In Windows the release binary and data files are put in the same place so
FILESDIR is not used. So well why don't you install it to the same place?
Sorry but I can't offer very good advice I guess. If the cppcheck development environment in windows is a bit broken it would be good to fix it.
On Windows cppcheck.exe is generated in the folder
"/cppcheck/build/bin/Debug". It can't be used from that location as all
other files it depends on are in folder "/cppcheck". By the way directory
build is created by me under cppcheck.
Yes that is normal.
I probably can copy cppcheck.exe to folder "/cppcheck" and it should work.
But I would be making assumption here and may run into mysterious behavior
in future if there are changes in dependencies.
yes that could work. However it is not very elegant and as you say that may cause future problems with dependencies and other problems.
I think that the most elegant solution would be to use FILESDIR. As you already suggested. However no installation is needed. If that points at your root cppcheck folder then the /cppcheck/build/bin/Debug/cppcheck.exe should work in place. So no installation/copying is needed.
Then the question is if our cmake files support FILESDIR in windows. I must say I am a bit surprised if that is not supported in windows right now. But well if it isn't then a fix for that would be a good thing. Feel free to open a github pull request that fixes that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think that the most elegant solution would be to use FILESDIR. As you
already suggested. However no installation is needed. If that points at
your root cppcheck folder then the /cppcheck/build/bin/Debug/cppcheck.exe
should work in place. So no installation/copying is needed.
I tried this but it didn't work. The /cppcheck/cmake/options.cmake has
following line -
It appends /share/cppcheck to the path. So FILESDIR is set to
/cppcheck/share/cppcheck. But this location is missing and cppcheck
complains about it. I am not certain how all this
works on Linux. It looks like there isn't much difference in how FILESDIR
is set on Linux. That means /share/cppcheck is added to path on Linux too.
Does that mean this directory is
generated on Linux? I am just curious. if I understand that then I can try
to commenize behavior across Windows and linux.
Sorry but I can't offer very good advice I guess. If the cppcheck
development environment in windows is a bit broken it would be good to fix
it.
On Windows cppcheck.exe is generated in the folder
"/cppcheck/build/bin/Debug". It can't be used from that location as all
other files it depends on are in folder "/cppcheck". By the way directory
build is created by me under cppcheck.
Yes that is normal.
I probably can copy cppcheck.exe to folder "/cppcheck" and it should work.
But I would be making assumption here and may run into mysterious behavior
in future if there are changes in dependencies.
yes that could work. However it is not very elegant and as you say that
may cause future problems with dependencies and other problems.
I think that the most elegant solution would be to use FILESDIR. As you
already suggested. However no installation is needed. If that points at
your root cppcheck folder then the /cppcheck/build/bin/Debug/cppcheck.exe
should work in place. So no installation/copying is needed.
Then the question is if our cmake files support FILESDIR in windows. I
must say I am a bit surprised if that is not supported in windows right
now. But well if it isn't then a fix for that would be a good thing. Feel
free to open a github pull request that fixes that.
Of Course I have changed /cppcheck/cmake/compilerDefinitions.cmake to add
following line for windows too -
add_definitions(-DFILESDIR="${FILESDIR}")
I think it's not working for you probably because this is missing from
your compilerDefinitions.cmake. I can see that on github the same is
suggested.
Thank you for following up and raising this on github. Let me know if I am
of any help on this. I am all set now to contribute.
Hello,
I am setting up cppcheck development environment using VS Code on windows. I am interested in building and installing cppcheck on command line . I am planning to use this command line in VS Code "task". I am using cmake to generate build scripts. They work alright as far as build is concern but install tries to install it in "C:\Program Files\". For development purpose I don't prefer it to install there. I want to provide custom directory. So after some digging around I realized I need to use following command from inside directory "/cppcheck/build" to generate build scripts -
cmake -DCMAKE_INSTALL_PREFIX=<custom_install_directory> ..\</custom_install_directory>
and to install cppcheck in <custom_install_directory> I need to run following command</custom_install_directory>
cmake -DBUILD_TYPE=Debug -P cmake_install.cmake
But to make this work I had to update file /cppcheck/cmake/compilerDefinitions.cmake to add line -
add_definitions(-DFILESDIR="${FILESDIR}") for Windows (MSVC).
Now it works perfect and I can easily integrate this with VS Code but I wanted to ask community over here if I am doing this right or is there better way of doing this. Thank you.
I'm not sure, as far as I know we rarelly use windows for development. But of course, it should work and feel free to do it.
I do not install Cppcheck during development. Not sure why you would do that? Can't you just execute Cppcheck directly?
I think it's possible that the windows installation in cmake is not used much and lacks some important feature. The
FILESDIR
is intended to be used when you have the binary in one place and data files in other places. In Windows the release binary and data files are put in the same place so FILESDIR is not used. So well why don't you install it to the same place?On Windows cppcheck.exe is generated in the folder
"/cppcheck/build/bin/Debug". It can't be used from that location as all
other files it depends on are in folder "/cppcheck". By the way directory
build is created by me under cppcheck.
I probably can copy cppcheck.exe to folder "/cppcheck" and it should work.
But I would be making assumption here and may run into mysterious behavior
in future if there are changes in dependencies. So I wanted to use install
script rather than one off copy of cppcheck.exe. What is your
recommendation? Thank you
On Sun, Nov 8, 2020 at 3:47 AM "Daniel Marjamäki" danielmarjamaki@users.sourceforge.net wrote:
Sorry but I can't offer very good advice I guess. If the cppcheck development environment in windows is a bit broken it would be good to fix it.
Yes that is normal.
yes that could work. However it is not very elegant and as you say that may cause future problems with dependencies and other problems.
I think that the most elegant solution would be to use FILESDIR. As you already suggested. However no installation is needed. If that points at your root cppcheck folder then the /cppcheck/build/bin/Debug/cppcheck.exe should work in place. So no installation/copying is needed.
Then the question is if our cmake files support FILESDIR in windows. I must say I am a bit surprised if that is not supported in windows right now. But well if it isn't then a fix for that would be a good thing. Feel free to open a github pull request that fixes that.
I tried this but it didn't work. The /cppcheck/cmake/options.cmake has
following line -
set(FILESDIR
${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME} CACHE STRING "Cppcheck files
directory")
It appends /share/cppcheck to the path. So FILESDIR is set to
/cppcheck/share/cppcheck. But this location is missing and cppcheck
complains about it. I am not certain how all this
works on Linux. It looks like there isn't much difference in how FILESDIR
is set on Linux. That means /share/cppcheck is added to path on Linux too.
Does that mean this directory is
generated on Linux? I am just curious. if I understand that then I can try
to commenize behavior across Windows and linux.
On Sun, Nov 8, 2020 at 11:33 PM "Daniel Marjamäki" danielmarjamaki@users.sourceforge.net wrote:
hmm.. I see similar problems when I try to cmake file in Linux.
maybe those that use cmake more can give better answers. I wrote a question here also: https://github.com/danmar/cppcheck/commit/488813d00fab8278a78d518cf0d3d6651c8f0caa
Which compiler do you use? If you use clang/mingw/cygwin then I believe that the cppcheck/Makefile should work.
Abhijit:
This works for me in Linux:
Could you test similar commands in windows?
Abhijit: I tried cmake in windows myself and it fails for me also. Something is not working well.
I think it should work if you write :
cmake -DFILESDIR=<full path for cppcheck> -G"..." ..
but it doesn't ..Daniel,
Perfect ! It works for me -
cmake -DFILESDIR=C:/Users/Abhijit/Software/cppcheck ..\
Of Course I have changed /cppcheck/cmake/compilerDefinitions.cmake to add
following line for windows too -
add_definitions(-DFILESDIR="${FILESDIR}")
I think it's not working for you probably because this is missing from
your compilerDefinitions.cmake. I can see that on github the same is
suggested.
Thank you for following up and raising this on github. Let me know if I am
of any help on this. I am all set now to contribute.
On Tue, Nov 10, 2020 at 12:52 PM "Daniel Marjamäki" danielmarjamaki@users.sourceforge.net wrote: