[RFC] Cross-platform CMake support

I’m trying to implement some post build action like supporting make run and post build copy.

This is what I managed to do for make run. It should use CMAKE_RUNTIME_OUTPUT_DIRECTORY instead of the CMAKE_BUILD_TYPE hack, but I could not access that variable.

add_custom_target( run
    COMMAND open ${CMAKE_BUILD_TYPE}/${APP_NAME}.app
    DEPENDS ${CMAKE_BUILD_TYPE}/${APP_NAME}.app/Contents/MacOS/${APP_NAME}
    WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
)

I also have to define CMAKE_BUILD_TYPE in my CMake file to make this work.

It is also often necessary to copy a shared library from a block next to the application executable. It would be more elegant to do this from the block config cmake than hacking it into the application cmake. This is what I have for a block with Leap Motion dynamic libraries in the app cmake. I’m not sure if it is possible to put this in the block cmake.

if( CINDER_MAC )
    add_custom_command( TARGET ${APP_NAME} POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy
            ${APP_DIR}/blocks/Cinder-Leap/lib/macosx/libLeap.dylib
            ${CMAKE_BUILD_TYPE}/${APP_NAME}.app/Contents/MacOS/
    )
elseif( CINDER_LINUX )
  ...
elseif( CINDER_MSW )
  ...
endif()

Do you have any suggestions to make these solutions simpler, more elegant? Or is it not possible to do this with the current cinder cmake system?