diff --git a/CMakeLists.txt b/CMakeLists.txt index c1c291a..168bd17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,50 +24,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -# RagePhoto functionality tests -message("-- Testing codecvt") -try_run(CODECVT_RUN CODECVT_COMPILE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/tests/CodecvtTest.cpp) -if (CODECVT_COMPILE AND CODECVT_RUN EQUAL 0) - set(CODECVT_COMPAT TRUE) - message("-- Testing codecvt - yes") -else() - message("-- Testing codecvt - no") -endif() - -message("-- Testing iconv") -try_run(ICONV_RUN ICONV_COMPILE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/tests/IconvTest.cpp) -if (ICONV_COMPILE AND ICONV_RUN EQUAL 0) - set(ICONV_COMPAT TRUE) - message("-- Testing iconv - yes") -else() - message("-- Testing iconv - no") -endif() - -if (WIN32) - message("-- Testing wincvt") - try_run(WINCVT_RUN WINCVT_COMPILE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/tests/WincvtTest.cpp) - if (WINCVT_COMPILE AND WINCVT_RUN EQUAL 0) - set(WINCVT_COMPAT TRUE) - message("-- Testing wincvt - yes") - else() - message("-- Testing wincvt - no") - endif() -endif() - -# Unicode implementation for RagePhoto -if (WINCVT_COMPAT) - list(APPEND LIBRAGEPHOTO_DEFINES - UNICODE_WINCVT - ) -elseif (CODECVT_COMPAT) - list(APPEND LIBRAGEPHOTO_DEFINES - UNICODE_CODECVT - ) -elseif (ICONV_COMPAT) - list(APPEND LIBRAGEPHOTO_DEFINES - UNICODE_ICONV - ) -endif() +# RagePhoto CMake includes +include(cmake/unicode.cmake) # RagePhoto Source files set(RAGEPHOTO_HEADERS diff --git a/cmake/unicode.cmake b/cmake/unicode.cmake new file mode 100644 index 0000000..c15b918 --- /dev/null +++ b/cmake/unicode.cmake @@ -0,0 +1,62 @@ +#[[************************************************************************** +* libragephoto RAGE Photo Parser +* Copyright (C) 2021 Syping +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* This software is provided as-is, no warranties are given to you, we are not +* responsible for anything with use of the software, you are self responsible. +****************************************************************************]] + +# RagePhoto Unicode functionality tests +message("-- Testing codecvt") +try_run(CODECVT_RUN CODECVT_COMPILE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/tests/CodecvtTest.cpp) +if (CODECVT_COMPILE AND CODECVT_RUN EQUAL 0) + set(CODECVT_COMPAT TRUE) + message("-- Testing codecvt - yes") +else() + message("-- Testing codecvt - no") +endif() + +message("-- Testing iconv") +try_run(ICONV_RUN ICONV_COMPILE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/tests/IconvTest.cpp) +if (ICONV_COMPILE AND ICONV_RUN EQUAL 0) + set(ICONV_COMPAT TRUE) + message("-- Testing iconv - yes") +else() + message("-- Testing iconv - no") +endif() + +if (WIN32) + message("-- Testing wincvt") + try_run(WINCVT_RUN WINCVT_COMPILE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/tests/WincvtTest.cpp) + if (WINCVT_COMPILE AND WINCVT_RUN EQUAL 0) + set(WINCVT_COMPAT TRUE) + message("-- Testing wincvt - yes") + else() + message("-- Testing wincvt - no") + endif() +endif() + +# Unicode implementation for RagePhoto +if (WINCVT_COMPAT) + list(APPEND LIBRAGEPHOTO_DEFINES + UNICODE_WINCVT + ) +elseif (CODECVT_COMPAT) + list(APPEND LIBRAGEPHOTO_DEFINES + UNICODE_CODECVT + ) +elseif (ICONV_COMPAT) + list(APPEND LIBRAGEPHOTO_DEFINES + UNICODE_ICONV + ) +endif()