CMAKE_SYSROOT和CMAKE_FIND_ROOT_PATH的区别
-
CMAKE_FIND_ROOT_PATH用来控制find_*命令搜索路径的前缀。
# 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)
-
CMAKE_SYSROOT的参数会被find_*命令用作搜索路径的前缀。并且会传递给编译器的 –sysroot 参数,那么此时究竟作用是什么就取决于编译器了。并且这一参数还有细分:
- CMAKE_SYSROOT_COMPILE: used only for compiling sources and not linking.
- CMAKE_SYSROOT_LINK: used only for linking and not compiling sources.