[CMake] Top level target depending on a file

Eric Noulard eric.noulard at gmail.com
Wed Dec 14 04:39:30 EST 2011


2011/12/14 Alexander Broekhuis <a.broekhuis at gmail.com>:
> Hi,
>
>>
>> CMake takes great care regarding dependencies on files which are needed
>> to build targets, i.e. usually, it's not necessary to specify any extra
>> dependencies of a target on a file. In my exemplary project, the README
>> file is actually not needed to build the library target, so CMake does
>> not add an appropriate dependency. However, the README file is needed
>> to generate the ZIP file, so the latter must be a separate target with
>> dependencies on its own, whereas the approach to generate the ZIP file
>> by a TARGET-style custom command for the library target is wrong, IMO;
>> one can just trigger the ZIP file target in this way. In other words:
>> You have two targets with different dependencies - don't mix them up.
>
>
> 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?

> The generated zip file (bundle) is the deployable unit which contains a
> library and additional information needed (at runtime) to use the library,
> which is located in the manifest file. If the manifest file changes, without
> a change to the library source, the zip file still needs to be regenerated.
> As such the output of the target depends on the manifest file, hence the
> need for a dependency to a file.

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

May be that's already what your
CPackConfig-${BUNDLE_NAME}-bundle.cmake contains?

Or may be you had to work-around some generator's bug?

The broader question; why didn't you use one of the MacOSX CPack generator:
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DragNDrop_.28OSX_only.29
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#PackageMaker_.28OSX_only.29
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#OSXX11_.28OSX_only.29
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29

I'm not a MacOS user but I may have to use some soon enough so I'm curious.

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list