[CMake] /path/to/libpng.so automatic conversion to -lpng ?
René J. V. Bertin
rjvbertin at gmail.com
Wed Jul 12 12:40:08 EDT 2017
FWIW, I do question this rewriting feature, because it clearly can go wrong.
I'd argue that programmers (or build script/cmake modules/...) usually have good
reason when they give the absolute path to a library: making darn sure it's
indeed that one that gets linked.
While I agree that replacing a full path with the -lfoo notation makes the final
command shorter and thus more readable it can also introduce subtle bugs. The
fact that a library can be found by the linker because it's on the search path
doesn't mean that the linker will find the right, intended library. In my case I
could get the correct linking by just adding -L/opt/local/lib, but what if for
some reason I had wanted to include the system libpng, i.e. if PNG_LIBRARIES had
pointed to /usr/lib/libpng.so?
I hope this is not such a corner case that Kitware haven't foreseen it and
implemented a way to deactivate the rewriting?
R.
More information about the CMake
mailing list