Issue
When trying to compile my project using cmake .
, variable CMAKE_INSTALL_LIBDIR
is empty and I have no idea why.
I'm trying to issue the following (on line 40):
install(TARGETS fpthread
EXPORT fpthread_config
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
I get the following error message:
CMake Error at CMakeLists.txt:40 (install):
install TARGETS given no LIBRARY DESTINATION for shared library target
"fpthread".
Issuing the following results in an empty string:
MESSAGE(STATUS ${CMAKE_INSTALL_LIBDIR})
I've tried both Cmake 3.5 (installed through package manager) and Cmake 3.11 (latest release, compiled from source).
Solution
Reformulating my previous comment as answer:
To access variables from the GNUInstallDirs module you need to add
include(GNUInstallDirs)
to your CMakeLists.txt file. The module is not included by default.
Answered By - vre