add codecvt support

This commit is contained in:
Syping 2021-08-27 01:47:09 +02:00
parent 63c0977ed6
commit c9b33b324d
5 changed files with 167 additions and 62 deletions

View file

@ -5,53 +5,68 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (WIN32)
message("-- Testing codecvt")
try_run(CODECVT_RUN CODECVT_COMPILE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/tests/CodecvtTest.cpp)
if (CODECVT_COMPILE)
list(APPEND LIBRAGEPHOTO_DEFINES
USE_WINAPI
CODECVT_COMPATIBLE
)
message("-- Testing codecvt - yes")
else()
message("-- Testing codecvt - no")
endif()
message("-- Testing iconv")
try_run(ICONV_RUN ICONV_COMPILE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/tests/IconvTest.cpp)
if (ICONV_COMPILE)
list(APPEND LIBRAGEPHOTO_DEFINES
USE_ICONV
ICONV_COMPATIBLE
)
message("-- Testing iconv - yes")
else()
message("-- Testing iconv - no")
endif()
option(WITH_BENCHMARK "Benchmark RagePhoto Parsing Engine" OFF)
project(ragephoto LANGUAGES CXX)
set(RAGEPHOTO_SOURCES
src/RagePhoto.cpp
src/RagePhoto.h
)
set(RAGEPHOTO_HEADERS
src/libragephoto_global.h
src/RagePhoto.h
)
option(BUILD_SHARED "Build libragephoto as shared library" ON)
if (BUILD_SHARED)
add_library(ragephoto SHARED ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES})
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
else()
add_library(ragephoto STATIC ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES})
endif()
option(WITH_BENCHMARK "Build with libragephoto benchmark" OFF)
if (WITH_BENCHMARK)
list(APPEND LIBRAGEPHOTO_DEFINES
RAGEPHOTO_BENCHMARK
)
endif()
project(ragephoto LANGUAGES CXX)
add_library(ragephoto SHARED
src/libragephoto_global.h
src/RagePhoto.cpp
src/RagePhoto.h
)
target_compile_definitions(ragephoto PRIVATE
LIBRAGEPHOTO_LIBRARY
${LIBRAGEPHOTO_DEFINES}
)
install(TARGETS ragephoto DESTINATION lib)
install(FILES
src/RagePhoto.h
src/libragephoto_global.h
DESTINATION include
)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
install(FILES ${RAGEPHOTO_HEADERS} DESTINATION include)
project(ragephoto-extract LANGUAGES CXX)
add_executable(ragephoto-extract
src/libragephoto_global.h
src/RagePhoto-Extract.cpp
src/RagePhoto.h
)
target_link_libraries(ragephoto-extract ragephoto)
install(TARGETS ragephoto-extract DESTINATION bin)
option(WITH_EXTRACT "Build ragephoto-extract" ON)
if (WITH_EXTRACT)
project(ragephoto-extract LANGUAGES CXX)
set(EXTRACT_SOURCES
src/RagePhoto-Extract.cpp
)
add_executable(ragephoto-extract ${RAGEPHOTO_HEADERS} ${EXTRACT_SOURCES})
target_link_libraries(ragephoto-extract ragephoto)
install(TARGETS ragephoto-extract DESTINATION bin)
endif()