pass on alternative g++ version to CMake settings?
For compiling a CMake project on a system that has /usr/bin/g++-7 as its default compiler, I am using the alternative /usr/bin/g++-9 to be able to use the std::filesystem functions (-std=g++-2a). The command g++-9 -std=gnu++-2a exits as expected -- the standard option is recognised.
In the Settings -> Build Settings I am using {C++ Compiler, /usr/bin/g++-9}, {C Compiler, /usr/bin/gcc-9}, {Linker, /usr/bin/g++-9}, {Shared Object Linker, /usr/bin/g++-9 -shared -fPIC}, {Archive, /usr/bin/gcc-ar-9 rcu}. The assembler, make and gdb commands do not have specific versions.
Then after 'Run Cmake' and 'Build', the output pane shows:
Code: Select all
...
/usr/bin/c++ [ ... many options and files ... ] -std=gnu++2a [ ... more options and files ]
c++: error: unrecognized command line option '-std=gnu++2a'; did you mean '-std=gnu++03'?
c++: error: unrecognized command line option '-std=gnu++2a'; did you mean '-std=gnu++03'?
...
The CMakeOutput.log file is full of calls to
Code: Select all
/usr/bin/cc
and in the project's CMakeCache.txt it says:
Code: Select all
...
CMakeCache.txt:CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
CMakeCache.txt:CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-7
CMakeCache.txt:CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-7
CMakeCache.txt:CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc
CMakeCache.txt:CMAKE_C_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-7
CMakeCache.txt:CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-7
...
This happens again if I delete all those files and re-run CMake. So it not only doesn't select the version of g++ (cc?) specified in the Build Settings, but also does explicitly select a different version than specified in the Build Settings.
Isn't that odd? And is it possible to control these CMake settings via the plugin in CodeLite?