View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015755CMakeCMakepublic2015-09-21 12:272016-02-01 09:10
ReporterDimitri Merejkowsky 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product VersionCMake 3.3.2 
Target VersionFixed in Version 
Summary0015755: add_dependencies() undoes include_directories()
DescriptionCalling add_dependencies() between two targets causes some calls to include_directories() to no longer be taken into account
Steps To ReproduceSee attached project.

$ mkdir b1
$ cmake ..
$ make
...
[ 25%] Linking C executable eggs
CMakeFiles/eggs.dir/eggs.c.o: In function `main':
eggs.c:(.text+0xa): undefined reference to `spam

$ mkdir b2
$ cmake -DADD_DEPENDENCIES=ON ..
$ make
[ 25%] Building C object spam/CMakeFiles/spam.dir/src/spam.c.o
spam/src/spam.c:1:23: fatal error: spam/spam.h: No such file or directory
TagsNo tags attached.
Attached Fileszip file icon spam.zip [^] (1,763 bytes) 2015-09-21 12:27

 Relationships

  Notes
(0039462)
Dimitri Merejkowsky (reporter)
2015-09-21 12:35

Note that if I add a line looking like

include_directories(".")

in spam/CMakeLists.txt, the header is found
(0039471)
Brad King (manager)
2015-09-22 13:24

The include_directories after the add_subdirectory has no influence on the subdirectory. The reason your "b1" case does not get the compiler error is that without add_dependencies there is no ordering between the targets so you happen to see the linker error before the "spam" library tries to build. Even in that case running "make spam" will see the missing header.
(0040416)
Robert Maynard (manager)
2016-02-01 09:10

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

 Issue History
Date Modified Username Field Change
2015-09-21 12:27 Dimitri Merejkowsky New Issue
2015-09-21 12:27 Dimitri Merejkowsky File Added: spam.zip
2015-09-21 12:35 Dimitri Merejkowsky Note Added: 0039462
2015-09-22 13:24 Brad King Note Added: 0039471
2015-09-22 13:24 Brad King Status new => resolved
2015-09-22 13:24 Brad King Resolution open => no change required
2016-02-01 09:10 Robert Maynard Note Added: 0040416
2016-02-01 09:10 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team