Are you asking whether the ONLY_CMAKE_FIND_ROOT_PATH will cause CMake to pass a flag to the compiler to drop default search paths when compiling? If that is the question, I don’t think so. Other than that, I’m not sure what find_* command control variables have to do with default compiler search paths.
Thank you very much for your reply, and I apologize for causing confusion. Allow me to provide a specific description of my question:
When using the following CMake variables:
# where is the target environment located
set(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc
/home/alex/mingw-install)
# adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
For gcc or g++ or ld, will it override their default paths for searching header files or library files? I believe this is important for cross-compilation scenarios.
If I understand your question correctly, no. These variables do nothing to set up include paths to find the files. I suspect that the toolchain file needs to provide the setup for this itself (as projects shouldn’t have to guess at cross-compile setups on their own).
Your code snippet has some “mingw” references:
You have to configure CMake to use the mingw compiler executables. In general cross-compilation is not done with your host compiler.