Why does CMake not respect LIBRARY_PATH and CPATH

2020-04-21 01:57发布

I'm using CMake on a HPC system that uses modules. Those modules usually set LIBRARY_PATH and CPATH so one can simply include headers and link against libraries without additional -L or -I.

However when using CMake those libraries must be found by CMake. I would expect, that LIBRARY_PATH and CPATH were automatically considered by CMake and captured in e.g. CMAKE_SYSTEM_LIBRARY_PATH and CMAKE_SYSTEM_INCLUDE_PATH but they are not.

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?

标签: linux cmake
1条回答
唯我独甜
2楼-- · 2020-04-21 02:57

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?

There is another view that having your build depend on environment variables results in unreliable builds. 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.

查看更多
登录 后发表回答