libragephoto: impl. linked iconv support

This commit is contained in:
Syping 2025-10-21 20:05:57 +02:00
parent aad0db247b
commit 9322e1943d
2 changed files with 37 additions and 18 deletions

View file

@ -1,6 +1,6 @@
#[[************************************************************************** #[[**************************************************************************
* libragephoto RAGE Photo Parser * libragephoto RAGE Photo Parser
* Copyright (C) 2021-2024 Syping * Copyright (C) 2021-2025 Syping
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -136,6 +136,7 @@ target_include_directories(ragephoto PUBLIC
"${ragephoto_BINARY_DIR}/include" "${ragephoto_BINARY_DIR}/include"
"${ragephoto_SOURCE_DIR}/src/core" "${ragephoto_SOURCE_DIR}/src/core"
) )
target_link_libraries(ragephoto PRIVATE ${LIBRAGEPHOTO_LIBRARIES})
install(TARGETS ragephoto install(TARGETS ragephoto
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"

View file

@ -1,6 +1,6 @@
#[[************************************************************************** #[[**************************************************************************
* libragephoto RAGE Photo Parser * libragephoto RAGE Photo Parser
* Copyright (C) 2021-2024 Syping * Copyright (C) 2021-2025 Syping
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -17,17 +17,31 @@
****************************************************************************]] ****************************************************************************]]
set(RAGEPHOTO_UNICODE "" CACHE STRING "libragephoto Unicode implementation") set(RAGEPHOTO_UNICODE "" CACHE STRING "libragephoto Unicode implementation")
set(RAGEPHOTO_UNICODE_LIBRARIES "" CACHE STRING "libragephoto Unicode libraries")
if (RAGEPHOTO_UNICODE) if (RAGEPHOTO_UNICODE)
string(TOUPPER "UNICODE_${RAGEPHOTO_UNICODE}" UNICODE_DEF) string(TOUPPER "UNICODE_${RAGEPHOTO_UNICODE}" UNICODE_DEF)
list(APPEND LIBRAGEPHOTO_DEFINES list(APPEND LIBRAGEPHOTO_DEFINES
"${UNICODE_DEF}" ${UNICODE_DEF}
)
list(APPEND LIBRAGEPHOTO_LIBRARIES
${RAGEPHOTO_UNICODE_LIBRARIES}
) )
message("-- UnicodeCvt - ${RAGEPHOTO_UNICODE}") message("-- UnicodeCvt - ${RAGEPHOTO_UNICODE}")
else() else()
# RagePhoto test source files
if (RAGEPHOTO_C_LIBRARY)
set(ICONV_SOURCE "${PROJECT_SOURCE_DIR}/tests/IconvTest.c")
set(WINCVT_SOURCE "${PROJECT_SOURCE_DIR}/tests/WincvtTest.c")
else()
set(CODECVT_SOURCE "${PROJECT_SOURCE_DIR}/tests/CodecvtTest.cpp")
set(ICONV_SOURCE "${PROJECT_SOURCE_DIR}/tests/IconvTest.cpp")
set(WINCVT_SOURCE "${PROJECT_SOURCE_DIR}/tests/WincvtTest.cpp")
endif()
# RagePhoto Unicode functionality tests # RagePhoto Unicode functionality tests
if (NOT RAGEPHOTO_C_LIBRARY) if (NOT RAGEPHOTO_C_LIBRARY)
message("-- Testing codecvt") message("-- Testing codecvt")
try_run(CODECVT_RUN CODECVT_COMPILE "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/tests/CodecvtTest.cpp") try_run(CODECVT_RUN CODECVT_COMPILE "${PROJECT_BINARY_DIR}" ${CODECVT_SOURCE})
if (CODECVT_COMPILE AND CODECVT_RUN EQUAL 0) if (CODECVT_COMPILE AND CODECVT_RUN EQUAL 0)
set(CODECVT_COMPAT TRUE) set(CODECVT_COMPAT TRUE)
message("-- Testing codecvt - yes") message("-- Testing codecvt - yes")
@ -37,25 +51,24 @@ else()
endif() endif()
message("-- Testing iconv") message("-- Testing iconv")
if (RAGEPHOTO_C_LIBRARY) try_run(ICONV_RUN ICONV_COMPILE "${PROJECT_BINARY_DIR}" "${ICONV_SOURCE}")
try_run(ICONV_RUN ICONV_COMPILE "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/tests/IconvTest.c")
else()
try_run(ICONV_RUN ICONV_COMPILE "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/tests/IconvTest.cpp")
endif()
if (ICONV_COMPILE AND ICONV_RUN EQUAL 0) if (ICONV_COMPILE AND ICONV_RUN EQUAL 0)
set(ICONV_COMPAT TRUE) set(ICONV_COMPAT TRUE)
message("-- Testing iconv - yes") message("-- Testing iconv - yes")
else()
try_run(ICONV_RUN ICONV_COMPILE "${PROJECT_BINARY_DIR}" "${ICONV_SOURCE}" LINK_LIBRARIES iconv)
if (ICONV_COMPILE AND ICONV_RUN EQUAL 0)
set(ICONV_COMPAT TRUE)
set(ICONV_LINKED TRUE)
message("-- Testing iconv - yes (linked)")
else() else()
message("-- Testing iconv - no") message("-- Testing iconv - no")
endif() endif()
endif()
if (WIN32) if (WIN32)
message("-- Testing wincvt") message("-- Testing wincvt")
if (RAGEPHOTO_C_LIBRARY) try_run(WINCVT_RUN WINCVT_COMPILE "${PROJECT_BINARY_DIR}" "${WINCVT_SOURCE}")
try_run(WINCVT_RUN WINCVT_COMPILE "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/tests/WincvtTest.c")
else()
try_run(WINCVT_RUN WINCVT_COMPILE "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/tests/WincvtTest.cpp")
endif()
if (WINCVT_COMPILE AND WINCVT_RUN EQUAL 0) if (WINCVT_COMPILE AND WINCVT_RUN EQUAL 0)
set(WINCVT_COMPAT TRUE) set(WINCVT_COMPAT TRUE)
message("-- Testing wincvt - yes") message("-- Testing wincvt - yes")
@ -67,18 +80,23 @@ else()
# Unicode implementation for RagePhoto # Unicode implementation for RagePhoto
if (WINCVT_COMPAT) if (WINCVT_COMPAT)
list(APPEND LIBRAGEPHOTO_DEFINES list(APPEND LIBRAGEPHOTO_DEFINES
"UNICODE_WINCVT" UNICODE_WINCVT
) )
message("-- UnicodeCvt - wincvt") message("-- UnicodeCvt - wincvt")
elseif (CODECVT_COMPAT AND NOT RAGEPHOTO_C_LIBRARY) elseif (CODECVT_COMPAT AND NOT RAGEPHOTO_C_LIBRARY)
list(APPEND LIBRAGEPHOTO_DEFINES list(APPEND LIBRAGEPHOTO_DEFINES
"UNICODE_CODECVT" UNICODE_CODECVT
) )
message("-- UnicodeCvt - codecvt") message("-- UnicodeCvt - codecvt")
elseif (ICONV_COMPAT) elseif (ICONV_COMPAT)
list(APPEND LIBRAGEPHOTO_DEFINES list(APPEND LIBRAGEPHOTO_DEFINES
"UNICODE_ICONV" UNICODE_ICONV
) )
if (ICONV_LINKED)
list(APPEND LIBRAGEPHOTO_LIBRARIES
iconv
)
endif()
message("-- UnicodeCvt - iconv") message("-- UnicodeCvt - iconv")
else() else()
message("-- UnicodeCvt - none") message("-- UnicodeCvt - none")