[CMake] Couple of library/link questions

Oliver Smith osmith at playnet.com
Tue Mar 20 15:01:31 EDT 2012


I'm trying to make a CMakeLists for libevent, and had a couple of 
questions that would make it a bit cleaner:

- Other than using a macro to do { add_executable(...) 
target_link_libraries(...) } is there a /clean/ way to make everything 
in a subdirectory automatically link a given library?

- The makefiles I'm basing this on build libevent_core.lib, 
libevent_extras.lib and then libevent.lib which is basically the two 
previous libraries merged.

I wanted to do:

ADD_LIBRARY(libevent_core ${CoreSrcFiles})
ADD_LIBRARY(libevent_extras ${ExtraSrcFiles})
ADD_LIBRARY(libevent)
TARGET_LINK_LIBRARIES(libevent libevent_core libevent_extras)

but this generates a warning/error,  listing the two libraries in 
add_library doesn't work either.

So for now I have

ADD_LIBRARY(libevent_core ${CoreSrcFiles})
ADD_LIBRARY(libevent_extras ${ExtraSrcFiles})
ADD_LIBRARY(libevent ${CoreSrcFiles} ${ExtraSrcFiles})

but that's clumsy :)

- Oliver

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120320/ccfa54ef/attachment.htm>


More information about the CMake mailing list