Issue
The title pretty much already sums up my problem:
When creating a library with add_library(SHARED)
, cmake creates two files, the actual library (.so/.dll) and the import library (.a/.lib)
That, by itself, is not a problem.
But when I call install(TARGETS ${PROJECT_NAME} DESTINATION ${DeploymentFolder})
, it also installs both files, the shared library and its import.
I only want the shared library to be installed, because they're only being used as runtime libraries. They're not supposed to be linked to anything but the executable also in the deployment folder.
Any ideas aside from using FILES
to specify the name explicitly?
FWIW, the environment is a Qt installation on Windows.
Solution
CMake supports several kinds of artifacts which can be installed. By default, for a SHARED library on Windows both RUNTIME (.dll
) and ARCHIVE (.lib
) are selected (documentation). But you may explicitly specify which artifacts you need:
install(TARGETS ${PROJECT_NAME}
RUNTIME # Installs only '.dll' part of the library
DESTINATION ${DeploymentFolder})
If you want to support both Windows and Linux, you may specify RUNTIME and LIBRARY kinds: the latter one is for installing .so
:
install(TARGETS ${PROJECT_NAME}
RUNTIME # Installs only '.dll' part of the shared library on Windows
# Does nothing for libraries on Linux
DESTINATION ${DeploymentFolder}
LIBRARY # Installs shared library on Linux
# Does nothing for shared libraries on Windows
DESTINATION ${DeploymentFolder})
Answered By - Tsyvarev Answer Checked By - Timothy Miller (WPSolving Admin)