Reputation: 327
I am compiling clang 11.1.0 from source and I want it to be configured to use an alternative sysroot by default, such that when I compile a program using clang it will take the system headers and libraries from this alternative sysroot path by default.
For example suppose I have /path/to/my/toolchain
as my sysroot.
When I configured and built gcc I used the options --with-sysroot=/path/to/my/toolchain
and --with-native-headers=/path/to/my/toolchain
. Now every time I compile a program with gcc it takes the system headers/libraries automatically from /path/to/my/toolchain
.
I want to do the same with clang. The only way I could get it working so far is to have the option -isysroot /path/to/my/toolchain
every time I compile a program. Is there a way to specify the sysroot path when compiling clang so that it becomes the default sysroot when running clang?
Upvotes: 1
Views: 4781
Reputation: 9324
Use DEFAULT_SYSROOT
cmake variable. E.g. cmake -DDEFAULT_SYSROOT=<your_sysroot_path>
Upvotes: 3