[CMake] cmake side effects: possible bug
William A. Hoffman
billlist at nycap.rr.com
Sun Aug 27 22:09:08 EDT 2006
At 05:13 PM 8/27/2006, Alan W. Irwin wrote:
>On 2006-08-27 16:30-0400 William A. Hoffman wrote:
>
>>At 12:00 PM 8/27/2006, Steve Johns wrote:
>>>Michael Bell wrote:
>>>>>ADD_CUSTOM_TARGET(makeExecutable ALL)
>>>>>FOREACH(file ${SCRIPTS})
>>>>> CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}
>>>>> ${EXECUTABLE_OUTPUT_PATH}/../${file}
>>>>> @ONLY)
>>>>> ADD_CUSTOM_COMMAND(
>>>>> TARGET makeExecutable
>>>>> POST_BUILD
>>>>> COMMAND chmod
>>>>> ARGS +x ${EXECUTABLE_OUTPUT_PATH}/../${file}
>>>>> )
>>>>>ENDFOREACH(file)
>
>>[...] So, in the above example, the foreach and configure_file will run
>>when cmake is run on the project, and not when make is run. The custom
>>target will run when make is run but not the foreach and configure_file.
>
>
>Bill, just to make sure I am understanding your explanation, does that mean
>the above ADD_CUSTOM_COMMAND in the foreach loop creates a large number of
>different rules (one for each of the files in the SCRIPTS list) at cmake
>time, all of which are executed at make time?
Yes, that is what it is doing, basically, it is creating a makefile like this:
makeExecutable:
chmod a+x file1
chmod a+x file2
chmod a+x file3
....
But any time one of the input files changes, cmake is re-run,
and it is rerun on the whole project.
Something like this:
runCmake: CMakeLists.txt [any input to a configure_file command]
cmake /path/to/binary/for/project
Since variables can be shared from parent and sibling CMakeLists.txt files,
cmake has to read the whole project before creating any single Makefile.
-Bill
More information about the CMake
mailing list