set(LIBRARY_OUTPUT_PATH_ROOT ${LIBRARY_PRODUCT_DIR})
set(EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}")
set(LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}")

macro(ADD_PREFIX_HEADER _target _header)
    get_target_property(_old_compile_flags ${_target} COMPILE_FLAGS)
    if (${_old_compile_flags} STREQUAL "_old_compile_flags-NOTFOUND")
        set(_old_compile_flags "")
    endif ()
    set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "-include ${_header} ${_old_compile_flags}")
endmacro()

macro(ADD_POST_BUILD_COMMAND _library)
    add_custom_command(TARGET ${_library} POST_BUILD COMMAND echo Running ${_library} post build tasks... VERBATIM)
endmacro()

macro(COPY_LIBRARY_HEADERS _library _list _destination)
    add_custom_command(TARGET ${_library} POST_BUILD COMMAND echo Copying ${_library} library headers... VERBATIM)
    foreach (_file ${_list})
        get_filename_component(_absolute "${_file}" ABSOLUTE)
        add_custom_command(TARGET ${_library} POST_BUILD COMMAND mkdir -p ${LIBRARY_PRODUCT_DIR}/${_destination} && cp -u ${_absolute} ${LIBRARY_PRODUCT_DIR}/${_destination} VERBATIM)
    endforeach ()
endmacro()

macro(COPY_LIBRARY_HEADERS_DIRECTORY _library _source _destination)
    add_custom_command(TARGET ${_library} POST_BUILD COMMAND echo Copying ${_library} library headers... VERBATIM)
    get_filename_component(_absolute "${_source}" ABSOLUTE)
    add_custom_command(TARGET ${_library} POST_BUILD COMMAND mkdir -p ${LIBRARY_PRODUCT_DIR}/${_destination} && rsync -rpuL --include='*.h' --include='*.hpp' --exclude='*.*' ${_absolute}/* ${LIBRARY_PRODUCT_DIR}/${_destination})
endmacro()
