linux-为什么CMake不尊重LIBRARY_PATH和CPATH

我在使用模块的HPC系统上使用CMake.这些模块通常设置LIBRARY_PATH和CPATH,因此可以简单地包含头文件并针对库进行链接,而无需其他-L或-I.

但是,使用CMake时,CMake必须找到这些库.我希望CMake自动考虑LIBRARY_PATH和CPATH并在例如CMAKE_SYSTEM_LIBRARY_PATH和CMAKE_SYSTEM_INCLUDE_PATH,但不是.

是否有任何理由说明为什么这样做(未完成)?

将LIBRARY_PATH附加到CMAKE_SYSTEM_LIBRARY_PATH并将CPATH附加到CMAKE_SYSTEM_INCLUDE_PATH是不是一个好主意(现在是手动,以后是CMake自动)?

最佳答案

Is there any reasoning why this was (not) done?

Wouldn’t it be a good idea (for now manually, later automatically by CMake) to append LIBRARY_PATH to CMAKE_SYSTEM_LIBRARY_PATH and CPATH to CMAKE_SYSTEM_INCLUDE_PATH?

还有一种观点认为,让构建依赖于环境变量会导致构建不可靠. From GNU Make manual

It is not wise for makefiles to depend for their functioning on environment variables set up outside their control, since this would cause different users to get different results from the same makefile. This is against the whole purpose of most makefiles.

转载注明原文:linux-为什么CMake不尊重LIBRARY_PATH和CPATH - 代码日志