Hi Chris

Thanks for your reply.

>The message() and file(REMOVE) commands will be executed when you run CMake.
>The command to generate the .cpp file won't be executed until you run make.

I don't think I have 'got' CMake yet. I am now definitely confused!

During normal development, i.e. when the CMakeLists.txt files are complete, do 
I execute CMake or make to build the app?

If the answer is 'make', what is the point of functions such as message() and 
file() only working when I execute CMake?

I am struggling with the online CMake documentation. The API is well defined, 
but there seems to be description of CMake concepts. Some more words would be 
helpful!

> Wouldn't it make more sense to generate the source file into the binary 
> directory and just leave it there?

Yes, that's a good point. I will look at doing it that way. My only argument 
against it is that I will have to configure svn to ignore that source file.
David

From: [email protected] [mailto:[email protected]] On Behalf Of Chris Hillery
Sent: 17 September 2010 11:05
To: David Aldrich
Cc: [email protected]
Subject: Re: [CMake] Execution order

The message() and file(REMOVE) commands will be executed when you run CMake. 
The command to generate the .cpp file won't be executed until you run make. 
That's why it's still around after you're done.

You can't really do exactly what you want here very easily; you'd need to have 
a separate custom command to delete the file after the build is complete, and 
I'm not sure how to set up the dependencies to automate that for you.

Why do you want this? Wouldn't it make more sense to generate the source file 
into the binary directory and just leave it there? Your add_custom_command() 
and list(APPEND SRCS) steps below will do this if you just change the OUTPUT to 
"${CMAKE_CURRENT_BINARY_DIR}/SourceFileInfo.cpp". This would have the added 
benefit of not forcing a rebuild of SourceFileInfo.o every time you run "make".

Ceej
aka Chris Hillery
On Fri, Sep 17, 2010 at 2:53 AM, David Aldrich 
<[email protected]<mailto:[email protected]>> wrote:
Hi

I want to generate a source file 'SourceFileInfo.cpp', then build a library and 
then delete the generated file.

So I wrote:

<snip>

add_custom_command (
  OUTPUT SourceFileInfo.cpp
  COMMAND ../VersionInfo/_gnuRelease/versionInfo . KERNEL
  DEPENDS ${SRCS}
  COMMENT "Generating SourceFileInfo.cpp"
  VERBATIM)

list(APPEND SRCS SourceFileInfo.cpp)

add_library( Kernel STATIC ${SRCS} )

message("Removing file")
file( REMOVE SourceFileInfo.cpp )

But the message 'Removing file' appears as the first action when executing make 
and the file remains after make has finished.

I guess that one can't interpret a CMakeLists.txt file sequentially, just like 
you can't interpret a makefile sequentially.

What am I doing wrong?

Where can I find an explanation of CMake command ordering?
Best regards
David


_______________________________________________
Powered by www.kitware.com<http://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



Click 
here<https://www.mailcontrol.com/sr/ko0+lZXnTAXTndxI!oX7UnAXsNktwyv39r1GFf+ITgBAMWnAT6em9peNQt!hhhplKiXbDbOtE1J8TccP!XTbKg==>
 to report this email as spam.
_______________________________________________
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

Reply via email to