On 12/13/2011 4:15 PM, David Cole wrote:
RUNTIME_OUTPUT_DIRECTORY is a target property, not a variable. You'd
have to use get_property to retrieve its value, not
${RUNTIME_OUTPUT_DIRECTORY}...

Thanks! I ended up with the following, in the targets CMakeList file

get_property(exe_path TARGET ${target} PROPERTY RUNTIME_OUTPUT_DIRECTORY)
set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${exe_path}/${target}.tds)
and that seem to work fine.

Question 1: What is best practice? To do the "get_property" in a top level CmakeList file and set_property in each targets CMakeList file. Or do I need both lines in each target CMakeList file?

Q 2: I have
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY      ${PROJECT_BINARY_DIR}/bins)

in the top level CMakeList file. If I want a variable corresponding to the RUNTIME_OUTPUT_DIRECTORY property, is there a best practice naming convention for such? For example, is it possible to create a variable with the same name, like:

get_property(RUNTIME_OUTPUT_DIRECTORY TARGET ${target} PROPERTY RUNTIME_OUTPUT_DIRECTORY)
?


-totte



HTH,
David


On Tue, Dec 13, 2011 at 10:04 AM, Totte Karlsson
<[email protected]>  wrote:
not sure if the following was sent to the newsgroup?
Sorry if posting double..

set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES

                        ${RUNTIME_OUTPUT_DIRECTORY}/${target}.tds
                        )


Is your RUNTIME_OUTPUT_DIRECTORY variable set up correctly?


In the top Cmake file I have
set(EXECUTABLE_OUTPUT_PATH      ${PROJECT_BINARY_DIR}/bins)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
Not sure if that is best practice? I'm a cmake beginner


Do you

perhaps mean the target property of this name instead, and what's
the value of your "target" variable?


In the 'target' cmake file, where the target is an application or a dll, it
looks something like (for an application 'read_from_file'):

set(target read_from_file)
add_executable(${target} main.cpp)

#MTK libraries
target_link_libraries (${target} mtkCommon)
...
#VTK libraries
target_link_libraries(${target} vtkCommon)
....
ADD_CUSTOM_COMMAND(
TARGET ${target} POST_BUILD
COMMAND echo ${target} and ${EXECUTABLE_OUTPUT_PATH}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
    ${CMAKE_CURRENT_SOURCE_DIR}/ball.mtk ${EXECUTABLE_OUTPUT_PATH}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
    ${CMAKE_CURRENT_SOURCE_DIR}/Alanine.mtk ${EXECUTABLE_OUTPUT_PATH}
)

set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
                        ${EXECUTABLE_OUTPUT_PATH}/ball.mtk
                        ${EXECUTABLE_OUTPUT_PATH}/Alanine.mtk

                        ${RUNTIME_OUTPUT_DIRECTORY}/${target}.tds
                        )

#then comes installs, omitted...
install (TARGETS ${target}                              DESTINATION bins)
...

In the set_property command, the cleaning works for the text files, ball and
Alanine.mtk. Interestingly, if I change it to
                        ${EXCECUTABLE_PATH}/${target}.tds

So I guess the RUNTIME_OUTPUT_DIRECTORY variable is not set correctly? I
thought
I read somewhere it is setup when the CMAKE_RUNTIME_OUTPUT_DIRECTORY is
setup?

Any feedback appreciated!
totte

--

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

Reply via email to