summaryrefslogtreecommitdiff
path: root/cmake/FindUtfcpp.cmake
diff options
context:
space:
mode:
authorAlexis Hildebrandt <afh@surryhill.net>2015-01-11 12:10:00 +0100
committerAlexis Hildebrandt <afh@surryhill.net>2015-01-12 10:50:44 +0100
commit1d7dd3e082be8a046f21d4a2d51026ac3c1f7c14 (patch)
tree0e9dd4165ac65d7b7c8fec8fa0ceb23bd57ee9e1 /cmake/FindUtfcpp.cmake
parentcc0b32d9bc26f9345de3d89b540841bc2b8ad593 (diff)
downloadfork-ledger-1d7dd3e082be8a046f21d4a2d51026ac3c1f7c14.tar.gz
fork-ledger-1d7dd3e082be8a046f21d4a2d51026ac3c1f7c14.tar.bz2
fork-ledger-1d7dd3e082be8a046f21d4a2d51026ac3c1f7c14.zip
[cmake] Add FindUtfcpp.cmake
it will look for utfcpp in the standard system paths, UTFCPP_PATH, and lib/utfcpp/v2_0/source. This allows the use of utfcpp in: * standard locations such as /usr/include on distributions shipping utfcpp * custom locations for users via UTFCPP_PATH * the source tree using the default location of the utfcpp git submodule, .i.e lib/utfcpp/v2_0 Signed-off-by: Alexis Hildebrandt <afh@surryhill.net>
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)