From a468fdca0eb380e6ea3d954d98b5995a45decbc9 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sat, 10 Jan 2015 16:16:05 +0100 Subject: Replace utfcpp submodule with partial subtree * Remove utfcpp submodule * Squashed 'lib/utfcpp/' content from commit 63cd498 git-subtree-dir: lib/utfcpp git-subtree-split: 63cd4984464e875546b4a91918be7355357a3a68 * Merge commit '82003f30ba8ba436cf7cef380155f50ed4242b37' as 'lib/utfcpp' * Remove needless utfcpp subtree files * Change include path to utfcpp Signed-off-by: Alexis Hildebrandt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index b7e7e920..285b7b6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -242,7 +242,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) # add the binary tree to the search path for include files so that we will # find TutorialConfig.h include_directories("${PROJECT_SOURCE_DIR}/lib") -include_directories("${PROJECT_SOURCE_DIR}/lib/utfcpp/source") +include_directories("${PROJECT_SOURCE_DIR}/lib/utfcpp/v2_0/source") include_directories("${PROJECT_BINARY_DIR}") configure_file( -- cgit v1.2.3 From 1d7dd3e082be8a046f21d4a2d51026ac3c1f7c14 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sun, 11 Jan 2015 12:10:00 +0100 Subject: [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 --- CMakeLists.txt | 16 +++++++++++++--- cmake/FindUtfcpp.cmake | 30 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 cmake/FindUtfcpp.cmake (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 285b7b6b..538a26c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,9 @@ set(Ledger_VERSION_MINOR 1) set(Ledger_VERSION_PATCH 0) set(Ledger_VERSION_DATE 20141005) +# Point CMake at any custom modules we may ship +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") + enable_testing() add_definitions(-std=c++11) @@ -236,13 +239,20 @@ endmacro(add_ledger_library_dependencies _target) ######################################################################## +include(FindUtfcpp) +if (UTFCPP_FOUND) + include_directories("${UTFCPP_INCLUDE_DIR}") +else() + message(FATAL_ERROR "Missing required header file: utf8.h\n" + "Define UTFCPP_PATH or install utfcpp locally into the source tree below lib/utfcpp/." + ) +endif() + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) # add the binary tree to the search path for include files so that we will -# find TutorialConfig.h -include_directories("${PROJECT_SOURCE_DIR}/lib") -include_directories("${PROJECT_SOURCE_DIR}/lib/utfcpp/v2_0/source") +# find system.hh include_directories("${PROJECT_BINARY_DIR}") configure_file( 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 +#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) -- cgit v1.2.3 From d0fba947ade223dfa351c49ac15c6939c35b5f89 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Tue, 28 Jul 2015 20:55:56 +0200 Subject: [cmake] Use CMAKE_SYSTEM_NAME to test the platform. APPLE and CMAKE_HOST_APPLE only check the host system, whereas CMAKE_SYSTEM_NAME checks the target system when cross-compiling. --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 6166780c..3c8c36ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,7 +225,7 @@ macro(add_ledger_library_dependencies _target) target_link_libraries(${_target} ${INTL_LIB}) endif() if (HAVE_BOOST_PYTHON) - if(APPLE) + if(CMAKE_SYSTEM_NAME STREQUAL Darwin) # Don't link directly to a Python framework on OS X, to avoid segfaults # when the module is imported from a different interpreter target_link_libraries(${_target} ${Boost_LIBRARIES}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 570a6592..8ed6e51a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -273,7 +273,7 @@ if (BUILD_LIBRARY) add_executable(ledger main.cc global.cc) target_link_libraries(ledger libledger) - if (APPLE AND HAVE_BOOST_PYTHON) + if (CMAKE_SYSTEM_NAME STREQUAL Darwin AND HAVE_BOOST_PYTHON) target_link_libraries(ledger ${PYTHON_LIBRARIES}) endif() @@ -297,7 +297,7 @@ print(s.get_python_lib(True, prefix=''))" if (PYTHON_SITE_PACKAGES) if (WIN32 AND NOT CYGWIN) set(_ledger_python_module_name "ledger.pyd") - elseif(CMAKE_HOST_APPLE) + elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(_ledger_python_module_name "ledger.so") else() set(_ledger_python_module_name "ledger${CMAKE_SHARED_LIBRARY_SUFFIX}") -- cgit v1.2.3