[CMake] Top level target depending on a file

Michael Hertling mhertling at online.de
Wed Dec 14 05:26:54 EST 2011


On 12/14/2011 10:55 AM, Alexander Broekhuis wrote:
> Hi,
> 
> Thanks for you replies,
> 
> 
>>> In my case the output is the ZIP file. So the zip file is produced by the
>>> top level target, and I don't want/need a separate target for it.
>>
>> Yes but CMake's jobs is to build libraries and executables not "bundle"
>> which is more the CPack's job, however I understand your point.
>>
>> An extra target may be a small price to pay, no?
>>
> 
> Well I'd rather have a solution without CPack, CPack being a package
> creator, whereas my bundle is a development item.
> If all fails I could make the extra target, but again, the zip file in my
> case is equivalent to a library.

Not technically, because the ZIP file has different dependencies than
the library, and these dependencies can't be expressed for the latter.

However, if you (1) absolutely want to generate the ZIP file by a
TARGET-style custom command attached to the library target, (2) get
along with Makefiles and (3) are willing to pay an extra charge, you
might use the LINK_DEPENDS target property for your purposes. If set
on the library target and specifying the manifest file, it will have
the library relinked and, thus, the ZIP file command triggered when
the manifest is newer than the library. Of course, this means to
accept actually unnecessary link operations which can be quite
expensive.

Regards,

Michael

>> Yes sure, sometimes file dependencies are needed.
>>
>> By the way I see you custom-commands in order to create a bundle on MacOS?
>> Did you try try CPack MacOSX bundle generator?
>>
>> http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29
>>
>>
> My "bundles" don't have anything to do with MacOS bundles, the name is a
> coincidence. Some background might be helpful now..
> 
> I am using CMake to build Apache Celix, which is a project in the Apache
> Incubator. Apache Celix is an implementation of the OSGi specification in
> C. I am not sure if you are familiar with OSGi, but it provides a modular
> system for Java in which new functionality can be added/removed/updated at
> runtime. In Java OSGi a bundle is a regular Jar file with additional
> information in the Manifest file.
> For Celix we use a similar solution (since a jar file is actually a zip
> file..) where the library is packed in a zip file together with the
> manifest file. One bundle contains always one library, this is why I see
> the Celix bundles as top level artifacts, and not the library. As such,
> from the Celix point of view it makes sense to have one target for creating
> a Bundle.
> 
> More information can be found at: http://incubator.apache.org/celix/
> And specifically on the build files:
> http://incubator.apache.org/celix/documentation/buildingandrunning.html
> 
> I hope this makes all a little bit clearer, I understand I am using a
> rather specific solution, but the flexibility of CMake has really helped my
> achieving what I wanted (until now?). This way fits the modular development
> needed in an OSGi based environment.


More information about the CMake mailing list