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
This commit is contained in:
Syping 2021-12-01 07:41:47 +01:00
parent 81675355b0
commit aa9ac44f3e
3 changed files with 43 additions and 54 deletions

View File

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

View File

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

View File

@ -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
<b>Main Class:</b>
- RagePhoto