Re: [CMake] How do I generate a preprocessed file?
Bill Hoffman wrote: > You do know about make foo.i where CMake will do this for you, right? No, I didn't. But now I do -- it does exactly what I want. Thanks! :-) Best regards Piotr Wyderski ___ 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] How do I generate a preprocessed file?
Tyler Roscoe wrote: > Thinking about this more, is there anything handed off to the compiler > that affects the preprocessor other than definitions (-D flags)? Yes, a lot of them: include directories specification, optimization flags (they also work as -D directives, e.g. they define __SSE2__ or not), language error handling mode (e.g. --Wno-pmf-conversion) etc. In fact I need the entire command line with option -E attached at the end. I would be happy to grab it from any C++-dependent object file (as they all use the same set of options). > What other flags do you really need? Well, pretty everything except "-o". Perfect matching is of key importance, as the result of preprocessing is a form of environment for a dynamic code generator. I need precisely the same set of interface definitions as the hand-compiled objects use. I am also very surprised that this problem is so hard in CMake -- I thought there is a single variable specifying a template for a given target, e.g. *.cpp => *.o Best regards Piotr Wyderski ___ 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] How do I generate a preprocessed file?
Tyler Roscoe wrote: > I don't know of a single place to gather all the flags CMake will pass > to your compiler. I've chceked those variables, but they provide not a very useful part of the command line, for example CMAKE_CXX_FLAGS_RELEASE gives me only -O3 -DNDEBUG. > get_target_properties() might also be of use. It is a very promising direction indeed, however after some hacking all I have from GET_TARGET_PROPERTY(_x ... COMPILE_FLAGS) is NOTFOUND :-/ But thank you Tyler for pointing me out the function. :-) Best regards Piotr Wyderski ___ 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] How do I generate a preprocessed file?
Tyler Roscoe wrote: > I don't know how to run the preprocessor by itself. If all you are > trying to do is write out a file containing the contents of entry_1 ... > entry_n, I wouldn't bother with the preprocessor; Unfortunately not, the primary goal is to generate a preprocessed source file. The entry list is just a way to inform the compiler about the input files involved. The task is easy on its own, i.e. run gcc with -E, but it must be invoked with exactly the same CMake-generated parameters as during regular object compilation. But this is far beyond my knowledge of CMake. Best regards Piotr Wyderski ___ 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 do I generate a preprocessed file?
Hello, my problem is as follow. I have a project composed of four directories: base, io, rt and vm. The first three of them are being built in a normal way, but the last one has some fancy requirements. Namely, in the directory vm I want to generate a file called inc.cpp, which is composed of all the header files from base, io and rt, preprocessed by the C++ compiler. So, in vm/CMakeLists.txt I specify: ADD_DEFINITIONS(-DCONFIG_BUILDING_VM) ADD_LIBRARY(vm SHARED inc.cpp) Next, I indicate that inc.cpp is generated: SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/inc.cpp PROPERTIES GENERATED 1) Then I create a list of all the header files of interest: FILE( GLOB _runtime_header_list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/base/*.h ${PROJECT_SOURCE_DIR}/io/*.h ${PROJECT_SOURCE_DIR}/rt/*.h) And specify a command to generate the file: ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/inc.cpp COMMAND YYY >inc.cpp DEPENDS ${_runtime_header_list} ) but what shoud YYY be in order to achieve the following goal: 1. all the entries from _runtime_header_list are enumerated and a single temporary file t1.cpp is created as follows: #include "entry_1" #include "entry_2" ... #include "entry_n" 2. t1 is sent to the C++ compiler (with all its options, definitions and include paths set as for a normal build), but for preprocessing stage only (i.e. g++ -E). The resulting C++ file is my inc.cpp. How can I achieve that goal using CMake? Of course it doesn't need to be done the way I specified above, as I am pretty new to CMake. A functional equivalent is all what I need, in particular I don't need t1.cpp. Best regards Piotr Wyderski ___ 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