add pkgconfig, improve Qt example
This commit is contained in:
parent
33c3dcb512
commit
dd47087afd
5 changed files with 43 additions and 23 deletions
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.7)
|
||||
project(ragephoto LANGUAGES CXX)
|
||||
project(ragephoto VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
@ -27,16 +27,14 @@ else()
|
|||
message("-- Testing iconv - no")
|
||||
endif()
|
||||
|
||||
project(ragephoto LANGUAGES CXX)
|
||||
|
||||
set(RAGEPHOTO_SOURCES
|
||||
src/RagePhoto.cpp
|
||||
src/RagePhoto.h
|
||||
)
|
||||
set(RAGEPHOTO_HEADERS
|
||||
src/libragephoto_global.h
|
||||
src/RagePhoto.h
|
||||
)
|
||||
set(RAGEPHOTO_SOURCES
|
||||
src/RagePhoto.cpp
|
||||
)
|
||||
configure_file(src/ragephoto.pc.in pkgconfig/ragephoto.pc @ONLY)
|
||||
|
||||
option(BUILD_SHARED "Build libragephoto as shared library" ON)
|
||||
if (BUILD_SHARED)
|
||||
|
@ -59,6 +57,7 @@ target_compile_definitions(ragephoto PRIVATE
|
|||
)
|
||||
install(TARGETS ragephoto DESTINATION lib)
|
||||
install(FILES ${RAGEPHOTO_HEADERS} DESTINATION include)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/ragephoto.pc DESTINATION lib/pkgconfig)
|
||||
|
||||
option(WITH_GTK_EXAMPLE "Build libragephoto with GTK Photo Viewer" OFF)
|
||||
if (WITH_GTK_EXAMPLE)
|
||||
|
@ -72,11 +71,10 @@ endif()
|
|||
|
||||
option(WITH_EXTRACT "Build libragephoto with ragephoto-extract" ON)
|
||||
if (WITH_EXTRACT)
|
||||
project(ragephoto-extract LANGUAGES CXX)
|
||||
set(EXTRACT_SOURCES
|
||||
src/RagePhoto-Extract.cpp
|
||||
)
|
||||
add_executable(ragephoto-extract ${RAGEPHOTO_HEADERS} ${EXTRACT_SOURCES})
|
||||
target_link_libraries(ragephoto-extract ragephoto)
|
||||
target_link_libraries(ragephoto-extract PRIVATE ragephoto)
|
||||
install(TARGETS ragephoto-extract DESTINATION bin)
|
||||
endif()
|
||||
|
|
|
@ -8,8 +8,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTKMM REQUIRED gtkmm-3.0)
|
||||
|
||||
project(ragephoto-gtkviewer LANGUAGES CXX)
|
||||
|
||||
set(GTKVIEWER_HEADERS
|
||||
src/PhotoViewer.h
|
||||
)
|
||||
|
@ -21,11 +19,16 @@ set(GTKVIEWER_SOURCES
|
|||
|
||||
if (TARGET ragephoto)
|
||||
set(RAGEPHOTO_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src)
|
||||
set(RAGEPHOTO_LIBRARIES ragephoto)
|
||||
else()
|
||||
pkg_check_modules(RAGEPHOTO REQUIRED ragephoto)
|
||||
endif()
|
||||
|
||||
add_executable(ragephoto-gtkviewer ${GTKVIEWER_HEADERS} ${GTKVIEWER_SOURCES})
|
||||
target_link_libraries(ragephoto-gtkviewer ${GTKMM_LIBRARIES} ragephoto)
|
||||
target_link_directories(ragephoto-gtkviewer PRIVATE ${GTKMM_LIBRARY_DIRS})
|
||||
target_compile_options(ragephoto-gtkviewer PRIVATE ${GTKMM_CFLAGS} ${RAGEPHOTO_CFLAGS})
|
||||
target_link_libraries(ragephoto-gtkviewer PRIVATE ${GTKMM_LIBRARIES} ${RAGEPHOTO_LIBRARIES})
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0")
|
||||
target_link_directories(ragephoto-gtkviewer PRIVATE ${GTKMM_LIBRARY_DIRS} ${RAGEPHOTO_LIBRARY_DIRS})
|
||||
endif()
|
||||
target_include_directories(ragephoto-gtkviewer PRIVATE ${GTKMM_INCLUDE_DIRS} ${RAGEPHOTO_INCLUDE_DIRS})
|
||||
install(TARGETS ragephoto-gtkviewer DESTINATION bin)
|
||||
else()
|
||||
message("ragephoto-gtkviewer need to be build with libragephoto together")
|
||||
endif()
|
||||
|
|
|
@ -18,9 +18,17 @@ set(QTVIEWER_SOURCES
|
|||
)
|
||||
|
||||
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})
|
||||
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})
|
||||
|
|
|
@ -89,6 +89,8 @@ int main(int argc, char *argv[])
|
|||
QPushButton openButton("Open", &mainWindow);
|
||||
QObject::connect(&openButton, &QPushButton::clicked, &mainWindow, [&](){
|
||||
const QString filename = QFileDialog::getOpenFileName(&mainWindow, "Open Photo...", QString(), "GTA V Photo (PGTA5*)");
|
||||
if (filename.isEmpty())
|
||||
return;
|
||||
if (readPhotoFile(filename, &mainWindow, &photoLabel)) {
|
||||
QTimer::singleShot(0, &mainWindow, [&](){
|
||||
mainWindow.setFixedSize(mainWindow.sizeHint());
|
||||
|
|
9
src/ragephoto.pc.in
Normal file
9
src/ragephoto.pc.in
Normal file
|
@ -0,0 +1,9 @@
|
|||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: libragephoto
|
||||
Description: Open Source RAGE Photo Parser for GTA V
|
||||
Version: @PROJECT_VERSION@
|
||||
Libs: -L${libdir} -lragephoto
|
||||
Cflags: -I${includedir}
|
Loading…
Reference in a new issue