Depends on who knows the directories to be included. If you're in a situation when B doesn't know which directories A will add, you can use global properties for this purpose. Something like this:
#------------- project(B) define_property(GLOBAL PROPERTY my_include_files ...) add_subdirectory(/there/A) #1 get_property(added_by_a GLOBAL PROPERTY my_include_files) #1 include_directories(${added_by_a}) #1 #--------------- project(A) include_directories(/there/A/include) #2 set_property(GLOBAL PROPERTY my_include_files /there/A/include) #2 #------------- Lines marked as #1 and #2 could be encapsulated in macros, something like "add_subdirectory_and_import_includes()" and "set_and_import_includes()", respectively. Petr On Thu, Apr 19, 2012 at 8:58 PM, <noru...@me.com> wrote: > You could create a macro for such purpose: > > macro(AddAndInclude directory) > add_subdirectory(${directory}) > include_directories(${directory}/include) > endmacro(AddAndInclude) > > Usage: > AddAndInclude(/there/A) > > Best Regards > NoRulez > > Am 19.04.2012 um 16:42 schrieb Christian Arnault <arna...@lal.in2p3.fr>: > >> Hi, >> >> My simple work model is as follows: >> >> 1) I have two projects A & B, located in independant locations. Both provide >> some libraries & executable >> 2) B makes use of libraries & headers provided in A >> >> >> I want to launch the build of A together B thus I do: >> >> #------------------------- >> project(B) >> add_subdirectory (/there/A) >> ... >> #------------------------- >> >> OK! >> >> Then I'd like to inherit some properties of A (let's say 'include >> directories' !) of course I could simply say: >> >> #-------------------- >> project(B) >> ... >> add_subdirectory (/there/A) >> include_directories (/there/A/includes) >> add_library (MyBLib...) >> ... >> #---------------------- >> >> >> OK! this works >> >> Now, suppose I want rather to 'export' the include_directories property >> while I am within the CMakeLists.txt of A, so that, it's enough to >> add_subdirectory(A). such as: >> >> #-------------------------------- >> project(B) >> ... >> add_subdirectory (/there/A) >> add_library (MyBLib...) >> #-------------------------------- >> >> >> So as the include_directories property is transparently acquired. >> How to do this in CMake ? >> (of course, I tried many features of CMake, but perhaps I have missed some >> important point....) >> >> Thanks for any hint >> >> Christian >> >> >> >> >> -- >> -------------------------------------------- >> | Christian Arnault | >> | LAL Bat 200 pièce 03a | >> | 91405 Orsay CEDEX | >> | phone : (33) 1 64 46 84 24 | >> | gsm : (33) 6 77 27 62 30 | >> | fax : (33) 1 69 07 94 04 | >> | e-mail : christian.arna...@lal.in2p3.fr | >> -------------------------------------------- >> >> -- >> >> Powered by www.kitware.com >> >> Visit other Kitware open-source projects at >> http://www.kitware.com/opensource/opensource.html >> >> Please keep messages on-topic and check the CMake FAQ at: >> http://www.cmake.org/Wiki/CMake_FAQ >> >> Follow this link to subscribe/unsubscribe: >> http://www.cmake.org/mailman/listinfo/cmake > -- > > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake