Set( CMAKE_C_COMPILER $/clang++ CACHE PATH "clang++" ) The trick is to disable the compiler detection with NONE, set the paths with FORCE, then enable_language. This happens because it triggers a re-configure. I wanted to compile with an alternate compiler, but also pass -D options on the command-line which would get wiped out by setting a different compiler. When using an export before running CMake it is set to /usr/lib/llvm-3.8/bin/llvm-ar.Ĭhange CMAKE_COMPILER path without triggering a reconfigure When you override the compiler value in a script, it's "too late", all checks and detections are already done.įor instance, on my machine with gcc as default compiler, when using the set command to /usr/bin/clang, ar is set to /usr/bin/gcc-ar-7. It also uses the compiler to detect related tools, like ar and ranlib. But any change will be overwritten by the set command.Įarly in the configuration process, CMake performs checks on the compiler: Does it work? Is it able to produce executables? etc. This is almost the same as the "normal" variable version, the only difference is your value will be set in the cache, so users can see it. Set(CMAKE_CXX_COMPILER /usr/bin/clang++ CACHE PATH "" FORCE) The CMAKE_C(XX)_COMPILER variable is already in the cache, so it won't get updated unless you force it.įorce cache set(CMAKE_C_COMPILER /usr/bin/clang CACHE PATH "" FORCE) Set(CMAKE_CXX_COMPILER /usr/bin/clang++ CACHE PATH "") With cache set(CMAKE_C_COMPILER /usr/bin/clang CACHE PATH "") You could just update your script each time you want to use a different compiler, but that removes the value of using CMake in the first place. This will be a problem if you have multiple build environments with different compilers. That means your compiler is now hard-coded in your build script and you cannot give it a custom value. When doing this, you create a "normal" variable CMAKE_C(XX)_COMPILER that hides the cache variable of the same name. Without cache set(CMAKE_C_COMPILER /usr/bin/clang) Let's see what happens for the three possible calls to set: force cache, to always force the cache value when configuring.with cache, to create a cached variable.without cache, to create a normal variable.When using the set command, you have three options: I recommend against overriding the CMAKE_C(XX)_COMPILER value for two main reasons: because it won't play well with CMake's cache and because it breaks compiler checks and tooling detection. UPDATE: longer explanation on why not overriding CMAKE_C(XX)_COMPILER after Jake's comment The export only needs to be done once, the first time you configure the project, then those values will be read from the CMake cache. Version g++ (GCC) 13.0.1 20230201 (experimental).Do not overwrite CMAKE_C_COMPILER, but export CC (and CXX) before calling cmake: export CC=/usr/local/bin/gcc Also the devel/c++-modules branchĬompiles to g++ version of g++ (GCC) 11.0.0 20210203 (experimental) I have also tried the same using the masterĪll of them have given the same errors. I have also tried the same using this certain patch I have tried this with g++ 11.3, g++ 12.1 installed using ubuntu package Target_link_libraries(main std_module_example) Target_link_libraries(std_module_example)įILE_SET cxx_modules TYPE CXX_MODULES FILES Set(CMAKE_CXX_COMPILER "/home/hhn/makes/gcc-install/usr/local/bin/g++") The following in the CMakeLists.txt file : G++: error: unrecognized command-line option ‘-fdep-format=trtbd’ ‘-fdep-output=CMakeFiles/std_module_example.dir/t3.cxx.o’ ‘-fdep-file=CMakeFiles/std_module_example.dir/t3.cxx.o.ddi’ G++: error: unrecognized command-line option Keep running into this issue of unrecognized command-line options. Modules, while trying to experiment with GCC support for C++ modules, I I have been working on upgrading the HPX build system to support C++
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |