[CMake] Generating Source Files
Jeremy Cowgar
jeremy at cowgar.com
Wed Apr 8 17:24:03 EDT 2009
Bill Hoffman wrote:
> If the included file is newer than the last run of cmake, cmake will
> re-run during make. In your code, it looks like you write two
> different files:
>
> "${CMAKE_SOURCE_DIR}/int.ex"
> and
> "${CMAKE_SOURCE_DIR}/interpreter/int.cmake"
>
> I don't get it...
I don't write int.ex, that is what is translated. That is the main
source for the interpreter. Now, when int.ex is translated, int.cmake is
updated. Now, this is the problem, or the disconnect..... int.cmake is
NOT updated when I run wmake. The EXECUTE_PROCESS call is what causes
int.cmake to be updated. What is updated is, parser.e. Let me run
through this...
1. I run cmake -G "Watcom WMake" ..
That sees that int.cmake does not exist, and it causes the
EXECUTE_PROCESS to run, which generates all sorts of C files as well as
int.cmake.
2. I run wmake
This makes my project and everything is great.
3. I edit ../source/parser.e and add new functionality. This file
../source/parser.e is listed in EU_CORE_FILES, which is checked in a
FOREACH loop as to if it's newer or not than int.cmake. (See my
FOREACH/EXECUTE_PROCESS below)
Now, here is where the problem starts. the int.cmake file is not
updated. I only updated parser.e However, I was expecting this to see
that parser.e is newer than int.cmake and cause EXECUTE_PROCESS to run
again, causing int.cmake to be updated. (See my FOREACH/EXECUTE_PROCESS
below)
4. Once done making changes to my project (parser.e is just one of many
files, but I keep using it as an example of what I edit), I run wmake.
However, int.cmake has not been updated at this point, still. I expected
that the FOREACH loop would detect that parser.e is newer than int.cmake
and cause the EXECUTE_PROCESS to translate my code again:
FOREACH( file ${EU_CORE_FILES} )
IF( "${CMAKE_SOURCE_DIR}/source/${file}" IS_NEWER_THAN
"${CMAKE_CURRENT_BINARY_DIR}/int.cmake" )
SET( EU_CORE_UPDATE 1 )
ENDIF()
ENDFOREACH()
IF( EU_CORE_UPDATE )
MESSAGE( "Translating interpreter..." )
EXECUTE_PROCESS(
COMMAND ${TRANSLATOR} -cmakefile "${CMAKE_SOURCE_DIR}/source/int.ex"
WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR} )
ENDIF()
Does that make it any clearer? I know I am just not describing my
process well enough, but I am trying.
Jeremy
More information about the CMake
mailing list