[CMake] Beginner's Question: Organizing Projects

Ryan Pavlik rpavlik at iastate.edu
Wed Oct 27 11:54:31 EDT 2010


On Wed, Oct 27, 2010 at 9:04 AM, Rolf Eike Beer <eike at sf-mail.de> wrote:
>> Thanks. The way I understand this is that now instead of
>>
>> include_directories(${GTKMM_INCLUDE_DIRS})
>>
>> i would write something like
>>
>> include_directories(${GTKMM_INCLUDE_DIRS})
>> # and at the end of the file
>> set(INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} PARENT_SCOPE)
>>
>> ? I'd do the same with the LINK_DIRECTORIES, LINK_LIBRARIES property and
>> for all other libraries?
>
> Don't set LINK_DIRECTORIES and LINK_LIBRARIES. When you are a beginner
> probably every usage of them is wrong.
>
> You simply do
>
> TARGET_LINK_LIBRARIES(mytarget ${GTK_LIBRARIES}) (or however that is called)
>
> The only thing you need to "export upwards" in this case would be the
> GTK_LIBRARIES variable.
>
> Eike

This is good advice, however, in most cases, since you're using
pkgconfig directly (which is not the recommended way), that will cause
more failure.  Best thing to do is to create/find a cmake module for
each of those packages, that might use pkgconfig for help finding the
library, but that doesn't just use what it returns verbatim.

Ryan

-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik at iastate.edu
http://academic.cleardefinition.com
Internal VRAC/HCI Site: http://tinyurl.com/rpavlik


More information about the CMake mailing list