# Exported target list adds SHARED IMPORTED library with IMPORTED\_LOCATION property missing

**URL:** https://discourse.cmake.org/t/exported-target-list-adds-shared-imported-library-with-imported-location-property-missing/2937
**Category:** Usage
**Tags:** os:linux
**Created:** [March 10, 2021, 10:51pm UTC](https://discourse.cmake.org/t/exported-target-list-adds-shared-imported-library-with-imported-location-property-missing/2937 "2021-03-10T22:51:45Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![yisseamake](https://discourse.cmake.org/user_avatar/discourse.cmake.org/yisseamake/32/897_2.png) [@yisseamake](https://discourse.cmake.org/u/yisseamake)
#### Post date: [March 10, 2021, 10:51pm UTC](https://discourse.cmake.org/t/exported-target-list-adds-shared-imported-library-with-imported-location-property-missing/2937/1 "2021-03-10T22:51:45Z")

</div>

When cmake install(EXPORT…) command executed it creates myprojectTargets.cmake file which is being used by downstream consuming project issuing find\_package( myproject).  
cmake writes to myprojectTargets.cmake file commands

```cmake
# Create imported target myproject::myLib1
    add_library(myproject::myLib1 SHARED IMPORTED)
set_target_properties(myproject::myLib1 PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/myLib/include"
  INTERFACE_LINK_LIBRARIES "myproject::myLib2;myproject::myLib3;myproject::myLib3" #etc
)

```

There is no setting for IMPORTED\_LOCATION which supposed to be a path to library.so (or dll.a) file.  
What could be done to make cmake to insert it or for consuming project to get it but without me adding find\_path(myproject::myLib1), find\_library(myproject::myLib1) commands for the imported libraries ?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 11, 2021, 12:01am UTC](https://discourse.cmake.org/t/exported-target-list-adds-shared-imported-library-with-imported-location-property-missing/2937/2 "2021-03-11T00:01:29Z")

</div>

There should be a file named `myprojectTargest-$<CONFIG>.cmake` which contains the locations for that target for the given configuration. There should be a `file(GLOB)` followed by a loop which includes them in the plain `myprojectTargets.cmake` file.

---

<div class="post-metadata">

### Author: ![yisseamake](https://discourse.cmake.org/user_avatar/discourse.cmake.org/yisseamake/32/897_2.png) [@yisseamake](https://discourse.cmake.org/u/yisseamake)
#### Post date: [March 11, 2021, 12:14am UTC](https://discourse.cmake.org/t/exported-target-list-adds-shared-imported-library-with-imported-location-property-missing/2937/3 "2021-03-11T00:14:07Z")

</div>

Dear @ben.boeckel, I think you meant `myprojectConfig.cmake`, but that file is generated by cmake from my myprojectConfig.cmake.in template. So it contents determine what I included there. I could add set\_target\_property in this file and this is what I am doing as a workaround, but cmake itself does not generate myprojectConfig.cmake with " the locations for that target for the given configuration" or " `file(GLOB)` followed by a loop". cmake just expands macros (macro(set\_and\_check \_var \_file)) and variables like @PACKAGE\_INIT@,@PACKAGE\_PREFIX\_DIR@, @AUTO\_GEN\_MSG@ from myprojectConfig.cmake.in template into myprojectConfig.cmake.  
So did you mean that file/process?  
In any case why would cmake writes command to ```set\_target\_properties in the myprojectTargets.cmake file for just 2 properties and for IMPORTED\_LOCATION is some other place?

```auto

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 11, 2021, 3:40pm UTC](https://discourse.cmake.org/t/exported-target-list-adds-shared-imported-library-with-imported-location-property-missing/2937/4 "2021-03-11T15:40:25Z")

</div>

> [@yisseamake](#):
>
> I think you meant `myprojectConfig.cmake`, but that file is generated by cmake from my myprojectConfig.cmake.in template

No. This file is indeed provided by you and should include the `myprojectTargets.cmake` file. The `Targets.cmake` file then includes the per-configuration bits on its own via a globbing mechanism.

> [@yisseamake](#):
>
> In any case why would cmake writes command to ```set\_target\_properties in the myprojectTargets.cmake file for just 2 properties and for IMPORTED\_LOCATION is some other place?

Because the location/filename of a library differs based on configuration in multi-config generators. Instead of rewriting a single file, the per-configuration information is written to distinct files and then collected together later.

However, I’m looking at VTK now and I’m not seeing per-config files for single configuration generators, so maybe I’ve just been confused myself. It seems that the location information is written in the second half of the file in such cases. This behavior is likely due to the simplification of writing the config-independent bits in one chunk of code and then handling per-config either as separate files (multi-config generators) or as additional content (for single-config generators) separately.
