include (FindPkgConfig)
pkg_check_modules (GTKLIBS REQUIRED gtk+-3.0)
pkg_check_modules (THUNARX REQUIRED thunarx-3)

set (LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/share/locale)
configure_file (config.h.cmake config.h)
include_directories (${CMAKE_BINARY_DIR}/src)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")

add_library (thunar-encryption STATIC thunar-encryption.c)
target_include_directories (thunar-encryption PRIVATE ${GTKLIBS_INCLUDE_DIRS} PUBLIC ${THUNARX_INCLUDE_DIRS})
target_link_libraries (thunar-encryption ${GTKLIBS_LDFLAGS} ${THUNARX_LDFLAGS})
add_library (thunar-encryption-plugin SHARED thunar-encryption-plugin.c)
target_link_libraries (thunar-encryption-plugin thunar-encryption ${GTKLIBS_LDFLAGS} ${THUNARX_LDFLAGS})

install (PROGRAMS umount.fuse DESTINATION ${CMAKE_INSTALL_BINDIR}) #must be in the same path as /bin/umount
install (FILES encrypted-folder.svg DESTINATION share/icons/hicolor/scalable/apps/)
install (FILES encrypted-folder-new.svg DESTINATION share/icons/hicolor/scalable/apps/)
install (TARGETS thunar-encryption-plugin DESTINATION ${CMAKE_INSTALL_LIBDIR}/thunarx-3)

add_custom_target (uninstall)
add_custom_command (TARGET uninstall POST_BUILD COMMAND xargs rm -f < ${CMAKE_BINARY_DIR}/install_manifest.txt)
add_custom_command (TARGET uninstall POST_BUILD COMMAND rmdir ${CMAKE_INSTALL_PREFIX}/doc/${PROJECT_NAME}-${PROJECT_VERSION})
add_custom_command (TARGET uninstall POST_BUILD COMMAND rmdir --ignore-fail-on-non-empty ${CMAKE_INSTALL_PREFIX}/lib/thunarx-3)
