View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015907CMakeCMakepublic2016-01-10 11:152016-05-02 08:30
ReporterPhilippe 
Assigned ToNils Gladitz 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformLinuxOSDebianOS Versionunstable
Product VersionCMake 3.4.1 
Target VersionFixed in Version 
Summary0015907: [ninja] wrong dependency management with imported targets from external project or custom target
DescriptionHere is a simple CMakeLists to reproduce my problem:

    # in my case, this line is actually an ExternalProject_Add
    add_custom_target(outfile COMMAND gcc ${CMAKE_CURRENT_SOURCE_DIR}/lib.c -shared -o liboutfile.so)

    add_library( mylib SHARED IMPORTED )
    set_property( TARGET mylib PROPERTY IMPORTED_LOCATION liboutfile.so )
    add_dependencies( mylib outfile )

    add_executable( testexe test.c )
    target_link_libraries( testexe mylib )

This ensures that before we try to link with the mylib target, the outfile target is built. Except it works only with the Unix Makefiles generator but not with the Ninja one.

With Ninja I get this error before it tries to do any work:

    ninja: error: 'liboutfile.so', needed by 'testexe', missing and no known rule to make it

I'm attaching a simple and complete test project to reproduce.
Steps To Reproduce1. download and uncompress the attached testproj
2. configure with the Ninja generator
3. try build with ninja and get an error
TagsNo tags attached.
Attached Filesbz2 file icon testproj.tar.bz2 [^] (570 bytes) 2016-01-10 11:15

 Relationships

  Notes
(0040172)
Nils Gladitz (developer)
2016-01-10 12:21

For Ninja you need to declare liboutfile.so a byproduct (BYPRODUCTS keyword in add_custom_command()).

ExternalProject_Add() supports this through the BUILD_BYPRODUCTS option.
(0040173)
Philippe (reporter)
2016-01-10 12:35

Indeed, it works! Thank you. You can close this :)
(0040997)
Robert Maynard (manager)
2016-05-02 08:30

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2016-01-10 11:15 Philippe New Issue
2016-01-10 11:15 Philippe File Added: testproj.tar.bz2
2016-01-10 12:21 Nils Gladitz Note Added: 0040172
2016-01-10 12:35 Philippe Note Added: 0040173
2016-01-11 05:06 Nils Gladitz Status new => resolved
2016-01-11 05:06 Nils Gladitz Resolution open => no change required
2016-01-11 05:06 Nils Gladitz Assigned To => Nils Gladitz
2016-05-02 08:30 Robert Maynard Note Added: 0040997
2016-05-02 08:30 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team