Use CMake toolchain files for setting toolchain variables #161
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #159
This propperly implements cross-compiling for the c++/c extensions, using toolchain files for each target. This allows CMake to detect when it is cross-compiling, and act accordingly. For example, CMake will set the
CMAKE_CROSS_COMPILINGvariable, which can be used by extensions as intended. The faiss extension started to support CUDA recently, and this needsCMAKE_CROSS_COMPILINGto be set for it to detect the correct libraries. Currently this is done manually in our Makefile, but this is suboptimal.The biggest benefit is the fact that all the variables are now in one place, they are no longer split between the yaml file, and the makefile. For example the rust and OSX variables were in the Makefile, but all flags relates to c and c++ were in the yaml. Having a unified location also makes adding toolchains easier. Adding the variables for CUDA would either turn the makefile into a long list of checks and a mess of variables. Being able to do this in CMake is both easier and cleaner.