There is no magic way to do this with CMake.   However, if you don&#39;t mind writing some functions/macros you can use a variant of the following function to do what you want:<br><br>function(build_library NAME KIND SOURCES DEFINITIONS CFLAGS LFLAGS LIBS IPATHS LPATHS)<br>
    unset(MYCOMPILE_FLAGS)<br>    unset(MYLINK_FLAGS)<br><br>    set(MYCOMPILE_FLAGS &quot;${CFLAGS}&quot;)<br>    set(MYLINK_FLAGS &quot;${LFLAGS}&quot;)<br><br>    if(UNIX)<br>        foreach(IPATH ${IPATHS})<br>            set(MYCOMPILE_FLAGS &quot;${MYCOMPILE_FLAGS} -I${IPATH}&quot;)<br>
        endforeach(IPATH)<br><br>        foreach(LPATH ${LPATHS})<br>            set(MYLINK_FLAGS &quot;${MYLINK_FLAGS} -L${LPATH}&quot;)<br>        endforeach(LPATH)<br>    elseif(WIN32)<br>        foreach(IPATH ${IPATHS})<br>
            set(MYCOMPILE_FLAGS &quot;${MYCOMPILE_FLAGS} /I${IPATH}&quot;)<br>        endforeach(IPATH)<br><br>        foreach(LPATH ${LPATHS})<br>            set(MYLINK_FLAGS &quot;${MYLINK_FLAGS} /LIBPATH:\&quot;${LPATH}\&quot;&quot;)<br>
        endforeach(LPATH)<br>    endif(UNIX)<br><br>    add_library(${NAME} ${KIND} ${SOURCES})<br><br>    target_link_libraries(${NAME} ${LIBS})<br><br>    set_target_properties(${NAME} PROPERTIES<br>        COMPILE_DEFINITIONS &quot;${DEFINITIONS}&quot;<br>
        COMPILE_FLAGS &quot;${MYCOMPILE_FLAGS}&quot;<br>        LINK_FLAGS &quot;${MYLINK_FLAGS}&quot;<br>    )<br>endfunction(build_library)<br><br><br>This function build_library is designed to allow you to pass target specific configurations where includes/etc are different for each target.  You assign the includes/defintions/etc to variables and then pass the values as follows:<br>
<br>build_library(foo STATIC<br> &quot;${FOO_SOURCES}&quot;<br> &quot;${FOO_COMPILE_DEFINITIONS}&quot;<br> &quot;${FOO_COMPILE_FLAGS}&quot;<br> &quot;${FOO_LINK_FLAGS}&quot;<br> &quot;${FOO_LIBS}&quot;<br> &quot;${FOO_INCLUDE_DIRECTORIES}&quot;<br>
 &quot;${FOO_LINK_DIRECTORIES}&quot;<br>)<br><br>The sources, compile definitions, libraries, include directories and link directories variables should all be lists of values while the compile flags and the link flags should be strings of compiler/linker flags.  The second argument of the function sets the kind of library, STATIC/SHARED/etc...<br>
<br>This function then &#39;hacks&#39; the include directories into the compiler flags and the link directories into the link flags with the appropriate command line escape by platform (-I for Unix, /I for Windows, etc...).<br>
<br>Hope this helps,<br><br>Steve<br><br><div class="gmail_quote">On Wed, Nov 4, 2009 at 8:39 AM, Olivier Pierard <span dir="ltr">&lt;<a href="mailto:olivier.pierard@cenaero.be">olivier.pierard@cenaero.be</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
A quite basic question...<br>
<br>
In a given project, I build several libraries and an executable.  How<br>
can I get a different &#39;include_directories&#39; for each library and not the<br>
same list for all of them (typically, I don&#39;t want to have access to the<br>
includes related to the last library when compiling the first one).<br>
<br>
Thank you,<br>
<br>
Olivier<br>
<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br>