Hey
I want to install an object library but i met a problem with the directory where the object file are installed
install(TARGETS ${PROJECT_TARGET_NAME}
EXPORT "${PROJECT_TARGET_NAME}Targets"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/$<CONFIG>
FILE_SET headers
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILE_SET headers_generated_export
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILE_SET headers_generated_version
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
OBJECTS
DESTINATION "obj"
)
I thought my OBJECTS file will be installed on the obj
directory but they are installed on
obj/objects-<CONFIG>/${PROJECT_TARGET_NAME}/
Any ideas ?
Thanks in advance and have a good day !
After some investigation, this is not possible to change that directory.
Here is the source code
std::string computeInstallObjectDir(cmGeneratorTarget* gt,
std::string const& config)
{
std::string objectDir = "objects";
if (!config.empty()) {
objectDir += "-";
objectDir += config;
}
objectDir += "/";
objectDir += gt->GetName();
return objectDir;
}
case cmStateEnums::OBJECT_LIBRARY: {
// Compute all the object files inside this target
std::vector<std::string> objects;
this->Target->GetTargetObjectNames(config, objects);
files.Type = cmInstallType_FILES;
files.NoTweak = true;
files.FromDir = this->Target->GetObjectDirectory(config);
files.ToDir = computeInstallObjectDir(this->Target, config);
for (std::string& obj : objects) {
files.From.emplace_back(obj);
files.To.emplace_back(std::move(obj));
}
return files;
}
Does anyone know why the path is hard-computed especially for object library ?
brad.king
(Brad King)
August 15, 2024, 1:19pm
3
The OBJECTS DESTINATION
option to install(TARGETS)
specifies a base directory under which to install object files. Within that the layout is designed to avoid conflicts in cases like same-named sources in different directories.
CMake Issue 25407 requests more granular controls over this behavior.