fix Windows static build

This commit is contained in:
Syping 2021-08-29 03:06:14 +02:00
parent 8c860855ae
commit 7721aab48b
3 changed files with 11 additions and 2 deletions

View File

@ -34,15 +34,17 @@ set(RAGEPHOTO_HEADERS
set(RAGEPHOTO_SOURCES set(RAGEPHOTO_SOURCES
src/RagePhoto.cpp src/RagePhoto.cpp
) )
configure_file(src/ragephoto.pc.in pkgconfig/ragephoto.pc @ONLY)
option(BUILD_SHARED "Build libragephoto as shared library" ON) option(BUILD_SHARED "Build libragephoto as shared library" ON)
if (BUILD_SHARED) if (BUILD_SHARED)
add_library(ragephoto SHARED ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES}) add_library(ragephoto SHARED ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES})
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
set(LIBRAGEPHOTO_LIBTYPE -DLIBRAGEPHOTO_SHARED)
else() else()
add_library(ragephoto STATIC ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES}) add_library(ragephoto STATIC ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES})
set(LIBRAGEPHOTO_LIBTYPE -DLIBRAGEPHOTO_STATIC)
endif() endif()
configure_file(src/ragephoto.pc.in pkgconfig/ragephoto.pc @ONLY)
option(WITH_BENCHMARK "Build with libragephoto benchmark" OFF) option(WITH_BENCHMARK "Build with libragephoto benchmark" OFF)
if (WITH_BENCHMARK) if (WITH_BENCHMARK)
@ -55,6 +57,9 @@ target_compile_definitions(ragephoto PRIVATE
LIBRAGEPHOTO_LIBRARY LIBRAGEPHOTO_LIBRARY
${LIBRAGEPHOTO_DEFINES} ${LIBRAGEPHOTO_DEFINES}
) )
target_compile_definitions(ragephoto PUBLIC
${LIBRAGEPHOTO_LIBTYPE}
)
install(TARGETS ragephoto DESTINATION lib) install(TARGETS ragephoto DESTINATION lib)
install(FILES ${RAGEPHOTO_HEADERS} DESTINATION include) install(FILES ${RAGEPHOTO_HEADERS} DESTINATION include)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/ragephoto.pc DESTINATION lib/pkgconfig) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/ragephoto.pc DESTINATION lib/pkgconfig)

View File

@ -20,6 +20,7 @@
#define LIBRAGEPHOTO_GLOBAL_H #define LIBRAGEPHOTO_GLOBAL_H
#ifdef _WIN32 #ifdef _WIN32
#ifndef LIBRAGEPHOTO_STATIC
#ifdef LIBRAGEPHOTO_LIBRARY #ifdef LIBRAGEPHOTO_LIBRARY
#define LIBRAGEPHOTO_EXPORT __declspec(dllexport) #define LIBRAGEPHOTO_EXPORT __declspec(dllexport)
#else #else
@ -28,5 +29,8 @@
#else #else
#define LIBRAGEPHOTO_EXPORT __attribute__((visibility("default"))) #define LIBRAGEPHOTO_EXPORT __attribute__((visibility("default")))
#endif #endif
#else
#define LIBRAGEPHOTO_EXPORT __attribute__((visibility("default")))
#endif
#endif // LIBRAGEPHOTO_GLOBAL_H #endif // LIBRAGEPHOTO_GLOBAL_H

View File

@ -6,4 +6,4 @@ Name: libragephoto
Description: Open Source RAGE Photo Parser for GTA V Description: Open Source RAGE Photo Parser for GTA V
Version: @PROJECT_VERSION@ Version: @PROJECT_VERSION@
Libs: -L${libdir} -lragephoto Libs: -L${libdir} -lragephoto
Cflags: -I${includedir} Cflags: -I${includedir} @LIBRAGEPHOTO_LIBTYPE@