MantisBT - CMake
View Issue Details
0012322CMakeCMakepublic2011-07-08 05:272012-01-02 15:56
Yuri 
David Cole 
normaltweakalways
closedwon't fix 
CMake 2.8.4 
CMake 2.8.6 
0012322: Ability to add source files to target created with ExternalProject
In my scenario I have part of project which should be built with different toolset (Main project is built with VC2010, and some legacy libraries with VC6 and VS2005).
Basically nested project contains
set(Proj_SRCS src1.cpp src2.cpp...)
add_library(Proj MODULE ${Proj_SRCS})

So set() command may be moved into separate file which in turn could be included into main project. So I want to see them there to edit in IDE, but not compile.

The only possibility to add files to custom target - is specify SOURCES in add_custom_target command (It's impossible to call cmTarget::AddSources from outside). However, ExternalProject_Add macro doesn't add any sources.

Moreover, there is a kind of chicken-and-egg problem: all arguments are parsed and set as property on target. But you can't set property while there is no target.

So as quick work-around I made private copy of ExternalProject.cmake and pass sources as directory property.

So I'm asking for ideas how to properly implement this feature: modify somehow parameters parsing in ExternalProject, or may be introduce command which allows adding new sources to existing targets (I'm not sure if this will work, but for me it sounds like target_link_libraries command).
No tags attached.
Issue History
2011-07-08 05:27YuriNew Issue
2011-08-12 09:19David ColeAssigned To => David Cole
2011-08-12 09:19David ColeStatusnew => assigned
2011-08-12 09:23David ColeNote Added: 0027196
2011-08-12 09:23David ColeStatusassigned => resolved
2011-08-12 09:23David ColeFixed in Version => CMake 2.8.6
2011-08-12 09:23David ColeResolutionopen => won't fix
2011-08-12 09:24David ColeNote Added: 0027197
2012-01-02 15:56David ColeNote Added: 0028127
2012-01-02 15:56David ColeStatusresolved => closed

Notes
(0027196)
David Cole   
2011-08-12 09:23   
I don't think we should do this.

If we allow source files from external projects to be added directly to the IDE representations of the external projects in the containing project, then people will expect the dependencies to work correctly automatically...

The dependencies will not work automatically. You will have to forcefully trigger an incremental rebuild of the external project on *any* build of the containing project, and then hope that its build system appropriately picks up only the incremental build changes necessary.

I view this as fragile, and would not like to see it go in CMake unless it can be made robust, and shown to work automatically and as developers would expect in the vast majority of use cases.
(0027197)
David Cole   
2011-08-12 09:24   
If you need more help on this issue/topic, please send email to the CMake users list asking for advice there. There's a much wider readership of the mailing list than there is of the bug database.
(0028127)
David Cole   
2012-01-02 15:56   
Closing resolved issues that have not been updated in more than 4 months.