2021-09-04 17:13:03 +02:00
|
|
|
#[[**************************************************************************
|
|
|
|
* libragephoto RAGE Photo Parser
|
2024-01-18 19:53:47 +01:00
|
|
|
* Copyright (C) 2021-2024 Syping
|
2021-09-04 17:13:03 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
****************************************************************************]]
|
|
|
|
|
2023-03-03 03:26:59 +01:00
|
|
|
cmake_minimum_required(VERSION 3.8)
|
2023-10-30 14:31:50 +01:00
|
|
|
project(ragephoto VERSION 0.6.0 LANGUAGES C CXX)
|
2021-09-04 17:13:03 +02:00
|
|
|
include(GNUInstallDirs)
|
2021-08-25 00:30:10 +02:00
|
|
|
|
2021-11-09 03:25:27 +01:00
|
|
|
# RagePhoto CMake includes
|
|
|
|
include(cmake/unicode.cmake)
|
2021-11-06 20:17:28 +01:00
|
|
|
|
2023-11-09 20:17:37 +01:00
|
|
|
# RagePhoto Top Level
|
2021-12-14 03:15:52 +01:00
|
|
|
if (${CMAKE_PROJECT_NAME} STREQUAL "ragephoto")
|
|
|
|
set(RPTL_ON ON)
|
|
|
|
else()
|
|
|
|
set(RPTL_ON OFF)
|
|
|
|
endif()
|
|
|
|
|
2021-11-06 14:52:25 +01:00
|
|
|
# RagePhoto Source files
|
2023-06-06 19:39:22 +02:00
|
|
|
option(RAGEPHOTO_C_LIBRARY "Build libragephoto as C library" OFF)
|
|
|
|
if (RAGEPHOTO_C_LIBRARY)
|
|
|
|
set(RAGEPHOTO_HEADERS
|
2023-11-09 20:17:37 +01:00
|
|
|
src/core/RagePhoto.h
|
2024-01-15 17:05:54 +01:00
|
|
|
src/core/ragephoto_c
|
|
|
|
src/core/ragephoto_c.hpp
|
|
|
|
src/core/RagePhoto
|
|
|
|
src/core/RagePhoto.hpp
|
2023-11-09 20:17:37 +01:00
|
|
|
src/core/RagePhotoLibrary.h
|
|
|
|
src/core/RagePhotoTypedefs.h
|
2023-06-06 19:39:22 +02:00
|
|
|
)
|
|
|
|
set(RAGEPHOTO_SOURCES
|
2023-11-09 20:17:37 +01:00
|
|
|
src/core/RagePhoto.c
|
2023-06-06 19:39:22 +02:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
set(RAGEPHOTO_HEADERS
|
2024-01-15 17:05:54 +01:00
|
|
|
src/core/ragephoto_cxx
|
|
|
|
src/core/ragephoto_cxx.hpp
|
2023-11-09 20:17:37 +01:00
|
|
|
src/core/RagePhoto
|
|
|
|
src/core/RagePhoto.hpp
|
|
|
|
src/core/RagePhotoLibrary.h
|
|
|
|
src/core/RagePhotoTypedefs.h
|
2023-06-06 19:39:22 +02:00
|
|
|
)
|
|
|
|
set(RAGEPHOTO_SOURCES
|
2023-11-09 20:17:37 +01:00
|
|
|
src/core/RagePhoto.cpp
|
2023-06-06 19:39:22 +02:00
|
|
|
)
|
|
|
|
endif()
|
2021-08-27 01:47:09 +02:00
|
|
|
|
2021-11-06 14:52:25 +01:00
|
|
|
# RagePhoto Library Type
|
2023-02-07 03:06:22 +01:00
|
|
|
option(RAGEPHOTO_STATIC "Build libragephoto as static library" OFF)
|
2021-12-01 07:41:47 +01:00
|
|
|
if (RAGEPHOTO_STATIC)
|
|
|
|
set(LIBRAGEPHOTO_LIBTYPE LIBRAGEPHOTO_STATIC)
|
2021-11-16 06:20:20 +01:00
|
|
|
else()
|
2021-10-29 11:52:59 +02:00
|
|
|
set(LIBRAGEPHOTO_LIBTYPE LIBRAGEPHOTO_SHARED)
|
2021-08-27 01:47:09 +02:00
|
|
|
endif()
|
|
|
|
|
2021-11-06 14:52:25 +01:00
|
|
|
# RagePhoto Benchmark
|
2023-12-10 07:57:15 +01:00
|
|
|
option(RAGEPHOTO_BENCHMARK "Build with libragephoto benchmark" OFF)
|
2021-08-25 00:30:10 +02:00
|
|
|
|
2024-04-05 04:17:41 +02:00
|
|
|
# RagePhoto Debug
|
|
|
|
option(RAGEPHOTO_DEBUG "Build with libragephoto debug output" OFF)
|
|
|
|
|
2023-11-09 20:17:37 +01:00
|
|
|
# RagePhoto API
|
|
|
|
option(RAGEPHOTO_C_API "Build libragephoto with C API support" ON)
|
2023-06-06 19:39:22 +02:00
|
|
|
if (RAGEPHOTO_C_LIBRARY)
|
2023-06-11 05:41:32 +02:00
|
|
|
set(LIBRAGEPHOTO_API LIBRAGEPHOTO_C_ONLY)
|
2021-10-29 11:52:59 +02:00
|
|
|
else()
|
2023-06-06 19:39:22 +02:00
|
|
|
if (RAGEPHOTO_C_API)
|
2023-06-11 05:41:32 +02:00
|
|
|
set(LIBRAGEPHOTO_API LIBRAGEPHOTO_CXX_C)
|
2023-06-06 19:39:22 +02:00
|
|
|
list(APPEND RAGEPHOTO_HEADERS
|
2023-11-09 20:17:37 +01:00
|
|
|
src/core/RagePhoto.h
|
2024-01-15 17:05:54 +01:00
|
|
|
src/core/ragephoto_c
|
|
|
|
src/core/ragephoto_c.hpp
|
2023-06-06 19:39:22 +02:00
|
|
|
)
|
|
|
|
else()
|
2023-06-07 06:57:23 +02:00
|
|
|
set(LIBRAGEPHOTO_API LIBRAGEPHOTO_CXX_ONLY)
|
2023-06-06 19:39:22 +02:00
|
|
|
endif()
|
2021-10-29 11:52:59 +02:00
|
|
|
endif()
|
|
|
|
|
2024-01-18 19:53:47 +01:00
|
|
|
# RagePhoto C++ Standard
|
|
|
|
set(RAGEPHOTO_CXX_STANDARD "11" CACHE STRING "libragephoto C++ standard")
|
|
|
|
|
2021-11-12 06:55:37 +01:00
|
|
|
# RagePhoto Win32 Shared Resources
|
|
|
|
if (WIN32)
|
|
|
|
string(TIMESTAMP ragephoto_BUILD_YEAR "%Y" UTC)
|
2023-11-09 20:17:37 +01:00
|
|
|
configure_file(src/core/ragephoto.rc.in "${ragephoto_BINARY_DIR}/resources/ragephoto.rc" @ONLY)
|
2021-11-12 06:55:37 +01:00
|
|
|
list(APPEND RAGEPHOTO_SHARED_RESOURCES
|
2021-12-14 03:15:52 +01:00
|
|
|
"${ragephoto_BINARY_DIR}/resources/ragephoto.rc"
|
2021-11-12 06:55:37 +01:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-11-07 20:32:06 +01:00
|
|
|
# RagePhoto Configures + Target + Installs
|
2023-11-09 20:17:37 +01:00
|
|
|
configure_file(src/core/ragephoto.pc.in "${ragephoto_BINARY_DIR}/pkgconfig/ragephoto.pc" @ONLY)
|
|
|
|
configure_file(src/core/RagePhotoConfig.h.in "${ragephoto_BINARY_DIR}/include/RagePhotoConfig.h" @ONLY)
|
2021-11-03 10:19:32 +01:00
|
|
|
list(APPEND RAGEPHOTO_HEADERS
|
2023-02-07 03:06:22 +01:00
|
|
|
"${ragephoto_BINARY_DIR}/include/RagePhotoConfig.h"
|
2021-11-03 10:19:32 +01:00
|
|
|
)
|
2021-12-01 07:41:47 +01:00
|
|
|
if (RAGEPHOTO_STATIC)
|
|
|
|
add_library(ragephoto STATIC ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES} ${RAGEPHOTO_STATIC_RESOURCES})
|
|
|
|
else()
|
2021-11-12 06:55:37 +01:00
|
|
|
add_library(ragephoto SHARED ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES} ${RAGEPHOTO_SHARED_RESOURCES})
|
|
|
|
set_target_properties(ragephoto PROPERTIES
|
|
|
|
PREFIX "lib"
|
2023-02-07 03:06:22 +01:00
|
|
|
VERSION "${ragephoto_VERSION}"
|
2023-03-09 05:30:01 +01:00
|
|
|
SOVERSION "${ragephoto_VERSION}"
|
2021-11-12 06:55:37 +01:00
|
|
|
)
|
2021-11-06 14:52:25 +01:00
|
|
|
endif()
|
2024-01-18 19:53:47 +01:00
|
|
|
set_target_properties(ragephoto PROPERTIES
|
|
|
|
CXX_STANDARD ${RAGEPHOTO_CXX_STANDARD}
|
|
|
|
CXX_STANDARD_REQUIRED ON
|
|
|
|
)
|
2021-08-26 00:22:11 +02:00
|
|
|
target_compile_definitions(ragephoto PRIVATE
|
2021-08-25 00:30:10 +02:00
|
|
|
LIBRAGEPHOTO_LIBRARY
|
|
|
|
${LIBRAGEPHOTO_DEFINES}
|
2023-11-09 20:17:37 +01:00
|
|
|
$<$<BOOL:${RAGEPHOTO_BENCHMARK}>:RAGEPHOTO_BENCHMARK>
|
2024-04-05 04:17:41 +02:00
|
|
|
$<$<BOOL:${RAGEPHOTO_DEBUG}>:RAGEPHOTO_DEBUG>
|
2021-08-25 00:30:10 +02:00
|
|
|
)
|
2023-11-09 20:17:37 +01:00
|
|
|
if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914)
|
|
|
|
target_compile_options(ragephoto PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>)
|
2023-03-09 05:30:01 +01:00
|
|
|
endif()
|
2021-11-03 10:19:32 +01:00
|
|
|
target_include_directories(ragephoto PUBLIC
|
2021-12-14 03:15:52 +01:00
|
|
|
"${ragephoto_BINARY_DIR}/include"
|
2023-11-09 20:17:37 +01:00
|
|
|
"${ragephoto_SOURCE_DIR}/src/core"
|
2021-08-29 03:06:14 +02:00
|
|
|
)
|
2021-12-02 03:14:19 +01:00
|
|
|
install(TARGETS ragephoto
|
2021-12-14 03:15:52 +01:00
|
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
2021-12-02 03:14:19 +01:00
|
|
|
)
|
2021-12-14 03:15:52 +01:00
|
|
|
install(FILES ${RAGEPHOTO_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/RagePhoto")
|
2021-12-02 03:14:19 +01:00
|
|
|
if (UNIX)
|
2021-12-14 03:15:52 +01:00
|
|
|
install(FILES "${ragephoto_BINARY_DIR}/pkgconfig/ragephoto.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
2021-12-02 03:14:19 +01:00
|
|
|
endif()
|
2021-11-16 06:20:20 +01:00
|
|
|
|
|
|
|
# RagePhoto WebAssembly Target
|
|
|
|
if (EMSCRIPTEN)
|
2023-03-03 03:26:59 +01:00
|
|
|
include(cmake/wasm.cmake)
|
2021-11-16 06:20:20 +01:00
|
|
|
endif()
|
2021-08-25 00:30:10 +02:00
|
|
|
|
2021-11-06 14:52:25 +01:00
|
|
|
# RagePhoto Documentation
|
2021-12-01 07:41:47 +01:00
|
|
|
option(RAGEPHOTO_DOC "Build libragephoto with documentation" OFF)
|
|
|
|
if (RAGEPHOTO_DOC)
|
2021-09-14 19:35:46 +02:00
|
|
|
add_subdirectory(doc)
|
|
|
|
endif()
|
|
|
|
|
2021-11-06 14:52:25 +01:00
|
|
|
# RagePhoto Examples
|
2021-12-01 07:41:47 +01:00
|
|
|
option(RAGEPHOTO_EXAMPLE_GTKVIEWER "Build libragephoto with GTK Photo Viewer" OFF)
|
|
|
|
if (RAGEPHOTO_EXAMPLE_GTKVIEWER)
|
2021-08-27 05:33:20 +02:00
|
|
|
add_subdirectory(examples/ragephoto-gtkviewer)
|
|
|
|
endif()
|
|
|
|
|
2021-12-01 07:41:47 +01:00
|
|
|
option(RAGEPHOTO_EXAMPLE_QTVIEWER "Build libragephoto with Qt Photo Viewer" OFF)
|
|
|
|
if (RAGEPHOTO_EXAMPLE_QTVIEWER)
|
2021-08-27 20:07:14 +02:00
|
|
|
add_subdirectory(examples/ragephoto-qtviewer)
|
|
|
|
endif()
|
|
|
|
|
2021-11-06 14:52:25 +01:00
|
|
|
# RagePhoto Extract Tool
|
2021-12-14 03:15:52 +01:00
|
|
|
option(RAGEPHOTO_EXTRACT "Build libragephoto with ragephoto-extract" ${RPTL_ON})
|
2021-12-01 07:41:47 +01:00
|
|
|
if (RAGEPHOTO_EXTRACT)
|
2021-11-16 06:20:20 +01:00
|
|
|
# RagePhoto-Extract Source files
|
2021-12-01 07:41:47 +01:00
|
|
|
if (RAGEPHOTO_C_API)
|
2023-11-09 20:17:37 +01:00
|
|
|
set(EXTRACT_SOURCES src/extract/RagePhoto-Extract.c)
|
2021-11-03 11:21:37 +01:00
|
|
|
else()
|
2023-11-09 20:17:37 +01:00
|
|
|
set(EXTRACT_SOURCES src/extract/RagePhoto-Extract.cpp)
|
2021-11-03 11:21:37 +01:00
|
|
|
endif()
|
2021-11-16 06:20:20 +01:00
|
|
|
# RagePhoto-Extract Win32 Shared Resources
|
|
|
|
if (WIN32)
|
|
|
|
string(TIMESTAMP ragephoto_BUILD_YEAR "%Y" UTC)
|
2023-11-09 20:17:37 +01:00
|
|
|
configure_file(src/extract/ragephoto-extract.rc.in "${ragephoto_BINARY_DIR}/resources/ragephoto-extract.rc" @ONLY)
|
2021-11-16 06:20:20 +01:00
|
|
|
list(APPEND EXTRACT_RESOURCES
|
2021-12-14 03:15:52 +01:00
|
|
|
"${ragephoto_BINARY_DIR}/resources/ragephoto-extract.rc"
|
2021-11-16 06:20:20 +01:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
# RagePhoto-Extract Target + Installs
|
|
|
|
add_executable(ragephoto-extract ${RAGEPHOTO_HEADERS} ${EXTRACT_SOURCES} ${EXTRACT_RESOURCES})
|
2021-11-12 06:55:37 +01:00
|
|
|
set_target_properties(ragephoto-extract PROPERTIES
|
2021-11-16 06:20:20 +01:00
|
|
|
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
|
2024-01-18 19:53:47 +01:00
|
|
|
CXX_STANDARD ${RAGEPHOTO_CXX_STANDARD}
|
|
|
|
CXX_STANDARD_REQUIRED ON
|
2021-11-12 06:55:37 +01:00
|
|
|
)
|
2023-11-09 20:17:37 +01:00
|
|
|
if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914)
|
|
|
|
target_compile_options(ragephoto-extract PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>)
|
2023-03-09 05:30:01 +01:00
|
|
|
endif()
|
2021-08-27 21:48:33 +02:00
|
|
|
target_link_libraries(ragephoto-extract PRIVATE ragephoto)
|
2021-12-14 03:15:52 +01:00
|
|
|
install(TARGETS ragephoto-extract DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
2021-08-27 01:47:09 +02:00
|
|
|
endif()
|
2023-02-11 18:53:15 +01:00
|
|
|
|
2023-11-09 20:17:37 +01:00
|
|
|
# RagePhoto Python Package
|
|
|
|
option(RAGEPHOTO_PYTHON "Create ragephoto Python Package" OFF)
|
|
|
|
if (RAGEPHOTO_PYTHON)
|
|
|
|
# Python Package Library file
|
|
|
|
if (WIN32)
|
|
|
|
set(PYRAGEPHOTO_LIBRARY "libragephoto.dll")
|
|
|
|
else()
|
|
|
|
set(PYRAGEPHOTO_LIBRARY "libragephoto.so")
|
|
|
|
endif()
|
|
|
|
# Generate Python Package Project files
|
|
|
|
configure_file(src/python/setup.py.in "${ragephoto_BINARY_DIR}/pyragephoto/setup.py" @ONLY)
|
|
|
|
configure_file(src/python/pyproject.toml.in "${ragephoto_BINARY_DIR}/pyragephoto/pyproject.toml" @ONLY)
|
|
|
|
configure_file(src/python/__version__.py.in "${ragephoto_BINARY_DIR}/pyragephoto/ragephoto/__version__.py" @ONLY)
|
|
|
|
# Python Package Source files + Target
|
|
|
|
set(PYRAGEPHOTO_SOURCES
|
|
|
|
"src/python/__init__.py"
|
2024-03-25 13:06:14 +01:00
|
|
|
"src/python/libragephoto_loader.py"
|
2023-11-09 20:17:37 +01:00
|
|
|
"src/python/ragephoto.py"
|
|
|
|
)
|
|
|
|
add_custom_target(pyragephoto SOURCES ${PYRAGEPHOTO_SOURCES})
|
|
|
|
# Copy Python Package to build directory
|
|
|
|
file(COPY ${PYRAGEPHOTO_SOURCES} DESTINATION "${ragephoto_BINARY_DIR}/pyragephoto/ragephoto")
|
|
|
|
# Python Package Bundle Settings
|
|
|
|
option(RAGEPHOTO_PYTHON_BUNDLE_LIBRARY "Bundle libragephoto with ragephoto Python Package" OFF)
|
|
|
|
if (RAGEPHOTO_PYTHON_BUNDLE_LIBRARY)
|
|
|
|
add_custom_command(
|
|
|
|
TARGET ragephoto
|
|
|
|
POST_BUILD
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:ragephoto>" "${ragephoto_BINARY_DIR}/pyragephoto/ragephoto/${PYRAGEPHOTO_LIBRARY}"
|
|
|
|
BYPRODUCTS "${ragephoto_BINARY_DIR}/pyragephoto/ragephoto/${PYRAGEPHOTO_LIBRARY}"
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2023-02-11 18:53:15 +01:00
|
|
|
# CPack Package Generation
|
2023-04-09 21:22:13 +02:00
|
|
|
if (RPTL_ON)
|
|
|
|
include(InstallRequiredSystemLibraries)
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION "Open Source RAGE Photo Parser for GTA V and RDR 2")
|
|
|
|
set(CPACK_PACKAGE_NAME "libragephoto")
|
|
|
|
set(CPACK_PACKAGE_VENDOR "Syping")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "${ragephoto_VERSION_MAJOR}")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR "${ragephoto_VERSION_MINOR}")
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH "${ragephoto_VERSION_PATCH}")
|
|
|
|
set(CPACK_STRIP_FILES ON)
|
|
|
|
include(CPack)
|
|
|
|
endif()
|