Ateljevich, Eli | 10 Jul 2012 03:35
Picon
Favicon

How can I mimic a second CMAKE_RUNTIME_OUTPUT_DIRECTORY for the tests?

My source and tests are stored separately in a quasi-parallel arrangement:

/proj

  /build

    /bin       # CMAKE_RUNTIME_OUTPUT_DIRECTORY

   /mod1      # Build directory

   /mod2

    /test

        /mod1

        /mod2

    /src          # source

         /mod1

         /mod2

    /test         # source for tests

         /mod1

         /mod2

 

When I build the tests, I would like the tests to either go in /proj/build/testbin or stay where the object files are, same as they would if CMAKE_RUNTIME_OUTPUT_DIRECTORY had never been set. Is there any simple way to do this for the /test part of the directory tree, or do I have to set the RUNTIME_OUTOUT_DIRECTORY property all over the place?

 

There are enough test and non-test executables that this is painful either way.

 

Thanks,

Eli

--

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
Patrick Spendrin | 10 Jul 2012 11:01
Picon
Picon

Re: How can I mimic a second CMAKE_RUNTIME_OUTPUT_DIRECTORY for the tests?

Am 10.07.2012 03:35, schrieb Ateljevich, Eli:
> My source and tests are stored separately in a quasi-parallel arrangement:
> 
> /proj
> 
>   /build
> 
>     /bin       # CMAKE_RUNTIME_OUTPUT_DIRECTORY
> 
>    /mod1      # Build directory
> 
>    /mod2
> 
>     /test
> 
>         /mod1
> 
>         /mod2
> 
>     /src          # source
> 
>          /mod1
> 
>          /mod2
> 
>     /test         # source for tests
> 
>          /mod1
> 
>          /mod2
> 
>  
> 
> When I build the tests, I would like the tests to either go in
> /proj/build/testbin or stay where the object files are, same as they
> would if CMAKE_RUNTIME_OUTPUT_DIRECTORY had never been set. Is there any
> simple way to do this for the /test part of the directory tree, or do I
> have to set the RUNTIME_OUTOUT_DIRECTORY property all over the place?
> 
>  
> 
> There are enough test and non-test executables that this is painful
> either way.

Using a special add_my_test macro and automating setting this property
is probably the easiest way.

regards,
Patrick
--

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

Ateljevich, Eli | 11 Jul 2012 01:22
Picon
Favicon

CMAKE_RUNTIME_OUTPUT_DIRECTORY cannot be overridden?

My expectation from the documentation was that runtime output directories are initialized to
CMAKE_RUNTIME_OUTPUT_DIRECTORY, but I took that to mean they could be overridden. 

In the code below I attempt to set the RUNTIME_OUTPUT_DIRECTORY property to
${CMAKE_CURRENT_BINARY_DIR} for some tests. The global CMAKE_RUNTIME_OUTPUT_DIRECTORY is set to
/build/bin which I wanted to reserve for executables.

The "requested" message() points correctly to the directory I expected. The "actual" message() points to CMAKE_PROJECT_BINARY_DIR.

... is what I am attempting even possible?

Thanks --Eli

macro( make_test testname)
  add_executable(${testname} "${testname}.F90")
  message(STATUS "The requested outdir is: ${CMAKE_CURRENT_BINARY_DIR}")
  set_target_properties(${testmame} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR} )
  get_target_property(outdir ${testname} RUNTIME_OUTPUT_DIRECTORY)
  message(STATUS "The actual outdir is: ${outdir}")
  add_test(${testname} "${MAKE_CURRENT_BINARY_DIR}/${testname}" )
endmacro()

foreach(testname test_a
                 test_b)
  make_test(${testname})
endforeach()

--

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

Petr Kmoch | 11 Jul 2012 10:10
Picon
Gravatar

Re: CMAKE_RUNTIME_OUTPUT_DIRECTORY cannot be overridden?

Hi Eli.

You have a typo in the macro: set_target_properties(${testmame} ...
If it's a direct copy&paste from your code, it might be the source if the issue.

Petr

On Wed, Jul 11, 2012 at 1:22 AM, Ateljevich, Eli <eli@...> wrote:
> My expectation from the documentation was that runtime output directories are initialized to
CMAKE_RUNTIME_OUTPUT_DIRECTORY, but I took that to mean they could be overridden.
>
> In the code below I attempt to set the RUNTIME_OUTPUT_DIRECTORY property to
${CMAKE_CURRENT_BINARY_DIR} for some tests. The global CMAKE_RUNTIME_OUTPUT_DIRECTORY is set to
/build/bin which I wanted to reserve for executables.
>
> The "requested" message() points correctly to the directory I expected. The "actual" message() points
to CMAKE_PROJECT_BINARY_DIR.
>
> ... is what I am attempting even possible?
>
> Thanks --Eli
>
>
> macro( make_test testname)
>   add_executable(${testname} "${testname}.F90")
>   message(STATUS "The requested outdir is: ${CMAKE_CURRENT_BINARY_DIR}")
>   set_target_properties(${testmame} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR} )
>   get_target_property(outdir ${testname} RUNTIME_OUTPUT_DIRECTORY)
>   message(STATUS "The actual outdir is: ${outdir}")
>   add_test(${testname} "${MAKE_CURRENT_BINARY_DIR}/${testname}" )
> endmacro()
>
> foreach(testname test_a
>                  test_b)
>   make_test(${testname})
> endforeach()
>
>
> --
>
> 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
--

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


Gmane