Re: [CMake] Fwd: Re: Compiler debug file, howto remove in clean?
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 to...@dunescientific.com 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
Re: [CMake] Fwd: Re: Compiler debug file, howto remove in clean?
On 12/14/2011 09:43 AM, Totte Karlsson wrote: 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? The latter, as the target must be defined before you can query its properties; thus, the GET_PROPERTY() command should reside in the respective CMakeLists.txt file next to the target. Moreover, the RUNTIME_OUTPUT_DIRECTORY property is empty if it's neither set explicitly nor initialized by CMAKE_RUNTIME_OUTPUT_DIRECTORY; perhaps, you should handle this case, e.g.: ADD_EXECUTABLE(xyz ...) GET_PROPERTY(s TARGET xyz PROPERTY RUNTIME_OUTPUT_DIRECTORY SET) IF(s) GET_PROPERTY(... TARGET xyz PROPERTY RUNTIME_OUTPUT_DIRECTORY) SET_PROPERTY(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ...) ELSE() # Warn or bail out or do just nothing... ENDIF() 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) ? Yes, because properties and variables are different types of objects with separate namespaces, and property-related predefined variables usually have the CMAKE_ prefix. Regards, Michael On Tue, Dec 13, 2011 at 10:04 AM, Totte Karlsson to...@dunescientific.com 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
[CMake] Fwd: Re: Compiler debug file, howto remove in clean?
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
Re: [CMake] Fwd: Re: Compiler debug file, howto remove in clean?
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}... HTH, David On Tue, Dec 13, 2011 at 10:04 AM, Totte Karlsson to...@dunescientific.com 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
Re: [CMake] Fwd: Re: Compiler debug file, howto remove in clean?
On 12/13/2011 04:04 PM, Totte Karlsson wrote: not sure if the following was sent to the newsgroup? Wasn't. ;-) Sorry if posting double.. Only to me. ;) 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 Don't use EXECUTABLE_OUTPUT_PATH, it's obsolete. With regard to the RUNTIME_OUTPUT_DIRECTORY variable, refer to David's reply. Regards, Michael 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