There is no magic way to do this with CMake. However, if you don'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 "${CFLAGS}")<br> set(MYLINK_FLAGS "${LFLAGS}")<br><br> if(UNIX)<br> foreach(IPATH ${IPATHS})<br> set(MYCOMPILE_FLAGS "${MYCOMPILE_FLAGS} -I${IPATH}")<br>
endforeach(IPATH)<br><br> foreach(LPATH ${LPATHS})<br> set(MYLINK_FLAGS "${MYLINK_FLAGS} -L${LPATH}")<br> endforeach(LPATH)<br> elseif(WIN32)<br> foreach(IPATH ${IPATHS})<br>
set(MYCOMPILE_FLAGS "${MYCOMPILE_FLAGS} /I${IPATH}")<br> endforeach(IPATH)<br><br> foreach(LPATH ${LPATHS})<br> set(MYLINK_FLAGS "${MYLINK_FLAGS} /LIBPATH:\"${LPATH}\"")<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 "${DEFINITIONS}"<br>
COMPILE_FLAGS "${MYCOMPILE_FLAGS}"<br> LINK_FLAGS "${MYLINK_FLAGS}"<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> "${FOO_SOURCES}"<br> "${FOO_COMPILE_DEFINITIONS}"<br> "${FOO_COMPILE_FLAGS}"<br> "${FOO_LINK_FLAGS}"<br> "${FOO_LIBS}"<br> "${FOO_INCLUDE_DIRECTORIES}"<br>
"${FOO_LINK_DIRECTORIES}"<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 'hacks' 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"><<a href="mailto:olivier.pierard@cenaero.be">olivier.pierard@cenaero.be</a>></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 'include_directories' for each library and not the<br>
same list for all of them (typically, I don'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>