[CMake] Specify dependency on externally generated shared library

Scott Gray sgray at inventa.com
Thu May 7 08:42:48 EDT 2009


Tyler Roscoe wrote:
> On Wed, May 06, 2009 at 03:53:10PM -0400, Scott Gray wrote:
>   
>> My problem is that I need to both generate the DLL and declare it as an
>> imported library so that other programs can depend upon it.  I think I'm
>>     
>
> Maybe I'm missing something, but why do you need to do this? If you are
> building the library yourself, why would you need to mark it as
> "imported"?
>   

You are right, I don't need to import it.  My feeble brain was thinking 
that this would be a good way in which programs that would depend upon 
the generated library, thus they could just to:

     add_executable(some_prog some_prog.c)
     target_link_libraries(some_prog mylib_intl)

and cmake would just "know" where mylib_intl is located based upon the 
process that was used to generated it.

However, upon your suggestion I got rid of the IMPORT of the library and 
just did:

    link_directories("${LIBRARY_OUTPUT_PATH"})
    add_executable(some_prog some_prog.c)
    target_link_libraries(some_prog mylib_intl)

And it works.


>> make[2]: *** No rule to make target
>> `src/util/build/dist/lib/libmylib_intl.so', needed by `src/util/test/myprog'
>>     
>
> I think all you need is to create a target with add_custom_target() that
> drives the custom_command(), and then add_dependencies(your_library
> translation_library_target).
>   

Again, you are right. I followed your advice and everything seems to be 
working OK now. Now for the real test, I need to see if I can compile my 
stuff on Windows (ugh).  We'll see how that goes :)

Thanks!
-scott



More information about the CMake mailing list