View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014311CMakeCMakepublic2013-07-25 05:192016-06-10 14:31
ReporterNikita Krupenko 
Assigned ToKitware Robot 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
Platformx86OSWindowsOS Version7
Product VersionCMake 2.8.11.2 
Target VersionFixed in Version 
Summary0014311: CMake cannot install imported targets
DescriptionI use ExternalProject for building non-Cmake projects and add imported targets for that projects. For example:

ExternalProject_add(mylib_proj ...)
add_library(mylib SHARED IMPORTED)
set_target_properties(mylib PROPERTIES IMPORTED_LOCATION ...)
add_dependencies(mylib mylib_proj)

I can link with that library, but CMake cannot install them. This code

install(TARGETS mylib DESTINATION ...)

produces following error:

CMake Error at CMakeLists.txt:48 (install):
  install TARGETS given target "mylib" which does not exist in this
  directory.

Because of broken install packaging using CPack also not working.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0033603)
Brad King (manager)
2013-07-25 08:32

Imported targets were originally designed for importing from an existing installation of some external package so installing did not make sense at the time. Later this interaction with ExternalProject was invented.

ExternalProject_add supports an INSTALL_COMMAND step to use the external build-system's own install rules. If it doesn't have any then you could also use install(SCRIPT) or install(CODE) add custom install code for them.
(0033604)
Nikita Krupenko (reporter)
2013-07-25 08:38

How can I pack this imported targets with CPack? To do so, I must use the install() command.
(0033605)
Nikita Krupenko (reporter)
2013-07-25 08:44

I also found one solution:

get_target_property(MYLIB_LOCATION mylib LOCATION)
install(FILES ${MYLIB_LOCATION} DESTINATION ...)

This works, but maybe install command can be improved to handle imported targets.
(0033606)
Brad King (manager)
2013-07-25 08:53

Since the example includes

 set_target_properties(mylib PROPERTIES IMPORTED_LOCATION ...)

where the "..." knows the location already you don't need to get the LOCATION property.
(0039836)
Kishore Jonnalagadda (reporter)
2015-11-05 01:39

This is also useful when including prebuilt library binaries in the project.

add_library(prebuilt STATIC IMPORTED)
set_property(TARGET prebuilt PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libprebuilt.a)

install(TARGETS other_built_targets prebuilt
    EXPORT project-export
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
)

Making prebuilt an imported target makes in convenient to use in the project and treats it further like any other target.
(0040877)
Alex Turbov (reporter)
2016-04-18 01:17

+1 for the last comment from Kishore Jonnalagadda!
I have exacly the same case now :(
(0041062)
AleXoundOS (reporter)
2016-05-12 15:09

+1 for Kishore Jonnalagadda's comment
(0042326)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2013-07-25 05:19 Nikita Krupenko New Issue
2013-07-25 08:32 Brad King Note Added: 0033603
2013-07-25 08:32 Brad King Status new => backlog
2013-07-25 08:38 Nikita Krupenko Note Added: 0033604
2013-07-25 08:44 Nikita Krupenko Note Added: 0033605
2013-07-25 08:53 Brad King Note Added: 0033606
2015-11-05 01:39 Kishore Jonnalagadda Note Added: 0039836
2016-04-18 01:17 Alex Turbov Note Added: 0040877
2016-05-12 15:09 AleXoundOS Note Added: 0041062
2016-06-10 14:29 Kitware Robot Note Added: 0042326
2016-06-10 14:29 Kitware Robot Status backlog => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team