[CMake] Generated file dependency
Hi I have the following situation: files: test.cpp test.h I want to process the file test.cpp with a custom pre-processor which will generate, say, test.ii.cpp which will get compiled into libtest.a. test.cpp just includes test.h. This is my CMakeLists.txt file: cmake_minimum_required(VERSION 2.6) add_custom_command (OUTPUT test.ii.cpp COMMAND preprocess test.cpp test.ii.cpp DEPENDS test.cpp COMMENT "Creating test.ii.cpp" VERBATIM) add_library (test test.ii.cpp) All dandy, but when I modify test.h the preprocessing step is not run, but just the compile step for test.ii.cpp. How can I make it so, that when the header is modified the preprocessing and the compilation steps are both run? Regards, Nikolay ___ 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
[CMake] Fwd: Generated file dependency
[posting to the list, since I accidentally replied only to Sergey] On Thu, Apr 23, 2009 at 1:48 PM, Sergey Rudchenko < sergey.rudche...@gmail.com> wrote: > On Thu, 2009-04-23 at 13:37 +0300, Nikolay Mitev wrote: > > Hi > > > > I have the following situation: > > > > files: test.cpp test.h > > > > I want to process the file test.cpp with a custom pre-processor which > > will generate, say, test.ii.cpp which will get compiled into > > libtest.a. test.cpp just includes test.h. > > > > This is my CMakeLists.txt file: > > > > cmake_minimum_required(VERSION 2.6) > > > > add_custom_command (OUTPUT test.ii.cpp > > COMMAND preprocess test.cpp test.ii.cpp > > DEPENDS test.cpp > > COMMENT "Creating test.ii.cpp" > > VERBATIM) > > > > add_library (test test.ii.cpp) > > > > All dandy, but when I modify test.h the preprocessing step is not run, > > but just the compile step for test.ii.cpp. How can I make it so, that > > when the header is modified the preprocessing and the compilation > > steps are both run? > > Did you try to list the test.h in the DEPENDS list? > Yes, and this works, but I really don't want to keep this list up-to-date manually. The project involves hundreds of files, so I'm looking for a way to automate this. Is there a way to extract the dependencies of test.cpp and make test.ii.cpp depend on them? Nikolay ___ 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
Re: [CMake] Fwd: Generated file dependency
On Thu, Apr 23, 2009 at 6:50 PM, James Bigler wrote: > On Thu, Apr 23, 2009 at 9:39 AM, James Bigler wrote: > >> On Thu, Apr 23, 2009 at 6:50 AM, Nikolay Mitev wrote: >> >>> [posting to the list, since I accidentally replied only to Sergey] >>> On Thu, Apr 23, 2009 at 1:48 PM, Sergey Rudchenko < >>> sergey.rudche...@gmail.com> wrote: >>> >>>> On Thu, 2009-04-23 at 13:37 +0300, Nikolay Mitev wrote: >>>> > Hi >>>> > >>>> > I have the following situation: >>>> > >>>> > files: test.cpp test.h >>>> > >>>> > I want to process the file test.cpp with a custom pre-processor which >>>> > will generate, say, test.ii.cpp which will get compiled into >>>> > libtest.a. test.cpp just includes test.h. >>>> > >>>> > This is my CMakeLists.txt file: >>>> > >>>> > cmake_minimum_required(VERSION 2.6) >>>> > >>>> > add_custom_command (OUTPUT test.ii.cpp >>>> > COMMAND preprocess test.cpp test.ii.cpp >>>> > DEPENDS test.cpp >>>> > COMMENT "Creating test.ii.cpp" >>>> > VERBATIM) >>>> > >>>> > add_library (test test.ii.cpp) >>>> > >>>> > All dandy, but when I modify test.h the preprocessing step is not run, >>>> > but just the compile step for test.ii.cpp. How can I make it so, that >>>> > when the header is modified the preprocessing and the compilation >>>> > steps are both run? >>>> >>>> Did you try to list the test.h in the DEPENDS list? >>>> >>> >>> Yes, and this works, but I really don't want to keep this list up-to-date >>> manually. The project involves hundreds of files, so I'm looking for a way >>> to automate this. Is there a way to extract the dependencies of test.cpp and >>> make test.ii.cpp depend on them? >>> >>> >>> Nikolay >>> >>> >> If you have a C or CXX language file look the documentation for >> add_custom_command and IMPLICIT_DEPENDS. >> >> James >> > > I just realized that IMPLICIT_DEPENDS only works for the Makefile > generator. If you need a more general solution, it requires a much bigger > hammer. I have a cmake script that generates the dependency file (i.e. -M) > and does a bunch of CMake magic to maintain that dependency file and > encorporate those dependencies into the build system. > > James > IMPLICIT_DEPENDS works for me, for now, since I'm targeting unix platforms. But a more generic solution would be really nice to have. Nikolay ___ 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
[CMake] How to create preprocess-only file rule
Hi I'm trying to create a rule which will only run the C++ preprocessor on a file, without compiling it. I know about the make file.i rule, but if file.cpp is not a dependency of some target it does not get generated. Setting header_file property doesn't work either. Adding a custom rule works, but I have to manually assemble the include paths, defines, etc... I found the CMAKE_CXX_CREATE_PREPROCESSED_SOURCE rule in the modules dir, but I guess it can't be used directly in a cmake file. So, is there a way to generate a *.i target without the cpp file being included in any target? Nikolay ___ 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