#
# cmake directory contains all the macro and modules for 
# developing CamiTK extensions
#
set(CAMITK_CMAKE_PATH "share/${CAMITK_SHORT_VERSION_STRING}/cmake")

##############################################################################
#                                                                            #
# Install using the local/global install target                              #
#                                                                            #
##############################################################################

# install CamiTK configuration file
install(FILES ${CMAKE_BINARY_DIR}/share/${CAMITK_SHORT_VERSION_STRING}/cmake/CamiTKConfig.cmake
        DESTINATION ${CAMITK_CMAKE_PATH}
)
        
# install the generic cmake files
file(GLOB CAMITK_CMAKE_FILES "modules/*.cmake")

install(FILES ${CAMITK_CMAKE_FILES}
        DESTINATION ${CAMITK_CMAKE_PATH}
)

# install the macros 
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/modules/macros
        DESTINATION ${CAMITK_CMAKE_PATH}
)


# TODO:
# - Add a custom command that depends on the specified files and runs the install step
# - Add a custom target that depends on the output of the custom command
#
# Something like
# set(EXPORT_CAMITK_CMAKE_MACROS sdk-export-cmake-macros)
# add_custom_command(TARGET ${EXPORT_CAMITK_CMAKE_MACROS}
#                    POST_BUILD
#                    COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CAMITK_CMAKE_FILES} ${CAMITK_CMAKE_PATH}
#                    COMMENT "Installing build-time cmake macros"
#                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
#                    VERBATIM
# )
# add_custom_command(TARGET ${EXPORT_CAMITK_CMAKE_MACROS}
#                    POST_BUILD
#                    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/modules/macros ${CAMITK_CMAKE_PATH}
#                    COMMENT "Installing build-time cmake macros directory"
#                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
#                    VERBATIM
# )