project( corepdf )
cmake_minimum_required( VERSION 3.16 )

set( PROJECT_VERSION 4.5.0 )
set( PROJECT_VERSION_MAJOR 4 )
set( PROJECT_VERSION_MINOR 5 )
set( PROJECT_VERSION_PATCH 0 )

set( PROJECT_VERSION_MAJOR_MINOR ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} )
add_compile_definitions(VERSION_TEXT="${PROJECT_VERSION}")

set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_INCLUDE_CURRENT_DIR ON )
set( CMAKE_BUILD_TYPE Release )

add_definitions ( -Wall )
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
    set( CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Location for installing the project" FORCE )
endif()

set( CMAKE_AUTOMOC ON )
set( CMAKE_AUTORCC ON )
set( CMAKE_AUTOUIC ON )

find_package( Qt5Core REQUIRED )
find_package( Qt5Gui REQUIRED )
find_package( Qt5Widgets REQUIRED )
find_package( Qt5PrintSupport REQUIRED )

include_directories( pdfdocument )
include_directories( pdfwidget )

set( SOURCES
    main.cpp
    corepdf.cpp
    corepdf.h
    pdfdocument/Document.cpp
    pdfdocument/Document.hpp
    pdfdocument/Navigation.cpp
    pdfdocument/Navigation.hpp
    pdfdocument/Renderer.cpp
    pdfdocument/Renderer.hpp
    pdfdocument/RendererImpl.hpp
    pdfdocument/RenderOptions.hpp
    pdfwidget/qpdfview.cpp
    pdfwidget/qpdfview.h
    pdfwidget/qpdfview_p.cpp
    pdfwidget/qpdfview_p.h
    settings.cpp
    settings.h
)

set( UIS
    corepdf.ui
)

add_executable( corepdf ${SOURCES} ${UIS} )
target_link_libraries(
    corepdf
	Qt5::Core Qt5::Gui Qt5::Widgets
    poppler-qt5
    cprime-widgets cprime-core
)

install( TARGETS corepdf DESTINATION bin )
install( FILES org.cubocore.CorePDF.desktop DESTINATION share/applications )
install( FILES org.cubocore.CorePDF.svg DESTINATION share/icons/hicolor/scalable/apps/ )
