[CMake] Restrictions on where a binary can be put?

Nizar Khalifa Sallem nksallem at laas.fr
Sun Jan 9 15:32:04 EST 2011


At Sun, 9 Jan 2011 21:09:37 +0100,
Andreas Pakulat wrote:
> 
> [1  <text/plain; us-ascii (7bit)>]
> On 09.01.11 21:05:21, Andreas Pakulat wrote:
> > On 09.01.11 14:24:16, Michael Hertling wrote:
> > > On 01/09/2011 12:58 PM, Andreas Pakulat wrote:
> > > > Hi,
> > > > 
> > > > I'm having a bit of a problem here changing the runtime output directory
> > > > for a binary. Its an executable target named 'setup' and I'd like to put it
> > > > into the top-level directory. Unfortunately it always ends up in the bin/
> > > > directory, which is what CMAKE_RUNTIME_OUTPUT_DIRECTORY is being set to.
> > > > 
> > > > I'm using
> > > >     set_target_properties( setup PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} )
> > > > after creating the target currently, which should work as far as I can see
> > > > from the documentation. Are there maybe any restrictions on what the
> > > > directory may be or what targets can be put there?
> > > > 
> > > > If not, any suggestions how to debug this? I can see that the build.make
> > > > does already have the rule setup for putting the binary into bin/, so it
> > > > must be going wrong somewhere in the generation stage, but a simple cmake
> > > > --trace doesn't show up anything suspicious. Is there a switch to follow
> > > > the steps that cmake does during makefile-generation?
> > > 
> > > Could you provide a minimal but complete example?
> > 
> > Ok, attached case produces the error. Apparently the problem is fetching
> > the LOCATION property from the target and setting the
> > RUNTIME_OUTPUT_DIRECTORY afterwards. Looks like a cmake bug to me, so
> > I'll file a report.
> 
> Ooops, forgot the attachment :)
> 
> Andreas
> 
> -- 
> You should emulate your heros, but don't carry it too far.  Especially
> if they are dead.
> [2 test_output_dir.tar.gz <application/octet-stream (base64)>]
> 
> [3  <text/plain; us-ascii (7bit)>]
> _______________________________________________
> 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
Hi,

You I tested your CMakeLists.txt and this is no way a cmake bug but if
you sent  a wrong CMakeLists.txt file.
just remove this line get_target_property( _var foo LOCATION ) since
your target name is also "foo".
Tested without it and it works like a charm:
user at machine:~/tmp/test_output_dir/build$ rm -rf *
user at machine:~/tmp/test_output_dir/build$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/user/tmp/test_output_dir/build
user at machine:~/tmp/test_output_dir/build$ make
Scanning dependencies of target foo
[100%] Building CXX object CMakeFiles/foo.dir/main.cpp.o
Linking CXX executable foo
[100%] Built target foo
user at machine:~/tmp/test_output_dir/build$ ls
CMakeCache.txt  CMakeFiles  cmake_install.cmake  foo  Makefile

Best,
--
Nizar


More information about the CMake mailing list