# Object library install dir

**URL:** <https://discourse.cmake.org/t/object-library-install-dir/11421>\
**Category:** Code\
**Tags:** os:windows\
**Created:** [August 11, 2024, 11:41am UTC](https://discourse.cmake.org/t/object-library-install-dir/11421 "2024-08-11T11:41:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingloxxy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kingloxxy/32/3800_2.png) [@kingloxxy](https://discourse.cmake.org/u/kingloxxy)\
**Post date:** [August 11, 2024, 11:41am UTC](https://discourse.cmake.org/t/object-library-install-dir/11421/1 "2024-08-11T11:41:33Z")

</div>

Hey

I want to install an object library but i met a problem with the directory where the object file are installed

```auto
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 !

---

<div class="post-metadata">

**Author:** ![kingloxxy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kingloxxy/32/3800_2.png) [@kingloxxy](https://discourse.cmake.org/u/kingloxxy)\
**Post date:** [August 14, 2024, 10:14am UTC](https://discourse.cmake.org/t/object-library-install-dir/11421/2 "2024-08-14T10:14:39Z")

</div>

After some investigation, this is not possible to change that directory.

Here is the source code

```auto
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;
}

```

```auto
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 ?

---

<div class="post-metadata">

**Author:** ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)\
**Post date:** [August 15, 2024, 1:19pm UTC](https://discourse.cmake.org/t/object-library-install-dir/11421/3 "2024-08-15T13:19:59Z")

</div>

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](https://gitlab.kitware.com/cmake/cmake/-/issues/25407) requests more granular controls over this behavior.
