ecmwf / ecbuild

A CMake-based build system, consisting of a collection of CMake macros and functions that ease the managing of software build systems
https://ecbuild.readthedocs.io
Apache License 2.0
26 stars 25 forks source link

Incorrect handling of absolute CMAKE_INSTALL_{BIN,INCLUDE,LIB}DIR #40

Open alexshpilkin opened 2 years ago

alexshpilkin commented 2 years ago

As per title: multiple places in the code assume that INSTALL_{BIN,INCLUDE,LIB}_DIR are relative and yield broken output when they are absolute. That by itself would not be a problem, even if the comments are kind of fuzzy on whether these must or only should be relative (the way the code creates and populates ${PROJECT_NAME}_FULL_INSTALL_{BIN,INCLUDE,LIB}_DIR suggests the latter)—they are private to this build system after all. But if not set explicitly they get populated from the CMake-standard CMAKE_INSTALL_{BIN,INCLUDE,LIB}DIR, which definitely can be absolute. NixOS in particular passes absolute paths there whenever CMake is used and thereby exposes the problem.

A non-exhaustive list of occurrences of this problem is:

Jan Tojnar’s note linked above has more discussion of this problem in the general case. With the FULL variables already populated, all the tools to fix it here seem to be already in place, except they cannot be referenced from generic templates via @-expansion because their names depend on the name of the project (for reasons I don’t understand and so leave for you to examine).