On 2013-09-03 14:18, Andreas Pakulat wrote:
On Tue, Sep 3, 2013 at 7:41 PM, Felipe Menezes Machado wrote:
On Tue, Sep 3, 2013 at 2:33 PM, Matthew Woehlke wrote:
On 2013-09-03 13:21, Felipe Menezes Machado wrote:
I'm having trouble understanding this behavior: what happens if the
directory of the executable doesn't exist?

I created a minimum example CMakeLists.txt (where foo.cpp is just a hello
world):

add_executable(test/test.bin foo.cpp)

If the "test" directory doesn't exist, should the build system create it?
Does that depend on the build system?

Yes; ninja has a feature where it creates any non-existing directories
that are used by any outputs. At least make does not have a similar
feature. I don't know about other generators (e.g. xcode, msvc).

I suppose CMake could be taught to generate make
rules to emulate ninja's behavior.

Whether or not such a thing should be done is an interesting question.
(Especially as it probably should be done for all generators, it at all.)

It would at least be a very interesting optional feature. Like something
you specify in your CMakeLists.txt file, that every output directory should
be created.

Well, IMO you're somewhat misusing cmake here, the add_executable and
add_library commands are intended to get the _names_ of targets. Not some
relative path to the dedicated output file. If you want to influence where
the binary goes you can do so with the corresponding target properties (see
RUNTIME_OUTPUT_DIRECTORY and OUTPUT_NAME).

So supporting relative paths as target name would pose a second way to
achieve the same thing which may be considered uneeded and possibly
confusing.

Well, sure, that too :-). However the problem still exists for more usual ways of determining output paths. (I've run into it with add_custom_command, for example.)

--
Matthew

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to