From aa9ac44f3edcfe64ae6c7038c5f20503616a493b Mon Sep 17 00:00:00 2001 From: Syping Date: Wed, 1 Dec 2021 07:41:47 +0100 Subject: [PATCH] CMake, Doc and README updates CMake: add EM_ON EM_OFF and rename BUILD_* and WITH_* options to RAGEPHOTO_* Doc: change C++ API to C/C++ API README: change build libragephoto section and add the reworked CMake options --- CMakeLists.txt | 61 +++++++++++++++++++++++++------------------------- README.md | 34 +++++++++------------------- doc/index.doc | 2 +- 3 files changed, 43 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c16ed9..4008313 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,15 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # RagePhoto CMake includes include(cmake/unicode.cmake) +# RagePhoto WebAssembly ON/OFF +if (EMSCRIPTEN) + set(EM_ON ON) + set(EM_OFF OFF) +else() + set(EM_ON OFF) + set(EM_OFF ON) +endif() + # RagePhoto Source files set(RAGEPHOTO_HEADERS src/RagePhoto.h @@ -37,33 +46,25 @@ set(RAGEPHOTO_SOURCES ) # RagePhoto Library Type -if (EMSCRIPTEN) - option(BUILD_SHARED "Build libragephoto as shared library" OFF) -else() - option(BUILD_SHARED "Build libragephoto as shared library" ON) -endif() -if (BUILD_SHARED) - option(WITH_C_API "Build libragephoto with C API support" ON) - set(LIBRAGEPHOTO_LIBTYPE LIBRAGEPHOTO_SHARED) -else() - if (EMSCRIPTEN) - option(WITH_C_API "Build libragephoto with C API support" ON) - else() - option(WITH_C_API "Build libragephoto with C API support" OFF) - endif() +option(RAGEPHOTO_STATIC "Build libragephoto as static library" ${EM_ON}) +if (RAGEPHOTO_STATIC) + option(RAGEPHOTO_C_API "Build libragephoto with C API support" ${EM_ON}) set(LIBRAGEPHOTO_LIBTYPE LIBRAGEPHOTO_STATIC) +else() + option(RAGEPHOTO_C_API "Build libragephoto with C API support" ON) + set(LIBRAGEPHOTO_LIBTYPE LIBRAGEPHOTO_SHARED) endif() # RagePhoto Benchmark -option(WITH_BENCHMARK "Build with libragephoto benchmark" OFF) -if (WITH_BENCHMARK) +option(RAGEPHOTO_BENCHMARK "Build with libragephoto benchmark" OFF) +if (RAGEPHOTO_BENCHMARK) list(APPEND LIBRAGEPHOTO_DEFINES RAGEPHOTO_BENCHMARK ) endif() # RagePhoto C API -if (WITH_C_API) +if (RAGEPHOTO_C_API) set(LIBRAGEPHOTO_API LIBRAGEPHOTO_C_API) list(APPEND RAGEPHOTO_HEADERS src/RagePhotoA.h @@ -88,13 +89,13 @@ configure_file(src/libragephoto_global.h.in include/libragephoto_global.h @ONLY) list(APPEND RAGEPHOTO_HEADERS ${PROJECT_BINARY_DIR}/include/libragephoto_global.h ) -if (BUILD_SHARED) +if (RAGEPHOTO_STATIC) + add_library(ragephoto STATIC ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES} ${RAGEPHOTO_STATIC_RESOURCES}) +else() 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} ${RAGEPHOTO_STATIC_RESOURCES}) endif() target_compile_definitions(ragephoto PRIVATE LIBRAGEPHOTO_LIBRARY @@ -137,31 +138,31 @@ if (EMSCRIPTEN) endif() # RagePhoto Documentation -option(WITH_DOCUMENTATION "Build libragephoto with documentation" OFF) -if (WITH_DOCUMENTATION) +option(RAGEPHOTO_DOC "Build libragephoto with documentation" OFF) +if (RAGEPHOTO_DOC) add_subdirectory(doc) endif() # RagePhoto Examples -option(WITH_GTK_EXAMPLE "Build libragephoto with GTK Photo Viewer" OFF) -if (WITH_GTK_EXAMPLE) +option(RAGEPHOTO_EXAMPLE_GTKVIEWER "Build libragephoto with GTK Photo Viewer" OFF) +if (RAGEPHOTO_EXAMPLE_GTKVIEWER) add_subdirectory(examples/ragephoto-gtkviewer) endif() -option(WITH_QT_EXAMPLE "Build libragephoto with Qt Photo Viewer" OFF) -if (WITH_QT_EXAMPLE) +option(RAGEPHOTO_EXAMPLE_QTVIEWER "Build libragephoto with Qt Photo Viewer" OFF) +if (RAGEPHOTO_EXAMPLE_QTVIEWER) add_subdirectory(examples/ragephoto-qtviewer) endif() # RagePhoto Extract Tool if (${CMAKE_PROJECT_NAME} STREQUAL "ragephoto") - option(WITH_EXTRACT "Build libragephoto with ragephoto-extract" ON) + option(RAGEPHOTO_EXTRACT "Build libragephoto with ragephoto-extract" ON) else() - option(WITH_EXTRACT "Build libragephoto with ragephoto-extract" OFF) + option(RAGEPHOTO_EXTRACT "Build libragephoto with ragephoto-extract" OFF) endif() -if (WITH_EXTRACT) +if (RAGEPHOTO_EXTRACT) # RagePhoto-Extract Source files - if (WITH_C_API) + if (RAGEPHOTO_C_API) enable_language(C) set(EXTRACT_SOURCES src/RagePhoto-Extract.c) else() diff --git a/README.md b/README.md index 3e90035..1b4b5fd 100644 --- a/README.md +++ b/README.md @@ -9,33 +9,21 @@ Open Source RAGE Photo Parser for GTA V and RDR 2 #### Build libragephoto ```bash -git clone https://github.com/Syping/libragephoto && cd libragephoto -mkdir -p build && cd build -cmake ../ -make -j $(nproc --all) -sudo make install +git clone https://github.com/Syping/libragephoto +cmake -B libragephoto-build libragephoto +cmake --build libragephoto-build +sudo cmake --install libragephoto-build ``` ##### Optional CMake flags -`-DWITH_DOCUMENTATION=ON` -`-DWITH_EXTRACT=OFF` -`-DWITH_GTK_EXAMPLE=ON` -`-DWITH_QT_EXAMPLE=ON` -`-DBUILD_SHARED=OFF` +`-DRAGEPHOTO_C_API=OFF` +`-DRAGEPHOTO_DOC=ON` +`-DRAGEPHOTO_EXAMPLE_GTKVIEWER=ON` +`-DRAGEPHOTO_EXAMPLE_QTVIEWER=ON` +`-DRAGEPHOTO_EXTRACT=OFF` +`-DRAGEPHOTO_STATIC=ON` -#### How to Use libragephoto - -```cpp -RagePhoto ragePhoto; -bool loaded = ragePhoto.load(data, size); -std::string photo = ragePhoto.photo(); -const char* photoData = ragePhoto.photoData(); -uint32_t photoSize = ragePhoto.photoSize(); -std::string json = ragePhoto.json(); -std::string title = ragePhoto.title(); -RagePhoto::Error error = ragePhoto.error(); -uint32_t format = ragePhoto.format(); // RagePhoto::GTA5 or RagePhoto::RDR2 -``` +#### RagePhoto API [RagePhoto C API](https://libragephoto.syping.de/doc/RagePhotoC_8h.html) [RagePhoto C++ API](https://libragephoto.syping.de/doc/classRagePhoto.html) diff --git a/doc/index.doc b/doc/index.doc index 3a98f45..0882e44 100644 --- a/doc/index.doc +++ b/doc/index.doc @@ -5,7 +5,7 @@ - Read/Write RAGE Photos error free and correct - Support for metadata stored in RAGE Photos - Export RAGE Photos to jpeg with ragephoto-extract -- High Efficient and Simple C++ API +- High Efficient and Simple C/C++ API Main Class: - RagePhoto