[CMake] CMAKE_RUNTIME_OUTPUT_DIRECTORY cannot be overridden?

Ateljevich, Eli eli at water.ca.gov
Tue Jul 10 19:22:05 EDT 2012


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()




More information about the CMake mailing list