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
This commit is contained in:
Syping 2021-11-12 06:55:37 +01:00
parent 56314c2738
commit bb53b342b7
7 changed files with 75 additions and 9 deletions

15
.gitattributes vendored Normal file
View file

@ -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

View file

@ -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()

View file

@ -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")

View file

@ -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")

View file

@ -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 */

View file

@ -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}

29
src/ragephoto.rc.in Normal file
View file

@ -0,0 +1,29 @@
#include <windows.h>
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