Hello Alexander, Am Montag, 19. April 2010 um 18:03:28 schrieb Alexander Neundorf: > On Monday 19 April 2010, Benjamin Eikel wrote: > > Hello Alexander, > > > > Am Sonntag, 18. April 2010 10:52:17 schrieb Alexander Neundorf: > > > Hi Benjamin, > > > > > > On Friday 16 April 2010, Benjamin Eikel wrote: > > > > Hello, > > > > > > > > maybe my first post was not clear enough. > > > > I created a minimal example to demonstrate what I mean (see attached > > > > files). That example contains a library called MyLib and a binary > > > > called MyBin. The enclosed shell script can be used to build the > > > > binary on Linux. At first the library will be configured such that > > > > the file "MyLibConfig.cmake" will be created. After that the binary > > > > will be configured and a build will be started. The build will fail > > > > because the library was intentionally not build before. After that > > > > another way of including the library is used. The second > > > > "CMakeLists.txt" file uses add_subdirectory to reference the library. > > > > > > Yes, that's the normal way to do it. > > > > > > > When issuing a make command now, > > > > the library will be built automatically. My question is if it is > > > > possible to achieve this behavior when using the approach mentioned > > > > first. This would make things easier in our projects when there are > > > > multiple dependencies to different libraries which will be changed > > > > often and a build of the binary should be triggered automatically. > > > > > > The normal and recommended way to to add all that (via > > > add_subdirectory) into one CMake project. What is speaking against this > > > in your case ? > > > > > > If you really want to have it separated, you may try how far you can > > > get with externalproject_add(), but I would assume that the > > > straightforward approach (add_subdirectory) will work much better. > > > > I think you are right. > > But I still want to build the libraries on their own (because they are > > used in some Hudson builds to check if the build works correctly). > > Therefore a library libA depending on another library libB calls > > find_package(libB) to find the needed files. > > When using the add_subdirectory() approach I currently have the problem > > that the find modules do not find the library libB (because it has not > > been build yet). Is it the right way to integrate a check for the target > > libB like the following into FindlibB.cmake? > > > > if(TARGET libB) > > set(libB_LIBRARY Geometry) > > else() > > find_library(libB_LIBRARY > > NAMES libB > > HINTS ${libB_PKGCONF_LIBRARY_DIRS} [...] > > PATH_SUFFIXES lib64 lib [...] > > ) > > endif() > > > > This seems to work if I call add_subdirectory() in the correct order in > > the top-level project. > > Yes, something like this can work. I implemented it this way and it works like a charm. Thank you for your input.
Kind regards, Benjamin _______________________________________________ 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