Hello Philippe, you are generally right. But we have different build-processes for the same source-code at work. That means I cannot introduce this variable in the source code for everyone, this would break the non-cmake builds. Using CMake to insert this variable and run CONFIGURE_FILE afterwards results in missing semicolons too.
I have used a perl script now which runs as a PRE_BUILD-script and modifies the source code. It's a workaround that is pretty for me, but it would be nice if this IMHO faulty behaviour of CMake could be fixed. Best regards Marco -----Ursprüngliche Nachricht----- Von: Philippe Poilbarbe [mailto:[EMAIL PROTECTED] Gesendet: Donnerstag, 26. Januar 2006 12:28 An: wedekind; [email protected] Betreff: Re: AW: [CMake] CMake: Problem with reading files with semicolons wedekind a écrit : > ... > does not match any semicolons... Therefore I cannot modify C++ > source-code files with cmake, at least not the way I have tried. Can > you tell me how to insert a line of code (an #include in my case) into > an existing source file with CMake? > ... > Normally this kind of thing is done via CONFIGURE_FILE as it is typically a parameter depending on configuration (configuration: something determined before compile time). You can put in your C file some line like @INCLUDE_MYFILE@ and then define INCLUDE_MYFILE variable in cmake script and configure the C source file (or, usually a .h file which is included in your c file) Examples are below. Regards, Ph.P. ============ MyCFile.c.in: // Source file to be configured ... @INCLUDE_MYFILE@ ... CMakeLists.txt: IF (SOME_CONDITION) SET(INCLUDE_MYFILE "#include \"MyInclude.h\"") ENDIF (SOME_CONDITION) CONFIGURE_FILE(MyCFile.c.in MyCFile.c) _* or *_ MyCFile.c.in: // Source file to be configured #cmakedefine @HAVE_H_FILE@ ... #ifdef HAVE_H_FILE #include "MyInclude.h" #endif ... CMakeLists.txt: IF (SOME_CONDITION) SET(HAVE_H_FILE ON) ENDIF (SOME_CONDITION) CONFIGURE_FILE(MyCFile.c.in MyCFile.c) _______________________________________________ CMake mailing list [email protected] http://www.cmake.org/mailman/listinfo/cmake
