summaryrefslogtreecommitdiff
path: root/cmake/FindUtfcpp.cmake
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2015-08-04 14:14:20 -0700
committerJohn Wiegley <johnw@newartisans.com>2015-08-04 14:14:20 -0700
commit947a46ebebd141e928a9fcebb584e34df4e210a7 (patch)
tree4cb81e0e1c08d182ac86df3a6caa4dcc8ea90c53 /cmake/FindUtfcpp.cmake
parent614ba7d2136ab2b84abf74d7922a4f5d19b756cb (diff)
parent967a76193eb241ea99ae7d99d1f813590fa12ae3 (diff)
downloadfork-ledger-947a46ebebd141e928a9fcebb584e34df4e210a7.tar.gz
fork-ledger-947a46ebebd141e928a9fcebb584e34df4e210a7.tar.bz2
fork-ledger-947a46ebebd141e928a9fcebb584e34df4e210a7.zip
Merge pull request #369 from afh/pull/utfcpp_subtree
Replace utfcpp submodule with partial subtree
Diffstat (limited to 'cmake/FindUtfcpp.cmake')
-rw-r--r--cmake/FindUtfcpp.cmake30
1 files changed, 30 insertions, 0 deletions
diff --git a/cmake/FindUtfcpp.cmake b/cmake/FindUtfcpp.cmake
new file mode 100644
index 00000000..185a8d88
--- /dev/null
+++ b/cmake/FindUtfcpp.cmake
@@ -0,0 +1,30 @@
+# - Try to find utfcpp
+# Once done, this will define
+#
+# UTFCPP_FOUND - system has utfcpp's utf8.h
+# UTFCPP_PATH - the utfcpp include directories
+
+include(CheckCXXSourceCompiles)
+
+set(UTFCPP_FOUND FALSE)
+
+find_path(UTFCPP_INCLUDE_DIR
+ NAMES utf8.h
+ HINTS "${UTFCPP_PATH}" "${PROJECT_SOURCE_DIR}/lib/utfcpp/v2_0/source"
+)
+
+if (UTFCPP_INCLUDE_DIR)
+ set(CMAKE_REQUIRED_INCLUDES "${UTFCPP_INCLUDE_DIR}")
+ set(UTFCPP_FOUND TRUE)
+endif()
+
+check_cxx_source_compiles("
+#include <string>
+#include \"utf8.h\"
+
+int main(int argc, char** argv) {
+ std::string input = std::string(\"utfcpp\");
+ const char * p = input.c_str();
+ std::size_t len = input.length();
+ utf8::is_valid(p, p + len);
+}" HAVE_WORKING_UTFCPP)