Check for working C compiler: /usr/bin/cc - works Check for working C compiler: /usr/bin/cc The CXX compiler identification is GNU 9.3.0 The C compiler identification is GNU 9.3.0 DCMAKE_PREFIX_PATH=/usr/lib/llvm/10 -Wno-dev What should be passed to cmake to find the required libraries and includes?Įrror occurs with or without passing -DCMAKE_PREFIX_PATH (from upstream Mac build instructions):Ĭmake. When I build zig-9999.ebuild w LLVM 10 patch or when building from git master as per upstream instructions, I get a cmake error shown below. Using a buildsystem generator makes your project more future-proof.Gentoo Forums :: View topic - zig w llvm10 cmake missing _LIBRARIES INCL_DIRS CMake itself also provides some nice features like dependency detection, library interface management, or integration with CTest, CDash and CPack. I would always recommend using CMake (or another buildsystem generator, but CMake is my personal preference) if you intend your project to be multi-platform or widely usable. If you have Windows developers used to Visual Studio and Unix developers who swear by GNU Make, CMake is (one of) the way(s) to go. So if you have a platform-independent project, CMake is a way to make it buildsystem-independent as well. From the same starting point, the same CMakeLists.txt file. It can produce Makefiles, it can produce Ninja build files, it can produce KDEvelop or Xcode projects, it can produce Visual Studio solutions. Make (or rather a Makefile) is a buildsystem - it drives the compiler and other build tools to build your code.ĬMake is a generator of buildsystems. Putting this all together you can write a shell wrapper which sets up the environment variables CC and CXX and then invokes cmake with the mentioned variable overrides.Īlso see this CMake FAQ on make override files. This variable is honored by the CMakeFindBinUtils module: $ cmake -D_CMAKE_TOOLCHAIN_PREFIX=llvm. įinally to force the use of the LLVM binutils, set the internal variable _CMAKE_TOOLCHAIN_PREFIX. Then invoke cmake in the following way: $ cmake -DCMAKE_USER_MAKE_RULES_OVERRIDE=~/ClangOverrides.txt. The suffix _INIT will make CMake initialize the corresponding *_FLAGS variable with the given value. SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") SET (CMAKE_C_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") Create a file ~/ClangOverrides.txt with the following contents: SET (CMAKE_C_FLAGS_INIT "-Wall -std=c99") The compiler specific flags can be overridden by putting them into a make override file and pointing the CMAKE_USER_MAKE_RULES_OVERRIDE variable to it. The CXX compiler identification is Clang not just adding them into a project's CMakeLists.txt)?Īlso, is it necessary to use the llvm-* programs rather than the system defaults when compiling using clang instead of gcc? What's the difference?ĬMake honors the environment variables CC and CXX upon detecting the C and C++ compiler to use: $ export CC=/usr/bin/clang Is there an easy way of switching between these and the default GCC variables, preferably as a system-wide change rather than project specific (i.e. SET (CMAKE_RANLIB "/usr/bin/llvm-ranlib") SET (CMAKE_OBJDUMP "/usr/bin/llvm-objdump") SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") SET (CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG") SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") SET (CMAKE_CXX_COMPILER "/usr/bin/clang++") SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") SET (CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG") SET (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") I believe (please correct me if I'm mistaken!) that to use Clang I need to set the following: SET (CMAKE_C_COMPILER "/usr/bin/clang") I have a number of projects built using CMake and I'd like to be able to easily switch between using GCC or Clang/LLVM to compile them.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |