Menu

cmake generated install script on windows.

2020-11-08
2020-11-10
  • Abhijit Sawant

    Abhijit Sawant - 2020-11-08

    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.

     
  • Daniel Marjamäki

    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?

     
    • Abhijit Sawant

      Abhijit Sawant - 2020-11-09

      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:

      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?


      cmake generated install script on windows.
      https://sourceforge.net/p/cppcheck/discussion/development/thread/3ea5fd6d24/?limit=25#2e5c


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cppcheck/discussion/development/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
      • Daniel Marjamäki

        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.

         
        • Abhijit Sawant

          Abhijit Sawant - 2020-11-10

          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 -

          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:

          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.


          cmake generated install script on windows.
          https://sourceforge.net/p/cppcheck/discussion/development/thread/3ea5fd6d24/?limit=25#2e5c/883a/7d6d


          Sent from sourceforge.net because you indicated interest in
          https://sourceforge.net/p/cppcheck/discussion/development/

          To unsubscribe from further messages, please visit
          https://sourceforge.net/auth/subscriptions/

           
  • Daniel Marjamäki

    Which compiler do you use? If you use clang/mingw/cygwin then I believe that the cppcheck/Makefile should work.

     
  • Daniel Marjamäki

    Abhijit:

    This works for me in Linux:

    cd /home/danielm/cppcheck
    mkdir build
    cd build
    cmake -DFILESDIR=/home/danielm/cppcheck ..
    make
    bin/cppcheck ../lib/token.cpp
    

    Could you test similar commands in windows?

     
  • Daniel Marjamäki

    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 ..

     
    • Abhijit Sawant

      Abhijit Sawant - 2020-11-10

      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:

      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 ..</full>


      cmake generated install script on windows.
      https://sourceforge.net/p/cppcheck/discussion/development/thread/3ea5fd6d24/?limit=25#1934


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/cppcheck/discussion/development/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.