From febacdee5bf580932e1937f656b475762b48acd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Wed, 16 Mar 2022 23:34:43 +0100 Subject: Conversion to the cmake building system. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko (cherry picked from commit a6454b1658d325d6ff2d6ba6c349b772148798e0) --- kmm-macros.cmake | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 kmm-macros.cmake (limited to 'kmm-macros.cmake') diff --git a/kmm-macros.cmake b/kmm-macros.cmake new file mode 100644 index 0000000..4e50723 --- /dev/null +++ b/kmm-macros.cmake @@ -0,0 +1,93 @@ +################################################# +# # +# Auxiliary macros for KMyMoney # +# # +################################################# + +include( TDEMacros ) + + +################################################# +##### +##### kmm_install_includes +##### +##### The macro is used to determine the headers that are installed, +##### while the symlinks in the binary include directory are created. +##### +##### Syntax: +##### kmm_install_includes( +##### [FILES] include_name [include_name] +##### [DESTINATION subdir] +##### ) + +macro( kmm_install_includes ) + + unset( _files ) + unset( _dest ) + set( _var _files ) + + foreach( _arg ${ARGN} ) + + # found directive "FILES" + if( "+${_arg}" STREQUAL "+FILES" ) + unset( _files ) + set( _var _files ) + set( _directive 1 ) + endif( ) + + # found directive "DESTINATION" + if( "+${_arg}" STREQUAL "+DESTINATION" ) + unset( _dest ) + set( _var _dest ) + set( _directive 1 ) + endif( ) + + # collect data + if( _directive ) + unset( _directive ) + elseif( _var ) + list( APPEND ${_var} ${_arg} ) + endif( ) + + endforeach( ) + + # determine destination directory + if( NOT IS_ABSOLUTE "${_dest}" ) + set( _dest "${INCLUDE_INSTALL_DIR}/${_dest}" ) + endif() + file( RELATIVE_PATH _dest_sub "${INCLUDE_INSTALL_DIR}" "${_dest}" ) + file( MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/${_dest_sub}" ) + + # process files + foreach( _file IN LISTS _files ) + if( NOT TARGET kmm-includes ) + add_custom_target( kmm-includes + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + COMMENT "Prepare includes..." ) + endif() + + get_filename_component( _source_name "${_file}" NAME ) + get_filename_component( _source_file "${_file}" ABSOLUTE ) + file( RELATIVE_PATH _target_name "${CMAKE_SOURCE_DIR}" "${_source_file}" ) + string( REPLACE "/" "+" _target_name "${_target_name}" ) + + file( RELATIVE_PATH _link_source "${CMAKE_BINARY_DIR}/include/${_dest_sub}" ${_source_file} ) + file( RELATIVE_PATH _link_dest "${INCLUDE_INSTALL_DIR}" "${_dest}/${_source_name}" ) + + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/include/${_link_dest} + COMMAND + ${CMAKE_COMMAND} -E create_symlink + ${_link_source} ${CMAKE_BINARY_DIR}/include/${_link_dest} + COMMENT "Include file ${_link_dest}" + DEPENDS ${_source_file} + ) + add_custom_target( ${_target_name} + DEPENDS ${CMAKE_BINARY_DIR}/include/${_link_dest} + ) + add_dependencies( kmm-includes ${_target_name} ) + + install( FILES ${_file} DESTINATION ${_dest} ) + endforeach( _file ) + +endmacro( kmm_install_includes ) -- cgit v1.2.1