Giter VIP home page Giter VIP logo

Comments (3)

nanoant avatar nanoant commented on August 14, 2024

I have spent a while investigating this and this is indeed pretty tricky to carry CXX_STANDARD to PCH target. The problem that current CMake implementation for selecting C++ standard is pretty complicated and uses combination of CMAKE_CXX??_STANDARD/EXTENSION_COMPILE_OPTION compiler defined variables and custom dedicated code of cmLocalGenerator::AddCompilerRequirementFlag that adds these flags.

I tried to convince CMake to add these for PCH target too adding relevant entries in CMakeCXXPCHCompiler.cmake.in as it check if the compiler has CMAKE_ + lang + _STANDARD_DEFAULT defined, but it seems to be not enough.

FYI current baked in solution provided by @mick-p1982 simply bakes -std=gnu++<STD> rather using the CMakes built-in complicated C++ standard flags handling. That is why you get wrong standard. For now you can simply replace -std=gnu++ with -std=c++ and I believe this should do the job for you.

I am rather short on time for this project and already spend couple of hours yesterday, so any help would be appreciated.

from cmakepchcompiler.

drizt avatar drizt commented on August 14, 2024

Hm. I think maybe it is possible to use CMAKE_EXPORT_COMPILE_COMMANDS to get exact compile command? It will work only with Ninja and Unix Makefile generators. I tried it with my project so output:

[
{
  "directory": "/home/taurus/develop/torrent-file-editor/release-qt5",
  "command": "/usr/lib64/ccache/g++  -DHAVE_QT5 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_WIDGETS_LIB -I../ -I. -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtCore -isystem /usr/lib64/qt5/mkspecs/linux-g++ -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtWidgets   -std=c++11 -Wall -Wextra -pedantic -Werror -Wno-error=cpp -O2 -DNDEBUG   -fPIC -std=gnu++11 -o CMakeFiles/torrent-file-editor.dir/application.cpp.o -c /home/taurus/develop/torrent-file-editor/application.cpp",
  "file": "/home/taurus/develop/torrent-file-editor/application.cpp"
}
]

from cmakepchcompiler.

m-7761 avatar m-7761 commented on August 14, 2024

If there is no way to detect it with CMake then there has to be a parameter added to module's commands.

I should add that C++XX should be a subset of gnu++XX. The module is supposed to just give your what you need to do PCH with CMake for popular platforms. If switching to gnu++ standard is a bridge too far, then you don't really require PCH for your project!

from cmakepchcompiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.