[CMake] Invoking an script from the link command.

Mike Jackson mike.jackson at imts.us
Mon Aug 11 20:42:38 EDT 2008



On Aug 11, 2008, at 8:33 PM, Óscar Fuentes wrote:

> Bill Hoffman <bill.hoffman at kitware.com>
> writes:
>
>>> Solved:
>>>
>>> target_link_libraries(myexe "`/path/to/script arg1 arg2`")
>>>
>> This is in general a non-portable way to write cmake files, and is  
>> not
>> guaranteed to work in any version of CMake.  This is the same as a
>> pkg-config script.  The way to do this is to use execute_process and
>> collect the output at cmake time, and then use target_link_libraries.
>
> I just realized another reason why your proposal is not adequate: the
> libraries and the script must be built before the executable, so, at
> cmake time, the libraries and the script does not exists.
>
> I know this is not portable, but it is intended for POSIX  
> platforms, GNU
> toolchains. As far as cmake does not mess too much with the contents
> passed to target_link_libraries, it should be fine.
>
> -- 
> Oscar
>

Just out of curiosity..

Is the dependency tracking in CMake not adequate enough for your  
project? If CMake is used as intended you should not have to manually  
figure out what libraries are needed, CMake should be able to do that  
for you.
   Maybe you could give some more detail about your use case?

Mike


More information about the CMake mailing list