From bb53b342b7db94458f63d1cc6b26ea0113fec58b Mon Sep 17 00:00:00 2001 From: Syping Date: Fri, 12 Nov 2021 06:55:37 +0100 Subject: [PATCH] CMake updates, Win32 resources and .gitattributes added CMake: Improve RPATH handling for both TARGET and non-TARGET builds CMake: Updating configure_file's to handle ragephoto_ instead of PROJECT_ variables Win32 resources: Add basic library description with CMake's configure_file --- .gitattributes | 15 +++++++++++ CMakeLists.txt | 20 +++++++++++--- examples/ragephoto-gtkviewer/CMakeLists.txt | 4 +++ examples/ragephoto-qtviewer/CMakeLists.txt | 4 +++ src/libragephoto_global.h.in | 8 +++--- src/ragephoto.pc.in | 4 +-- src/ragephoto.rc.in | 29 +++++++++++++++++++++ 7 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 .gitattributes create mode 100644 src/ragephoto.rc.in diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2d8a894 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +# Auto detect text files and perform LF normalization +* text=auto eol=lf + +# Development files +CMakeLists.txt text eol=lf +*.cmake text eol=lf +*.cpp text eol=lf +*.h text eol=lf +*.h.in text eol=lf + +# Linux development file +*.pc.in text eol=lf + +# Windows development files +*.rc.in text eol=crlf diff --git a/CMakeLists.txt b/CMakeLists.txt index 168bd17..476ff6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,6 @@ set(RAGEPHOTO_SOURCES option(BUILD_SHARED "Build libragephoto as shared library" ON) if (BUILD_SHARED) option(WITH_C_API "Build libragephoto with C API support" ON) - set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) set(LIBRAGEPHOTO_LIBTYPE LIBRAGEPHOTO_SHARED) else() option(WITH_C_API "Build libragephoto with C API support" OFF) @@ -65,6 +64,15 @@ else() set(LIBRAGEPHOTO_API LIBRAGEPHOTO_C_NOAPI) endif() +# RagePhoto Win32 Shared Resources +if (WIN32) + string(TIMESTAMP ragephoto_BUILD_YEAR "%Y" UTC) + configure_file(src/ragephoto.rc.in resources/ragephoto.rc @ONLY) + list(APPEND RAGEPHOTO_SHARED_RESOURCES + ${PROJECT_BINARY_DIR}/resources/ragephoto.rc + ) +endif() + # RagePhoto Configures + Target + Installs configure_file(src/ragephoto.pc.in pkgconfig/ragephoto.pc @ONLY) configure_file(src/libragephoto_global.h.in include/libragephoto_global.h @ONLY) @@ -72,9 +80,12 @@ list(APPEND RAGEPHOTO_HEADERS ${PROJECT_BINARY_DIR}/include/libragephoto_global.h ) if (BUILD_SHARED) - add_library(ragephoto SHARED ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES}) + add_library(ragephoto SHARED ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES} ${RAGEPHOTO_SHARED_RESOURCES}) + set_target_properties(ragephoto PROPERTIES + PREFIX "lib" + ) else() - add_library(ragephoto STATIC ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES}) + add_library(ragephoto STATIC ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES} ${RAGEPHOTO_STATIC_RESOURCES}) endif() target_compile_definitions(ragephoto PRIVATE LIBRAGEPHOTO_LIBRARY @@ -119,6 +130,9 @@ if (WITH_EXTRACT) set(EXTRACT_SOURCES src/RagePhoto-Extract.cpp) endif() add_executable(ragephoto-extract ${RAGEPHOTO_HEADERS} ${EXTRACT_SOURCES}) + set_target_properties(ragephoto-extract PROPERTIES + INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} + ) target_link_libraries(ragephoto-extract PRIVATE ragephoto) install(TARGETS ragephoto-extract DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/examples/ragephoto-gtkviewer/CMakeLists.txt b/examples/ragephoto-gtkviewer/CMakeLists.txt index 8a817fc..5910025 100644 --- a/examples/ragephoto-gtkviewer/CMakeLists.txt +++ b/examples/ragephoto-gtkviewer/CMakeLists.txt @@ -33,11 +33,15 @@ set(GTKVIEWER_SOURCES if (TARGET ragephoto) set(RAGEPHOTO_LIBRARIES ragephoto) + set(RAGEPHOTO_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) else() pkg_check_modules(RAGEPHOTO REQUIRED ragephoto) endif() add_executable(ragephoto-gtkviewer WIN32 ${GTKVIEWER_SOURCES}) +set_target_properties(ragephoto-gtkviewer PROPERTIES + INSTALL_RPATH ${GTKMM_LIBRARY_DIRS};${RAGEPHOTO_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") diff --git a/examples/ragephoto-qtviewer/CMakeLists.txt b/examples/ragephoto-qtviewer/CMakeLists.txt index ca3f350..d7a8d67 100644 --- a/examples/ragephoto-qtviewer/CMakeLists.txt +++ b/examples/ragephoto-qtviewer/CMakeLists.txt @@ -38,12 +38,16 @@ set(QTVIEWER_SOURCES if (TARGET ragephoto) set(RAGEPHOTO_LIBRARIES ragephoto) + set(RAGEPHOTO_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) else() find_package(PkgConfig REQUIRED) pkg_check_modules(RAGEPHOTO REQUIRED ragephoto) endif() add_executable(ragephoto-qtviewer WIN32 ${QTVIEWER_SOURCES}) +set_target_properties(ragephoto-qtviewer PROPERTIES + INSTALL_RPATH ${RAGEPHOTO_LIBRARY_DIRS} +) 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") diff --git a/src/libragephoto_global.h.in b/src/libragephoto_global.h.in index 154947c..be3b55f 100644 --- a/src/libragephoto_global.h.in +++ b/src/libragephoto_global.h.in @@ -22,10 +22,10 @@ /* CMAKE CONFIG BEGIN */ #define @LIBRAGEPHOTO_API@ #define @LIBRAGEPHOTO_LIBTYPE@ -#define RAGEPHOTO_VERSION "@PROJECT_VERSION@" -#define RAGEPHOTO_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ -#define RAGEPHOTO_VERSION_MINOR @PROJECT_VERSION_MINOR@ -#define RAGEPHOTO_VERSION_PATCH @PROJECT_VERSION_PATCH@ +#define RAGEPHOTO_VERSION "@ragephoto_VERSION@" +#define RAGEPHOTO_VERSION_MAJOR @ragephoto_VERSION_MAJOR@ +#define RAGEPHOTO_VERSION_MINOR @ragephoto_VERSION_MINOR@ +#define RAGEPHOTO_VERSION_PATCH @ragephoto_VERSION_PATCH@ /* CMAKE CONFIG END */ /* RAGEPHOTO LIBRARY EXPORT BEGIN */ diff --git a/src/ragephoto.pc.in b/src/ragephoto.pc.in index f7f08f5..0903192 100644 --- a/src/ragephoto.pc.in +++ b/src/ragephoto.pc.in @@ -4,7 +4,7 @@ libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/RagePhoto Name: libragephoto -Description: Open Source RAGE Photo Parser for GTA V -Version: @PROJECT_VERSION@ +Description: Open Source RAGE Photo Parser for GTA V and RDR 2 +Version: @ragephoto_VERSION@ Libs: -L${libdir} -lragephoto Cflags: -I${includedir} diff --git a/src/ragephoto.rc.in b/src/ragephoto.rc.in new file mode 100644 index 0000000..4d88039 --- /dev/null +++ b/src/ragephoto.rc.in @@ -0,0 +1,29 @@ +#include +VS_VERSION_INFO VERSIONINFO +FILEVERSION @ragephoto_VERSION_MAJOR@, @ragephoto_VERSION_MINOR@, @ragephoto_VERSION_PATCH@, 0 +PRODUCTVERSION @ragephoto_VERSION_MAJOR@, @ragephoto_VERSION_MINOR@, @ragephoto_VERSION_PATCH@, 0 +FILEFLAGSMASK 0x3fL +FILEFLAGS 0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0809, 1200 + END + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Syping" + VALUE "FileDescription", "Open Source RAGE Photo Parser for GTA V and RDR 2" + VALUE "FileVersion", "@ragephoto_VERSION@" + VALUE "InternalName", "ragephoto" + VALUE "LegalCopyright", "Copyright © @ragephoto_BUILD_YEAR@ Syping" + VALUE "OriginalFilename", "ragephoto.dll" + VALUE "ProductName", "libragephoto" + VALUE "ProductVersion", "@ragephoto_VERSION@" + END + END +END