[CMake] Generating Source Files
Jeremy Cowgar
jeremy at cowgar.com
Wed Apr 8 15:48:54 EDT 2009
James Bigler wrote:
> On Wed, Apr 8, 2009 at 1:41 PM, Jeremy Cowgar <jeremy at cowgar.com> wrote:
>
>> Bill Hoffman wrote:
>>
>>> I like this solution as well, as you don't have to be running cmake from
>>> cmake. It does mean that you have to be able to run the parser at first
>>> cmake time.
>>>
>> Ok, I have this implemented now, however, it seems that the checks for
>> IS_NEWER and the execute_command does not run when you issue a normal make,
>> only when you do cmake. Thus, when I change anything, I have to run cmake to
>> even know if there are any changes that should cause a new build to take
>> place?
>>
>> For instance, I can edit parser.e and do wmake (using Watcom) and nothing
>> changes/compiles. It thinks everything is up to date. If I run cmake . then
>> it sees parser.e has changed, regenerates source and then wmake will build a
>> new binary :-(
>>
>> Jeremy
>>
>>
>
> This is why you need to generate a file that is included by CMake.
> This way CMake will know to reconfigure when that file changes.
>
James, the generator now generates a list for cmake. Here is the
revelant portions of my CMakeLists.txt file:
SET( EU_CORE_UPDATE 0 )
FOREACH( file ${EU_CORE_FILES} )
MESSAGE( "Checking file: ${file}" )
IF( ${file} IS_NEWER_THAN "${CMAKE_SOURCE_DIR}/interpreter/int.cmake" )
SET( EU_CORE_UPDATE 1 )
ENDIF()
ENDFOREACH()
IF( EU_CORE_UPDATE )
MESSAGE( "Translating interpreter..." )
EXECUTE_PROCESS(
COMMAND ${TRANSLATOR} -cmakefile "${CMAKE_SOURCE_DIR}/int.ex"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/interpreter" )
ENDIF()
INCLUDE( "${CMAKE_BINARY_DIR}/interpreter/int.cmake" )
IF( WIN32 )
ADD_EXECUTABLE( eui WIN32 ${INT_SOURCES} )
ENDIF()
int.cmake contains
SET( INT_SOURCES abc.c def.c xyz.c )
Jeremy
More information about the CMake
mailing list