FindUtfcpp.cmake 739 B

12345678910111213141516171819202122232425262728293031
  1. # - Try to find utfcpp
  2. # Once done, this will define
  3. #
  4. # UTFCPP_FOUND - system has utfcpp's utf8.h
  5. # UTFCPP_PATH - the utfcpp include directories
  6. include(CheckCXXSourceCompiles)
  7. set(UTFCPP_FOUND FALSE)
  8. find_path(UTFCPP_INCLUDE_DIR
  9. NAMES utf8.h
  10. HINTS "${UTFCPP_PATH}" "${PROJECT_SOURCE_DIR}/lib/utfcpp/v2_0/source"
  11. )
  12. if (UTFCPP_INCLUDE_DIR)
  13. set(CMAKE_REQUIRED_INCLUDES "${UTFCPP_INCLUDE_DIR}")
  14. set(UTFCPP_FOUND TRUE)
  15. endif()
  16. check_cxx_source_compiles("
  17. #include <string>
  18. #include \"utf8.h\"
  19. int main(int argc, char** argv) {
  20. std::string input = std::string(\"utfcpp\");
  21. const char * p = input.c_str();
  22. std::size_t len = input.length();
  23. utf8::is_valid(p, p + len);
  24. }" HAVE_WORKING_UTFCPP)