add pkgconfig, improve Qt example

This commit is contained in:
Syping 2021-08-27 21:48:33 +02:00
parent 33c3dcb512
commit dd47087afd
5 changed files with 43 additions and 23 deletions

View file

@ -17,10 +17,18 @@ set(QTVIEWER_SOURCES
src/main.cpp
)
if(TARGET ragephoto)
add_executable(ragephoto-qtviewer ${QTVIEWER_SOURCES})
target_link_libraries(ragephoto-qtviewer Qt${QT_VERSION_MAJOR}::Widgets ragephoto)
target_include_directories(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_INCLUDE_DIRS})
if (TARGET ragephoto)
set(RAGEPHOTO_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src)
set(RAGEPHOTO_LIBRARIES ragephoto)
else()
message("ragephoto-qtviewer need to be build with libragephoto together")
find_package(PkgConfig REQUIRED)
pkg_check_modules(RAGEPHOTO REQUIRED ragephoto)
endif()
add_executable(ragephoto-qtviewer ${QTVIEWER_SOURCES})
target_compile_options(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_CFLAGS})
target_link_libraries(ragephoto-qtviewer PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ${RAGEPHOTO_LIBRARIES})
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0")
target_link_directories(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_LIBRARY_DIRS})
endif()
target_include_directories(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_INCLUDE_DIRS})