CMake improvements, photoFormat improvement

This commit is contained in:
Syping 2021-09-04 17:13:03 +02:00
parent 464e5bf6dd
commit 9af28f0aa6
5 changed files with 72 additions and 10 deletions

View File

@ -1,5 +1,24 @@
#[[**************************************************************************
* libragephoto RAGE Photo Parser
* Copyright (C) 2021 Syping
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* This software is provided as-is, no warranties are given to you, we are not
* responsible for anything with use of the software, you are self responsible.
****************************************************************************]]
cmake_minimum_required(VERSION 3.7) cmake_minimum_required(VERSION 3.7)
project(ragephoto VERSION 0.1 LANGUAGES CXX) project(ragephoto VERSION 0.1 LANGUAGES CXX)
include(GNUInstallDirs)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
@ -38,7 +57,7 @@ set(RAGEPHOTO_SOURCES
option(BUILD_SHARED "Build libragephoto as shared library" ON) option(BUILD_SHARED "Build libragephoto as shared library" ON)
if (BUILD_SHARED) if (BUILD_SHARED)
add_library(ragephoto SHARED ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES}) add_library(ragephoto SHARED ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES})
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(LIBRAGEPHOTO_LIBTYPE -DLIBRAGEPHOTO_SHARED) set(LIBRAGEPHOTO_LIBTYPE -DLIBRAGEPHOTO_SHARED)
else() else()
add_library(ragephoto STATIC ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES}) add_library(ragephoto STATIC ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES})
@ -60,9 +79,9 @@ target_compile_definitions(ragephoto PRIVATE
target_compile_definitions(ragephoto PUBLIC target_compile_definitions(ragephoto PUBLIC
${LIBRAGEPHOTO_LIBTYPE} ${LIBRAGEPHOTO_LIBTYPE}
) )
install(TARGETS ragephoto DESTINATION lib) install(TARGETS ragephoto DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${RAGEPHOTO_HEADERS} DESTINATION include) install(FILES ${RAGEPHOTO_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/ragephoto.pc DESTINATION lib/pkgconfig) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/ragephoto.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
option(WITH_GTK_EXAMPLE "Build libragephoto with GTK Photo Viewer" OFF) option(WITH_GTK_EXAMPLE "Build libragephoto with GTK Photo Viewer" OFF)
if (WITH_GTK_EXAMPLE) if (WITH_GTK_EXAMPLE)
@ -74,12 +93,16 @@ if (WITH_QT_EXAMPLE)
add_subdirectory(examples/ragephoto-qtviewer) add_subdirectory(examples/ragephoto-qtviewer)
endif() endif()
option(WITH_EXTRACT "Build libragephoto with ragephoto-extract" ON) if (CMAKE_PROJECT_NAME EQUAL "ragephoto")
option(WITH_EXTRACT "Build libragephoto with ragephoto-extract" ON)
else()
option(WITH_EXTRACT "Build libragephoto with ragephoto-extract" OFF)
endif()
if (WITH_EXTRACT) if (WITH_EXTRACT)
set(EXTRACT_SOURCES set(EXTRACT_SOURCES
src/RagePhoto-Extract.cpp src/RagePhoto-Extract.cpp
) )
add_executable(ragephoto-extract ${RAGEPHOTO_HEADERS} ${EXTRACT_SOURCES}) add_executable(ragephoto-extract ${RAGEPHOTO_HEADERS} ${EXTRACT_SOURCES})
target_link_libraries(ragephoto-extract PRIVATE ragephoto) target_link_libraries(ragephoto-extract PRIVATE ragephoto)
install(TARGETS ragephoto-extract DESTINATION bin) install(TARGETS ragephoto-extract DESTINATION ${CMAKE_INSTALL_BINDIR})
endif() endif()

View File

@ -1,5 +1,24 @@
#[[**************************************************************************
* libragephoto RAGE Photo Parser
* Copyright (C) 2021 Syping
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* This software is provided as-is, no warranties are given to you, we are not
* responsible for anything with use of the software, you are self responsible.
****************************************************************************]]
cmake_minimum_required(VERSION 3.7) cmake_minimum_required(VERSION 3.7)
project(ragephoto-gtkviewer LANGUAGES CXX) project(ragephoto-gtkviewer LANGUAGES CXX)
include(GNUInstallDirs)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
@ -31,4 +50,4 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0")
target_link_directories(ragephoto-gtkviewer PRIVATE ${GTKMM_LIBRARY_DIRS} ${RAGEPHOTO_LIBRARY_DIRS}) target_link_directories(ragephoto-gtkviewer PRIVATE ${GTKMM_LIBRARY_DIRS} ${RAGEPHOTO_LIBRARY_DIRS})
endif() endif()
target_include_directories(ragephoto-gtkviewer PRIVATE ${GTKMM_INCLUDE_DIRS} ${RAGEPHOTO_INCLUDE_DIRS}) target_include_directories(ragephoto-gtkviewer PRIVATE ${GTKMM_INCLUDE_DIRS} ${RAGEPHOTO_INCLUDE_DIRS})
install(TARGETS ragephoto-gtkviewer DESTINATION bin) install(TARGETS ragephoto-gtkviewer DESTINATION ${CMAKE_INSTALL_BINDIR})

View File

@ -1,5 +1,24 @@
#[[**************************************************************************
* libragephoto RAGE Photo Parser
* Copyright (C) 2021 Syping
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* This software is provided as-is, no warranties are given to you, we are not
* responsible for anything with use of the software, you are self responsible.
****************************************************************************]]
cmake_minimum_required(VERSION 3.7) cmake_minimum_required(VERSION 3.7)
project(ragephoto-qtviewer LANGUAGES CXX) project(ragephoto-qtviewer LANGUAGES CXX)
include(GNUInstallDirs)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
@ -32,3 +51,4 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0")
target_link_directories(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_LIBRARY_DIRS}) target_link_directories(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_LIBRARY_DIRS})
endif() endif()
target_include_directories(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_INCLUDE_DIRS}) target_include_directories(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_INCLUDE_DIRS})
install(TARGETS ragephoto-qtviewer DESTINATION ${CMAKE_INSTALL_BINDIR})

View File

@ -125,7 +125,7 @@ bool RagePhoto::load(const char *data, size_t length)
p_headerSum = charToUInt32LE(uInt32Buffer); p_headerSum = charToUInt32LE(uInt32Buffer);
#endif #endif
if (format == static_cast<uint32_t>(PhotoFormat::RDR2)) if (p_photoFormat == PhotoFormat::RDR2)
pos = pos + 8; pos = pos + 8;
uint32_t headerSize = pos; uint32_t headerSize = pos;

View File

@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/lib libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/include includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: libragephoto Name: libragephoto
Description: Open Source RAGE Photo Parser for GTA V Description: Open Source RAGE Photo Parser for GTA V