Would this work? add_dependencies(MergeFiles SubdirTarget) On Nov 18, 2015 12:56 PM, "Attila Krasznahorkay" < [email protected]> wrote:
> Dear All, > > I'm trying to do something that may be very easy to implement, but I'm > really struggling with it at the moment... > > I have a project in which I generate various files in subdirectories. > Which I add to the main project file using add_subdirectory(...). Some of > these files I need to merge into a single file at the end of the build. For > which I tried to set up a custom command in my main project file. But I > can't convince this main project file to find out how to generate the files > whose generation rule sits in a subdirectory. > > Attached is a simple example of what I mean. In this example it is > possible to execute the following commands successfully: > > make SubdirTarget > make > > Since by the time the main target is built, its source files are already > available. But if I try to just execute "make" first, I get: > > Scanning dependencies of target MergeFiles > make[2]: *** No rule to make target `subdir/file3.txt', needed by > `merged.txt'. Stop. > make[1]: *** [CMakeFiles/MergeFiles.dir/all] Error 2 > make: *** [all] Error 2 > > I tried a number of different directory/file name combinations by now, but > the problematic thing in the end seems to be that these files are generated > in a different directory than where I try to use them. > > Do you have a suggestion on how I could do something like this? > > Cheers, > Attila > > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake >
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
