Minor fix during detection of CXX11 ABI

Minor fix during detection of CXX11 ABI

Signed-off-by: Nick Avramoussis <ce9ae7fb000f2865db247e53b12753caeda92c74@users.noreply.github.com>

--- cmake/OpenVDBHoudiniSetup.cmake
+++ cmake/OpenVDBHoudiniSetup.cmake
@@ -348,8 +348,8 @@

     set(GLIBCXX_USE_CXX11_ABI -1)
     if(NOT QUERIED_GCC_CXX11_ABI_SUCCESS)
-      string(FIND ${_GCC_CXX11_ABI} "0" GCC_OLD_CXX11_ABI)
-      string(FIND ${_GCC_CXX11_ABI} "1" GCC_NEW_CXX11_ABI)
+      string(FIND ${_GCC_CXX11_ABI} "_GLIBCXX_USE_CXX11_ABI 0" GCC_OLD_CXX11_ABI)
+      string(FIND ${_GCC_CXX11_ABI} "_GLIBCXX_USE_CXX11_ABI 1" GCC_NEW_CXX11_ABI)
       if(NOT (${GCC_OLD_CXX11_ABI} EQUAL -1))
         set(GLIBCXX_USE_CXX11_ABI 0)
       endif()


[CMake] Tell libc++ that we're using compiler-rt on Apple platforms

Reviewers: beanz, arphaman, EricWF

Subscribers: dberris, mgorny, jkorous, dexonsmith, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D58921

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@355927 91177308-0d34-0410-b5e6-96231b3b80d8

--- cmake/caches/Apple-stage2.cmake
+++ cmake/caches/Apple-stage2.cmake
@@ -38,6 +38,7 @@
 set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(LIBCXX_INSTALL_HEADERS ON CACHE BOOL "")
 set(LIBCXX_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(LLVM_LTO_VERSION_OFFSET 3000 CACHE STRING "")

 # Generating Xcode toolchains is useful for developers wanting to build and use


Repair cmake libatomic check.

Repair cmake libatomic check.

The cmake check for whether libatomic could be used had been
unconditionally setting the result to false. Which was somewhat
fortunate, because the prerequisite check for whether it was *needed*
was always claiming it was, even if it was not.

However, this made platforms where libatomic is actually necessary
fail to link.

Differential Revision: http://reviews.llvm.org/D10453

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@239819 91177308-0d34-0410-b5e6-96231b3b80d8

--- cmake/modules/CheckAtomic.cmake
+++ cmake/modules/CheckAtomic.cmake
@@ -2,15 +2,45 @@

 INCLUDE(CheckCXXSourceCompiles)

-check_function_exists(__atomic_fetch_add_4 HAVE___ATOMIC_FETCH_ADD_4)
-if( NOT HAVE___ATOMIC_FETCH_ADD_4 )
-  check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
-  set(HAVE_LIBATOMIC False)
-  if( HAVE_LIBATOMIC )
-    list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
+# Sometimes linking against libatomic is required for atomic ops, if
+# the platform doesn't support lock-free atomics.
+
+function(check_working_cxx_atomics varname)
+  set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+  set(CMAKE_REQUIRED_FLAGS "-std=c++11")
+  CHECK_CXX_SOURCE_COMPILES("
+#include <atomic>
+std::atomic<int> x;
+int main() {
+  return x;
+}
+" ${varname})
+  set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
+endfunction(check_working_cxx_atomics)
+
+# This isn't necessary on MSVC, so avoid command-line switch annoyance
+# by only running on GCC-like hosts.
+if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
+  # First check if atomics work without the library.
+  check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB)
+  # If not, check if the library exists, and atomics work with it.
+  if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
+    check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
+    if( HAVE_LIBATOMIC )
+      list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
+      check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB)
+      if (NOT HAVE_CXX_ATOMICS_WITH_LIB)
+	message(FATAL_ERROR "Host compiler must support std::atomic!")
+      endif()
+    else()
+      message(FATAL_ERROR "Host compiler appears to require libatomic, but cannot find it.")
+    endif()
   endif()
 endif()

+## TODO: This define is only used for the legacy atomic operations in
+## llvm's Atomic.h, which should be replaced.  Other code simply
+## assumes C++11 <atomic> works.
 CHECK_CXX_SOURCE_COMPILES("
 #ifdef _MSC_VER
 #include <Intrin.h> /* Workaround for PR19898. */


Cleanup FindDecibel test, no need to find QtTelepathyClient, QtTapioca is enough for now.

svn path=/trunk/KDE/kdenetwork/cmake/modules/FindDecibel.cmake; revision=598128

--- cmake/modules/FindDecibel.cmake
+++ cmake/modules/FindDecibel.cmake
@@ -23,20 +23,12 @@

 INCLUDE(UsePkgConfig)

-PKGCONFIG(QtTelepathy _TelepathyIncDir _TelepathyLinkDir _TelepathyLinkFlags _TelepathyCflags)
 PKGCONFIG(QtTapioca _TapiocaIncDir _TapiocaLinkDir _TapiocaLinkFlags _TapiocaCflags)

-set(QT_TELEPATHY_INCLUDE_DIR ${_TelepathyIncDir})
 set(QT_TAPIOCA_INCLUDE_DIR ${_TapiocaIncDir})

-set(DECIBEL_DEFINITIONS ${_TelepathyCflags} ${_TapiocaCflags})
-set(DECIBEL_INCLUDES ${QT_TELEPATHY_INCLUDE_DIR} ${QT_TAPIOCA_INCLUDE_DIR})
-
-FIND_LIBRARY(QT_TELEPATHY_LIBRARY NAMES QtTelepathyClient
-  PATHS
-  ${_TelepathyLinkDir}
-  NO_DEFAULT_PATH
-)
+set(DECIBEL_DEFINITIONS ${_TapiocaCflags})
+set(DECIBEL_INCLUDES ${QT_TAPIOCA_INCLUDE_DIR} )

 FIND_LIBRARY(QT_TAPIOCA_LIBRARY NAMES QtTapioca
   PATHS
@@ -44,7 +36,7 @@
   NO_DEFAULT_PATH
 )

-set(DECIBEL_LIBRARIES ${QT_TELEPATHY_LIBRARY} ${QT_TAPIOCA_LIBRARY})
+set(DECIBEL_LIBRARIES ${QT_TAPIOCA_LIBRARY})

 if (DECIBEL_INCLUDES AND DECIBEL_LIBRARIES)
    set(DECIBEL_FOUND TRUE)
@@ -60,4 +52,4 @@
   endif (DECIBEL_FIND_REQUIRED)
 endif (DECIBEL_FOUND)

-MARK_AS_ADVANCED(QT_TAPIOCA_INCLUDE_DIR QT_TAPIOCA_LIBRARY QT_TELEPATHY_INCLUDE_DIR QT_TELEPATHY_LIBRARY)
+MARK_AS_ADVANCED(QT_TAPIOCA_INCLUDE_DIR QT_TAPIOCA_LIBRARY)


Mac Packaging

Mac Packaging

First stab at automating third party dylib inclusion.

Signed-off-by: Gordon Smith <13c8c321b71403ffa9e1e91d85b30cb848a7b170@lexisnexis.com>

--- cmake_modules/commonSetup.cmake
+++ cmake_modules/commonSetup.cmake
@@ -482,6 +482,59 @@
   SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OSSDIR}/lib")
   SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

+  MACRO (FIXUP_MACPORTS apps dylibs)
+	foreach(dylib ${dylibs})
+		get_filename_component(dylib_path ${dylib} REALPATH)
+		install(PROGRAMS "${dylib_path}" DESTINATION "${OSSDIR}/lib2")
+	endforeach(dylib)
+	foreach(dylib ${dylibs})
+		get_filename_component(dylib_path ${dylib} REALPATH)
+		get_filename_component(dylib_name_ext ${dylib_path} NAME)
+		install(CODE "
+				execute_process(COMMAND install_name_tool -id \"@loader_path/../lib2/${dylib_name_ext}\" ${CMAKE_INSTALL_PREFIX}/${OSSDIR}/lib2/${dylib_name_ext})
+		" )
+		foreach(app ${apps})
+			#HACK HACK - Could be done generically with some REGEX?
+			string(REPLACE ".28.0.dylib" ".28.dylib" dylib_28_path "${dylib_path}")
+			string(REPLACE ".48.1.dylib" ".48.dylib" dylib_48_path "${dylib_path}")
+			install(CODE "
+				execute_process(COMMAND install_name_tool -change \"${dylib_path}\" \"@loader_path/../lib2/${dylib_name_ext}\" ${EXECUTABLE_OUTPUT_PATH}/${app})
+				execute_process(COMMAND install_name_tool -change \"${dylib_28_path}\" \"@loader_path/../lib2/${dylib_name_ext}\" ${EXECUTABLE_OUTPUT_PATH}/${app})
+				execute_process(COMMAND install_name_tool -change \"${dylib_48_path}\" \"@loader_path/../lib2/${dylib_name_ext}\" ${EXECUTABLE_OUTPUT_PATH}/${app})
+			" )
+		endforeach(app)
+	endforeach(dylib)
+  ENDMACRO()
+
+  if (APPLE)
+    SET(CMAKE_INSTALL_RPATH "@loader_path/../lib")
+    set(CMAKE_INSTALL_NAME_DIR "@loader_path/../lib")
+    set(APPS
+      "dafilesrv"
+      "dfuplus"
+      "ecl"
+      "ecl-package"
+      "ecl-queries"
+      "eclcc"
+      "eclplus"
+      "wuget"
+    )
+    set(DYLIBS)
+    if (USE_ICU)
+      set(DYLIBS ${DYLIBS} ${ICU_LIBRARIES})
+    endif ()
+    if (USE_BOOST_REGEX)
+      set(DYLIBS ${DYLIBS} ${BOOST_REGEX_LIBRARIES})
+    endif ()
+    if (USE_XALAN)
+      set(DYLIBS ${DYLIBS} ${XALAN_LIBRARIES})
+    endif ()
+    if (USE_XERCES)
+      set(DYLIBS ${DYLIBS} ${XERCES_LIBRARIES})
+    endif ()
+    FIXUP_MACPORTS("${APPS}" "${DYLIBS}")
+  endif()
+
   MACRO (FETCH_GIT_TAG workdir edition result)
       execute_process(COMMAND "${GIT_COMMAND}" describe --tags --dirty --abbrev=6 --match ${edition}*
         WORKING_DIRECTORY "${workdir}"


Some minor cleaning up of our common CMake file for LLVM [ci skip].

--- src/plugins/3rdparty/LLVM/cmake/common.cmake
+++ src/plugins/3rdparty/LLVM/cmake/common.cmake
@@ -23,7 +23,7 @@

     IF(WIN32)
         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244")
-        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4180 /wd4244 /wd4355 /wd4291 /wd4351 /wd4624 /wd4996")
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4180 /wd4244 /wd4355 /wd4291 /wd4351 /wd4624 /wd4722 /wd4996")
     ENDIF()
 ENDMACRO()


Reorder some C/CXX flags

Reorder some C/CXX flags

--- cmake/Modules/BuildSettings.cmake
+++ cmake/Modules/BuildSettings.cmake
@@ -97,7 +97,6 @@

 # SIMD OpenMP
 add_c_flag_if_avail("-fopenmp-simd")
-add_cxx_flag_if_avail("-fopenmp-simd")

 # general warnings
 add_cxx_flag_if_avail("-W")
@@ -105,6 +104,9 @@
 add_cxx_flag_if_avail("-Wextra")
 add_cxx_flag_if_avail("-Wshadow")
 add_cxx_flag_if_avail("-faligned-new")
+
+# SIMD OpenMP
+add_cxx_flag_if_avail("-fopenmp-simd")

 if(PTL_USE_ARCH)
     if(CMAKE_C_COMPILER_IS_INTEL)


Do not enable LTO flags for MSVC debug configuration

--- cmake/OpenCVCompilerOptions.cmake
+++ cmake/OpenCVCompilerOptions.cmake
@@ -244,8 +244,8 @@
   endif()

   if(ENABLE_LTO)
-    set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /GL")
-    set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS} /LTCG")
+    set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /GL")
+    set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE} /LTCG")
   endif()

 endif()


Add git-hooks to manage submodules by default.

--- cmake/initialize-submodules.cmake
+++ cmake/initialize-submodules.cmake
@@ -1,5 +1,6 @@
 macro(initialize_submodules)
   if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
+    # Initialize submodules
     set(git_modules_file "${PROJECT_SOURCE_DIR}/.gitmodules")
     if (EXISTS ${git_modules_file})
       file(STRINGS ${git_modules_file} file_lines)
@@ -23,5 +24,64 @@
         endif()
       endforeach()
     endif()
+
+    # Create git hooks
+    option(CREATE_GIT_HOOKS "Create git hooks to automatically update submodules." ON)
+    if (CREATE_GIT_HOOKS)
+      # post-checkout
+      if (NOT EXISTS "${PROJECT_SOURCE_DIR}/.git/hooks/post-checkout")
+        file(WRITE "${PROJECT_SOURCE_DIR}/.git/hooks/post-checkout"
+"#!/bin/sh
+
+echo \"Running .git/hooks/post-checkout\"
+echo
+
+echo \"git submodule sync --recursive\"
+echo
+git submodule sync --recursive
+
+echo \"git submodule update --init --recursive\"
+git submodule update --init --recursive
+
+"
+        )
+      endif()
+      # post-merge
+      if (NOT EXISTS "${PROJECT_SOURCE_DIR}/.git/hooks/post-merge")
+        file(WRITE "${PROJECT_SOURCE_DIR}/.git/hooks/post-merge"
+"#!/bin/sh
+
+# Note: Merge also happens after pull command.
+echo \"Running .git/hooks/post-merge\"
+echo
+
+echo \"git submodule sync --recursive\"
+echo
+git submodule sync --recursive
+
+echo \"git submodule update --init --recursive\"
+git submodule update --init --recursive
+
+"
+        )
+      endif()
+      # pre-push
+      if (NOT EXISTS "${PROJECT_SOURCE_DIR}/.git/hooks/pre-push")
+        file(WRITE "${PROJECT_SOURCE_DIR}/.git/hooks/pre-push"
+"#!/bin/sh
+
+echo \"Running .git/hooks/pre-push\"
+
+# Check if any submodules have unpushed commits.
+if ! [[ -z $(git submodule --quiet foreach --recursive 'git log --branches --not --remotes') ]]; then
+  echo
+  echo \"Warning: You have unpushed commits in one or more submodules. Don't forget to\"
+  echo \"push them if the parent repository is expecting those changes.\"
+fi
+
+"
+        )
+      endif()
+    endif()
   endif()
 endmacro()


cmake: locate Zephyr SDK before locating other host tools.

Follow-up: #49672

Zephyr SDK and host tools detection was reworked in #49672.

That rework accidentally changed the lookup order from:
- Zephyr SDK
- Other host tools
- Generic (host) C compiler

into
- Other host tools
- Zephyr SDK
- Generic (host) C compiler

this causes host tools shipped with Zephyr SDK, such as openocd to not
be discovered unless in path.

Restore the original order so that Zephyr SDK is located first so that
host tools from the SDK can be found without having them in path.

Signed-off-by: Torsten Rasmussen <a7c5b1d5a1f41fce6edfa3f7c2392ae0c59deafe@nordicsemi.no>

--- cmake/modules/FindHostTools.cmake
+++ cmake/modules/FindHostTools.cmake
@@ -48,6 +48,10 @@
   return()
 endif()

+find_package(Deprecated COMPONENTS XCC_USE_CLANG CROSS_COMPILE)
+
+find_package(Zephyr-sdk 0.15)
+
 # gperf is an optional dependency
 find_program(GPERF gperf)

@@ -60,10 +64,6 @@
 # imgtool is an optional dependency (the build may also fall back to scripts/imgtool.py
 # in the mcuboot repository if that's present in some cases)
 find_program(IMGTOOL imgtool)
-
-find_package(Deprecated COMPONENTS XCC_USE_CLANG CROSS_COMPILE)
-
-find_package(Zephyr-sdk 0.15)

 # Pick host system's toolchain if we are targeting posix
 if("${ARCH}" STREQUAL "posix")


[CMake] Split copying of Swift/Clang headers

This should result in less merge conflicts with upstream lldb.

--- cmake/modules/LLDBFramework.cmake
+++ cmake/modules/LLDBFramework.cmake
@@ -118,9 +118,13 @@
     COMMAND ${CMAKE_COMMAND} -E copy_directory
             ${clang_resource_headers_dir}
             $<TARGET_FILE_DIR:liblldb>/Resources/Clang/include
+    COMMENT "LLDB.framework: copy clang vendor-specific headers"
+  )
+
+  add_custom_command(TARGET liblldb POST_BUILD
     COMMAND ${CMAKE_COMMAND} -E copy_directory
             ${SWIFT_BINARY_DIR}/lib/swift
             $<TARGET_FILE_DIR:liblldb>/Resources/Swift
-    COMMENT "LLDB.framework: copy clang vendor-specific headers"
+    COMMENT "LLDB.framework: copy Swift vendor-specific headers"
   )
 endif()


Fine tune fix for ROOT-8701 for ROOT project itself.

--- cmake/modules/RootNewMacros.cmake
+++ cmake/modules/RootNewMacros.cmake
@@ -243,6 +243,10 @@
           list(APPEND fullheaderfiles ${f})
         endif()
       endforeach()
+    elseif(CMAKE_PROJECT_NAME STREQUAL ROOT AND
+           EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${fp}) # only for ROOT project
+      list(APPEND headerfiles ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
+      list(APPEND fullheaderfiles ${CMAKE_CURRENT_SOURCE_DIR}/${fp})
     elseif(IS_ABSOLUTE ${fp})
       list(APPEND headerfiles ${fp})
       list(APPEND fullheaderfiles ${fp})


Build the test binary in the test folder.

--- cmake/modules/RootNewMacros.cmake
+++ cmake/modules/RootNewMacros.cmake
@@ -1113,6 +1113,8 @@
   # Get the component from the path. Eg. core to form coreTests test suite name.
   ROOT_PATH_TO_STRING(test_name ${CMAKE_CURRENT_SOURCE_DIR}/Tests/)
   ROOT_ADD_GTEST(${test_name} ${test_files} ${ARGN})
+  # Override the target output folder for to put the binaries in the ${subdir}.
+  set_property(TARGET ${test_name} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${subdir}/)
 endfunction()

 #----------------------------------------------------------------------------
@@ -1128,11 +1130,12 @@
   # FIXME: For better coherence we could restrict the libraries the test suite could link
   # against. For example, tests in Core should link only against libCore. This could be tricky
   # to implement because some ROOT components create more than one library.
-  ROOT_EXECUTABLE(${test_suite} NOINSTALL ${source_files} LIBRARIES ${ARG_LIBRARIES})
+  ROOT_EXECUTABLE(${test_suite} ${source_files} LIBRARIES ${ARG_LIBRARIES})
+  set_property(TARGET ${test_suite} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
   target_link_libraries(${test_suite} gtest gtest_main gmock gmock_main)

   ROOT_PATH_TO_STRING(mangled_name ${test_suite} PATH_SEPARATOR_REPLACEMENT "-")
-  ROOT_ADD_TEST(gtest${mangled_name} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${test_suite})
+  ROOT_ADD_TEST(gtest${mangled_name} COMMAND ${test_suite})
 endfunction()


Fix for Windows CMake/nmake (ROOT-5560)

Fix for Windows CMake/nmake (ROOT-5560)

--- cmake/modules/RootNewMacros.cmake
+++ cmake/modules/RootNewMacros.cmake
@@ -292,7 +292,7 @@
           string (REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" src2 ${src1})
           string (REPLACE ${CMAKE_CURRENT_BINARY_DIR} "" src3 ${src2})
           string (REPLACE ".." "__" src ${src3})
-          get_filename_component(name ${src} NAME_WE)
+          get_filename_component(name ${src} NAME)
           get_filename_component(path ${src} PATH)
           set(lib_objs ${lib_objs} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir/${path}/${name}.obj)
         endif()


HPCC-15296 Fix cmake build issue against HPCC 6.0.0

Signed-off-by: Gleb Aronsky <9746c29e6ed593f1e1ccbe1aacaf8f0320155813@lexisnexis.com>

--- cmake_modules/nmCommonSetup.cmake
+++ cmake_modules/nmCommonSetup.cmake
@@ -28,8 +28,8 @@
                         ERROR_VARIABLE  packageManagement
                 )

-IF ("${COMMONSETUP_DONE}" STREQUAL "")
-  SET (COMMONSETUP_DONE 1)
+IF ("${NM_COMMONSETUP_DONE}" STREQUAL "")
+  SET (NM_COMMONSETUP_DONE 1)

   MACRO (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage)
     STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource)
@@ -45,102 +45,7 @@

   cmake_policy ( SET CMP0011 NEW )

-  option(CLIENTTOOLS "Enable the building/inclusion of a Client Tools component." OFF)
-  option(PLATFORM "Enable the building/inclusion of a Platform component." ON)
-  option(DEVEL "Enable the building/inclusion of a Development component." OFF)
-  option(CLIENTTOOLS_ONLY "Enable the building of Client Tools only." OFF)
-
-  option(USE_ANTLRc "Enable use of ANTLR (C target) to support SQL parsing" OFF)
-  option(USE_BINUTILS "Enable use of binutils to embed workunit info into shared objects" ON)
-  option(USE_CPPUNIT "Enable unit tests (requires cppunit)" OFF)
-  option(USE_OPENLDAP "Enable OpenLDAP support (requires OpenLDAP)" OFF)
-  option(USE_ICU "Enable unicode support (requires ICU)" ON)
-  option(USE_BOOST_REGEX "Configure use of boost regex" ON)
-  option(Boost_USE_STATIC_LIBS "Use boost_regex static library for RPM BUILD" OFF)
-  option(USE_OPENSSL "Configure use of OpenSSL" ON)
-  option(USE_ZLIB "Configure use of zlib" ON)
-  option(USE_GIT "Configure use of GIT (Hooks)" ON)
-  endif()
-  option(USE_LIBARCHIVE "Configure use of libarchive" ON)
-  option(USE_URIPARSER "Configure use of uriparser" OFF)
-  option(USE_NATIVE_LIBRARIES "Search standard OS locations for thirdparty libraries" ON)
-  option(USE_GIT_DESCRIBE "Use git describe to generate build tag" ON)
-  option(CHECK_GIT_TAG "Require git tag to match the generated build tag" OFF)
-  option(USE_XALAN "Configure use of xalan" ON)
-  option(USE_APR "Configure use of Apache Software Foundation (ASF) Portable Runtime (APR) libraries" OFF)
-  option(USE_LIBXSLT "Configure use of libxslt" ON)
-  option(MAKE_DOCS "Create documentation at build time." OFF)
-  option(MAKE_DOCS_ONLY "Create a base build with only docs." OFF)
-  option(DOCS_DRUPAL "Create Drupal HTML Docs" OFF)
-  option(DOCS_EPUB "Create EPUB Docs" OFF)
-  option(DOCS_MOBI "Create Mobi Docs" OFF)
-  option(USE_RESOURCE "Use resource download in ECLWatch" OFF)
-  option(GENERATE_COVERAGE_INFO "Generate coverage info for gcov" OFF)
-  option(USE_SIGNED_CHAR "Build system with default char type is signed" OFF)
-  option(USE_UNSIGNED_CHAR "Build system with default char type is unsigned" OFF)
-
-  option(USE_PYTHON "Enable Python support" OFF)
-  option(USE_V8 "Enable V8 JavaScript support" OFF)
-  option(USE_JNI "Enable Java JNI support" OFF)
-  option(USE_RINSIDE "Enable R support support" OFF)
-
-  option(USE_OPTIONAL "Automatically disable requested features with missing dependencies" ON)
-
-  if ( USE_PYTHON OR USE_V8 OR USE_JNI OR USE_RINSIDE )
-      set( WITH_PLUGINS ON )
-  endif()
-
-  if ( USE_XALAN AND USE_LIBXSLT )
-      set(USE_XALAN OFF)
-  endif()
-  if ( USE_LIBXSLT )
-      set(USE_LIBXML2 ON)
-  endif()
-  if ( USE_XALAN )
-      set(USE_XERCES ON)
-  endif()
-
-  if(USE_OPENSSL)
-    find_package(OPENSSL)
-    if (OPENSSL_FOUND)
-      add_definitions (-D_USE_OPENSSL)
-      include_directories(${OPENSSL_INCLUDE_DIR})
-      link_directories(${OPENSSL_LIBRARY_DIR})
-    else()
-      message(FATAL_ERROR "OPENSSL requested but package not found")
-    endif()
-  endif(USE_OPENSSL)
-
-  IF (USE_ICU)
-    find_package(ICU)
-    IF (ICU_FOUND)
-      add_definitions (-D_USE_ICU)
-      include_directories(${ICU_INCLUDE_DIR})
-    ELSE()
-      message(FATAL_ERROR "ICU requested but package not found")
-    ENDIF()
-  ENDIF(USE_ICU)
-
-  if ( MAKE_DOCS AND CLIENTTOOLS_ONLY )
-      set( MAKE_DOCS OFF )
-  endif()
-
-  if ( MAKE_DOCS_ONLY AND NOT CLIENTTOOLS_ONLY )
-      set( MAKE_DOCS ON )
-  endif()
-
-  if ( CLIENTTOOLS_ONLY )
-      set(PLATFORM OFF)
-      set(DEVEL OFF)
-  endif()
-
-  option(PORTALURL "Set url to hpccsystems portal download page")
-
-  if ( NOT PORTALURL )
-    set( PORTALURL "http://hpccsystems.com/download" )
-  endif()
-
-  set(CMAKE_MODULE_PATH "${HPCC_NM_SOURCE_DIR}/cmake_modules/")
+    set(CMAKE_MODULE_PATH "${HPCC_NM_SOURCE_DIR}/cmake_modules/")

   ##########################################################

@@ -535,3 +440,5 @@
     set(${cpackvar} "${_tmp}" CACHE STRING "" FORCE)
     message(STATUS "Updated ${cpackvar} to ${${cpackvar}}")
   endfunction()
+
+endif()


android.toolchain.cmake: Update to revision 80f6ede2 in OpenCV repository.

--- android/android.toolchain.cmake
+++ android/android.toolchain.cmake
@@ -1,5 +1,5 @@
 # Copyright (c) 2010-2011, Ethan Rublee
-# Copyright (c) 2011-2012, Andrey Kamaev
+# Copyright (c) 2011-2013, Andrey Kamaev
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -281,8 +281,17 @@
 #     [+] updated for NDK r8c
 #     [+] added support for clang compiler
 #   - December 2012
+#     [+] suppress warning about unused CMAKE_TOOLCHAIN_FILE variable
+#     [+] adjust API level to closest compatible as NDK does
 #     [~] fixed ccache full path search
 #     [+] updated for NDK r8d
+#     [~] compiler options are aligned with NDK r8d
+#   - March 2013
+#     [+] updated for NDK r8e (x86 version)
+#     [+] support x86_64 version of NDK
+#   - April 2013
+#     [+] support non-release NDK layouts (from Linaro git and Android git)
+#     [~] automatically detect if explicit link to crtbegin_*.o is needed
 # ------------------------------------------------------------------------------

 cmake_minimum_required( VERSION 2.6.3 )
@@ -290,6 +299,10 @@
 if( DEFINED CMAKE_CROSSCOMPILING )
  # subsequent toolchain loading is not really needed
  return()
+endif()
+
+if( CMAKE_TOOLCHAIN_FILE )
+ # touch toolchain variable only to suppress "unused variable" warning
 endif()

 get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
@@ -305,7 +318,7 @@
 # rpath makes low sence for Android
 set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )

-set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
+set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
 if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS)
  if( CMAKE_HOST_WIN32 )
   file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS )
@@ -449,17 +462,30 @@
  endif()
 endif()

+
 # detect current host platform
+if( NOT DEFINED ANDROID_NDK_HOST_X64 AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
+ set( ANDROID_NDK_HOST_X64 1 CACHE BOOL "Try to use 64-bit compiler toolchain" )
+ mark_as_advanced( ANDROID_NDK_HOST_X64 )
+endif()
+
 set( TOOL_OS_SUFFIX "" )
 if( CMAKE_HOST_APPLE )
- set( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86" )
+ set( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86_64" )
+ set( ANDROID_NDK_HOST_SYSTEM_NAME2 "darwin-x86" )
 elseif( CMAKE_HOST_WIN32 )
- set( ANDROID_NDK_HOST_SYSTEM_NAME "windows" )
+ set( ANDROID_NDK_HOST_SYSTEM_NAME "windows-x86_64" )
+ set( ANDROID_NDK_HOST_SYSTEM_NAME2 "windows" )
  set( TOOL_OS_SUFFIX ".exe" )
 elseif( CMAKE_HOST_UNIX )
- set( ANDROID_NDK_HOST_SYSTEM_NAME "linux-x86" )
+ set( ANDROID_NDK_HOST_SYSTEM_NAME "linux-x86_64" )
+ set( ANDROID_NDK_HOST_SYSTEM_NAME2 "linux-x86" )
 else()
  message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" )
+endif()
+
+if( NOT ANDROID_NDK_HOST_X64 )
+ set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} )
 endif()

 # see if we have path to Android NDK
@@ -493,23 +519,19 @@
   endif( ANDROID_NDK )
  endif( NOT ANDROID_STANDALONE_TOOLCHAIN )
 endif( NOT ANDROID_NDK )
+
 # remember found paths
 if( ANDROID_NDK )
  get_filename_component( ANDROID_NDK "${ANDROID_NDK}" ABSOLUTE )
- # try to detect change
- if( CMAKE_AR )
-  string( LENGTH "${ANDROID_NDK}" __length )
-  string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidNdkPreviousPath )
-  if( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK )
-   message( FATAL_ERROR "It is not possible to change the path to the NDK on subsequent CMake run. You must remove all generated files from your build folder first.
-   " )
-  endif()
-  unset( __androidNdkPreviousPath )
-  unset( __length )
- endif()
  set( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" FORCE )
  set( BUILD_WITH_ANDROID_NDK True )
- file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE LIMIT_COUNT 1 REGEX r[0-9]+[a-z]? )
+ if( EXISTS "${ANDROID_NDK}/RELEASE.TXT" )
+  file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE_FULL LIMIT_COUNT 1 REGEX r[0-9]+[a-z]? )
+  string( REGEX MATCH r[0-9]+[a-z]? ANDROID_NDK_RELEASE "${ANDROID_NDK_RELEASE_FULL}" )
+ else()
+  set( ANDROID_NDK_RELEASE "r1x" )
+  set( ANDROID_NDK_RELEASE_FULL "unreleased" )
+ endif()
 elseif( ANDROID_STANDALONE_TOOLCHAIN )
  get_filename_component( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE )
  # try to detect change
@@ -536,6 +558,51 @@
       sudo ln -s ~/my-android-toolchain ${ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH}" )
 endif()

+# android NDK layout
+if( BUILD_WITH_ANDROID_NDK )
+ if( NOT DEFINED ANDROID_NDK_LAYOUT )
+  # try to automatically detect the layout
+  if( EXISTS "${ANDROID_NDK}/RELEASE.TXT")
+   set( ANDROID_NDK_LAYOUT "RELEASE" )
+  elseif( EXISTS "${ANDROID_NDK}/../../linux-x86/toolchain/" )
+   set( ANDROID_NDK_LAYOUT "LINARO" )
+  elseif( EXISTS "${ANDROID_NDK}/../../gcc/" )
+   set( ANDROID_NDK_LAYOUT "ANDROID" )
+  endif()
+ endif()
+ set( ANDROID_NDK_LAYOUT "${ANDROID_NDK_LAYOUT}" CACHE STRING "The inner layout of NDK" )
+ mark_as_advanced( ANDROID_NDK_LAYOUT )
+ if( ANDROID_NDK_LAYOUT STREQUAL "LINARO" )
+  set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) # only 32-bit at the moment
+  set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/../../${ANDROID_NDK_HOST_SYSTEM_NAME}/toolchain" )
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH  "" )
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "" )
+ elseif( ANDROID_NDK_LAYOUT STREQUAL "ANDROID" )
+  set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) # only 32-bit at the moment
+  set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/../../gcc/${ANDROID_NDK_HOST_SYSTEM_NAME}/arm" )
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH  "" )
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "" )
+ else() # ANDROID_NDK_LAYOUT STREQUAL "RELEASE"
+  set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/toolchains" )
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH  "/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME2}" )
+ endif()
+ get_filename_component( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK_TOOLCHAINS_PATH}" ABSOLUTE )
+
+ # try to detect change of NDK
+ if( CMAKE_AR )
+  string( LENGTH "${ANDROID_NDK_TOOLCHAINS_PATH}" __length )
+  string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidNdkPreviousPath )
+  if( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK_TOOLCHAINS_PATH )
+   message( FATAL_ERROR "It is not possible to change the path to the NDK on subsequent CMake run. You must remove all generated files from your build folder first.
+   " )
+  endif()
+  unset( __androidNdkPreviousPath )
+  unset( __length )
+ endif()
+endif()
+
+
 # get all the details about standalone toolchain
 if( BUILD_WITH_STANDALONE_TOOLCHAIN )
  __DETECT_NATIVE_API_LEVEL( ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h" )
@@ -563,22 +630,27 @@
  endif()
 endif()

-macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar )
- foreach( __toolchain ${${__availableToolchainsVar}} )
-  if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/" )
+macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __toolchain_subpath )
+ foreach( __toolchain ${${__availableToolchainsLst}} )
+  if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" )
    string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" )
   else()
    set( __gcc_toolchain "${__toolchain}" )
   endif()
-  __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__gcc_toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
+  __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" )
   if( __machine )
-   string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?$" __version "${__gcc_toolchain}" )
-   string( REGEX MATCH "^[^-]+" __arch "${__gcc_toolchain}" )
+   string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" )
+   if( __machine MATCHES i686 )
+    set( __arch "x86" )
+   elseif( __machine MATCHES arm )
+    set( __arch "arm" )
+   elseif( __machine MATCHES mipsel )
+    set( __arch "mipsel" )
+   endif()
    list( APPEND __availableToolchainMachines "${__machine}" )
    list( APPEND __availableToolchainArchs "${__arch}" )
    list( APPEND __availableToolchainCompilerVersions "${__version}" )
-  else()
-   list( REMOVE_ITEM ${__availableToolchainsVar} "${__toolchain}" )
+   list( APPEND ${__availableToolchainsVar} "${__toolchain}" )
   endif()
   unset( __gcc_toolchain )
  endforeach()
@@ -592,19 +664,31 @@
  set( __availableToolchainMachines "" )
  set( __availableToolchainArchs "" )
  set( __availableToolchainCompilerVersions "" )
- if( ANDROID_TOOLCHAIN_NAME AND EXISTS "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/" )
+ if( ANDROID_TOOLCHAIN_NAME AND EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_TOOLCHAIN_NAME}/" )
   # do not go through all toolchains if we know the name
-  set( __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" )
-  __GLOB_NDK_TOOLCHAINS( __availableToolchains )
+  set( __availableToolchainsLst "${ANDROID_TOOLCHAIN_NAME}" )
+  __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
+  if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 )
+   __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" )
+   if( __availableToolchains )
+    set( ANDROID_NDK_TOOLCHAINS_SUBPATH ${ANDROID_NDK_TOOLCHAINS_SUBPATH2} )
+   endif()
+  endif()
  endif()
  if( NOT __availableToolchains )
-  file( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" )
+  file( GLOB __availableToolchainsLst RELATIVE "${ANDROID_NDK_TOOLCHAINS_PATH}" "${ANDROID_NDK_TOOLCHAINS_PATH}/*" )
   if( __availableToolchains )
-   list(SORT __availableToolchains) # we need clang to go after gcc
-  endif()
-  __LIST_FILTER( __availableToolchains "^[.]" )
-  __LIST_FILTER( __availableToolchains "llvm" )
-  __GLOB_NDK_TOOLCHAINS( __availableToolchains )
+   list(SORT __availableToolchainsLst) # we need clang to go after gcc
+  endif()
+  __LIST_FILTER( __availableToolchainsLst "^[.]" )
+  __LIST_FILTER( __availableToolchainsLst "llvm" )
+  __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
+  if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 )
+   __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" )
+   if( __availableToolchains )
+    set( ANDROID_NDK_TOOLCHAINS_SUBPATH ${ANDROID_NDK_TOOLCHAINS_SUBPATH2} )
+   endif()
+  endif()
  endif()
  if( NOT __availableToolchains )
   message( FATAL_ERROR "Could not find any working toolchain in the NDK. Probably your Android NDK is broken." )
@@ -617,11 +701,11 @@
 list( REMOVE_DUPLICATES __uniqToolchainArchNames )
 list( SORT __uniqToolchainArchNames )
 foreach( __arch ${__uniqToolchainArchNames} )
-list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} )
+ list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} )
 endforeach()
 unset( __uniqToolchainArchNames )
 if( NOT ANDROID_SUPPORTED_ABIS )
-message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." )
+ message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." )
 endif()

 # choose target ABI
@@ -733,6 +817,7 @@
   list( GET __availableToolchainArchs ${__idx} __toolchainArch )
   if( __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
    list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion )
+   string( REPLACE "x" "99" __toolchainVersion "${__toolchainVersion}")
    if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion )
     set( __toolchainMaxVersion "${__toolchainVersion}" )
     set( __toolchainIdx ${__idx} )
@@ -760,11 +845,22 @@
 # choose native API level
 __INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL )
 string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
-# TODO: filter out unsupported levels
+# adjust API level
+set( __real_api_level ${ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME}} )
+foreach( __level ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
+ if( NOT __level GREATER ANDROID_NATIVE_API_LEVEL AND NOT __level LESS __real_api_level )
+  set( __real_api_level ${__level} )
+ endif()
+endforeach()
+if( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL EQUAL __real_api_level )
+ message( STATUS "Adjusting Android API level 'android-${ANDROID_NATIVE_API_LEVEL}' to 'android-${__real_api_level}'")
+ set( ANDROID_NATIVE_API_LEVEL ${__real_api_level} )
+endif()
+unset(__real_api_level)
 # validate
 list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx )
 if( __levelIdx EQUAL -1 )
- message( SEND_ERROR "Specified Android native API level (${ANDROID_NATIVE_API_LEVEL}) is not supported by your NDK/toolchain." )
+ message( SEND_ERROR "Specified Android native API level 'android-${ANDROID_NATIVE_API_LEVEL}' is not supported by your NDK/toolchain." )
 else()
  if( BUILD_WITH_ANDROID_NDK )
   __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
@@ -925,11 +1021,11 @@
 elseif( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" )
  string( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}")
  string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-4.6" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
- if( NOT EXISTS "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}/bin/clang${TOOL_OS_SUFFIX}" )
-  message( FATAL_ERROR "Could not find the " )
+ if( NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}/bin/clang${TOOL_OS_SUFFIX}" )
+  message( FATAL_ERROR "Could not find the Clang compiler driver" )
  endif()
  set( ANDROID_COMPILER_IS_CLANG 1 )
- set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
+ set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
 else()
  set( ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
  unset( ANDROID_COMPILER_IS_CLANG CACHE )
@@ -943,7 +1039,7 @@

 # setup paths and STL for NDK
 if( BUILD_WITH_ANDROID_NDK )
- set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
+ set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
  set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" )

  if( ANDROID_STL STREQUAL "none" )
@@ -1002,11 +1098,11 @@
  endif()
  # find libsupc++.a - rtti & exceptions
  if( ANDROID_STL STREQUAL "system_re" OR ANDROID_STL MATCHES "gnustl" )
-  if( ANDROID_NDK_RELEASE STRGREATER "r8" ) # r8b
-   set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
-  elseif( NOT ANDROID_NDK_RELEASE STRLESS "r7" AND ANDROID_NDK_RELEASE STRLESS "r8b")
-   set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
-  else( ANDROID_NDK_RELEASE STRLESS "r7" )
+  set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r8b or newer
+  if( NOT EXISTS "${__libsupcxx}" )
+   set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r7-r8
+  endif()
+  if( NOT EXISTS "${__libsupcxx}" ) # before r7
    if( ARMEABI_V7A )
     if( ANDROID_FORCE_ARM_BUILD )
      set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" )
@@ -1056,7 +1152,7 @@

 # setup the cross-compiler
 if( NOT CMAKE_C_COMPILER )
- if( NDK_CCACHE )
+ if( NDK_CCACHE AND NOT ANDROID_SYSROOT MATCHES "[ ;\"]" )
   set( CMAKE_C_COMPILER   "${NDK_CCACHE}" CACHE PATH "ccache as C compiler" )
   set( CMAKE_CXX_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C++ compiler" )
   if( ANDROID_COMPILER_IS_CLANG )
@@ -1128,11 +1224,25 @@
 remove_definitions( -DANDROID )
 add_definitions( -DANDROID )

-if(ANDROID_SYSROOT MATCHES "[ ;\"]")
- set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" )
+if( ANDROID_SYSROOT MATCHES "[ ;\"]" )
+ if( CMAKE_HOST_WIN32 )
+  # try to convert path to 8.3 form
+  file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cvt83.cmd" "@echo %~s1" )
+  execute_process( COMMAND "$ENV{ComSpec}" /c "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cvt83.cmd" "${ANDROID_SYSROOT}"
+                   OUTPUT_VARIABLE __path OUTPUT_STRIP_TRAILING_WHITESPACE
+                   RESULT_VARIABLE __result ERROR_QUIET )
+  if( __result EQUAL 0 )
+   file( TO_CMAKE_PATH "${__path}" ANDROID_SYSROOT )
+   set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" )
+  else()
+   set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" )
+  endif()
+ else()
+  set( ANDROID_CXX_FLAGS "'--sysroot=${ANDROID_SYSROOT}'" )
+ endif()
  if( NOT _CMAKE_IN_TRY_COMPILE )
-  # quotes will break try_compile and compiler identification
-  message(WARNING "Your Android system root has non-alphanumeric symbols. It can break compiler features detection and the whole build.")
+  # quotes can break try_compile and compiler identification
+  message(WARNING "Path to your Android NDK (or toolchain) has non-alphanumeric symbols.\nThe build might be broken.\n")
  endif()
 else()
  set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" )
@@ -1140,38 +1250,52 @@

 # NDK flags
 if( ARMEABI OR ARMEABI_V7A )
- set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__" )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -funwind-tables" )
  if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 )
-  # It is recommended to use the -mthumb compiler flag to force the generation
-  # of 16-bit Thumb-1 instructions (the default being 32-bit ARM ones).
-  set( ANDROID_CXX_FLAGS_RELEASE "-mthumb" )
-  set( ANDROID_CXX_FLAGS_DEBUG   "-marm -finline-limit=64" )
+  set( ANDROID_CXX_FLAGS_RELEASE "-mthumb -fomit-frame-pointer -fno-strict-aliasing" )
+  set( ANDROID_CXX_FLAGS_DEBUG   "-marm -fno-omit-frame-pointer -fno-strict-aliasing" )
+  if( NOT ANDROID_COMPILER_IS_CLANG )
+   set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -finline-limit=64" )
+  endif()
  else()
   # always compile ARMEABI_V6 in arm mode; otherwise there is no difference from ARMEABI
-  # O3 instead of O2/Os in release mode - like cmake sets for desktop gcc
-  set( ANDROID_CXX_FLAGS_RELEASE "-marm" )
-  set( ANDROID_CXX_FLAGS_DEBUG   "-marm -finline-limit=300" )
+  set( ANDROID_CXX_FLAGS_RELEASE "-marm -fomit-frame-pointer -fstrict-aliasing" )
+  set( ANDROID_CXX_FLAGS_DEBUG   "-marm -fno-omit-frame-pointer -fno-strict-aliasing" )
+  if( NOT ANDROID_COMPILER_IS_CLANG )
+   set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" )
+  endif()
  endif()
 elseif( X86 )
- set( ANDROID_CXX_FLAGS         "${ANDROID_CXX_FLAGS} -funwind-tables" )
- set( ANDROID_CXX_FLAGS_RELEASE "" )
- set( ANDROID_CXX_FLAGS_DEBUG   "-finline-limit=300" )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" )
+ if( NOT ANDROID_COMPILER_IS_CLANG )
+  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" )
+ else()
+  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fPIC" )
+ endif()
+ set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" )
+ set( ANDROID_CXX_FLAGS_DEBUG   "-fno-omit-frame-pointer -fno-strict-aliasing" )
 elseif( MIPS )
- set( ANDROID_CXX_FLAGS         "${ANDROID_CXX_FLAGS} -fpic -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -frename-registers" )
- set( ANDROID_CXX_FLAGS_RELEASE "-finline-limit=300 -fno-strict-aliasing" )
- set( ANDROID_CXX_FLAGS_DEBUG   "-finline-functions -fgcse-after-reload -frerun-cse-after-loop" )
+ set( ANDROID_CXX_FLAGS         "${ANDROID_CXX_FLAGS} -fpic -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0" )
+ set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer" )
+ set( ANDROID_CXX_FLAGS_DEBUG   "-fno-omit-frame-pointer" )
+ if( NOT ANDROID_COMPILER_IS_CLANG )
+  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" )
+  set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -funswitch-loops -finline-limit=300" )
+ endif()
 elseif()
  set( ANDROID_CXX_FLAGS_RELEASE "" )
  set( ANDROID_CXX_FLAGS_DEBUG   "" )
 endif()

-if( NOT X86 )
- set( ANDROID_CXX_FLAGS         "-Wno-psabi ${ANDROID_CXX_FLAGS}" )
-endif()
-
 set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" ) # good/necessary when porting desktop libraries
-set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -fomit-frame-pointer" )
-set( ANDROID_CXX_FLAGS_DEBUG   "${ANDROID_CXX_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer" )
+
+if( NOT X86 AND NOT ANDROID_COMPILER_IS_CLANG )
+ set( ANDROID_CXX_FLAGS "-Wno-psabi ${ANDROID_CXX_FLAGS}" )
+endif()
+
+if( NOT ANDROID_COMPILER_VERSION VERSION_LESS "4.6" )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -no-canonical-prefixes" ) # see https://android-review.googlesource.com/#/c/47564/
+endif()

 # ABI-specific flags
 if( ARMEABI_V7A )
@@ -1189,22 +1313,18 @@
  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" )
 endif()

+if( ANDROID_STL MATCHES "gnustl" AND (EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}") )
+ set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
+ set( CMAKE_CXX_CREATE_SHARED_MODULE  "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
+ set( CMAKE_CXX_LINK_EXECUTABLE       "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
+else()
+ set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
+ set( CMAKE_CXX_CREATE_SHARED_MODULE  "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
+ set( CMAKE_CXX_LINK_EXECUTABLE       "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
+endif()
+
 # STL
 if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" )
- if( ANDROID_STL MATCHES "gnustl" )
-  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
-  set( CMAKE_CXX_CREATE_SHARED_MODULE  "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
-  set( CMAKE_CXX_LINK_EXECUTABLE       "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
- else()
-  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
-  set( CMAKE_CXX_CREATE_SHARED_MODULE  "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
-  set( CMAKE_CXX_LINK_EXECUTABLE       "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
- endif()
- if ( X86 AND ANDROID_STL MATCHES "gnustl" AND ANDROID_NDK_RELEASE STREQUAL "r6" )
-  # workaround "undefined reference to `__dso_handle'" problem
-  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" )
-  set( CMAKE_CXX_CREATE_SHARED_MODULE  "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" )
- endif()
  if( EXISTS "${__libstl}" )
   set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libstl}\"" )
   set( CMAKE_CXX_CREATE_SHARED_MODULE  "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libstl}\"" )
@@ -1223,9 +1343,12 @@
   set( CMAKE_C_LINK_EXECUTABLE       "${CMAKE_C_LINK_EXECUTABLE} \"${__libsupcxx}\"" )
  endif()
  if( ANDROID_STL MATCHES "gnustl" )
-  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} -lm" )
-  set( CMAKE_CXX_CREATE_SHARED_MODULE  "${CMAKE_CXX_CREATE_SHARED_MODULE} -lm" )
-  set( CMAKE_CXX_LINK_EXECUTABLE       "${CMAKE_CXX_LINK_EXECUTABLE} -lm" )
+  if( NOT EXISTS "${ANDROID_LIBM_PATH}" )
+   set( ANDROID_LIBM_PATH -lm )
+  endif()
+  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} ${ANDROID_LIBM_PATH}" )
+  set( CMAKE_CXX_CREATE_SHARED_MODULE  "${CMAKE_CXX_CREATE_SHARED_MODULE} ${ANDROID_LIBM_PATH}" )
+  set( CMAKE_CXX_LINK_EXECUTABLE       "${CMAKE_CXX_LINK_EXECUTABLE} ${ANDROID_LIBM_PATH}" )
  endif()
 endif()

@@ -1261,7 +1384,14 @@
 endif()

 if( ANDROID_NO_UNDEFINED )
- set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined" )
+ if( MIPS )
+  # there is some sysroot-related problem in mips linker...
+  if( NOT ANDROID_SYSROOT MATCHES "[ ;\"]" )
+   set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined -Wl,-rpath-link,${ANDROID_SYSROOT}/usr/lib" )
+  endif()
+ else()
+  set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined" )
+ endif()
 endif()

 if( ANDROID_SO_UNDEFINED )
@@ -1308,9 +1438,6 @@
   set( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS}" )
  endif()
  if( BUILD_WITH_ANDROID_NDK )
-  if(ANDROID_ARCH_NAME STREQUAL "arm" )
-   set( ANDROID_CXX_FLAGS "-isystem ${ANDROID_CLANG_TOOLCHAIN_ROOT}/lib/clang/${ANDROID_CLANG_VERSION}/include ${ANDROID_CXX_FLAGS}" )
-  endif()
   set( ANDROID_CXX_FLAGS "-gcc-toolchain ${ANDROID_TOOLCHAIN_ROOT} ${ANDROID_CXX_FLAGS}" )
  endif()
 endif()
@@ -1326,6 +1453,12 @@
 set( CMAKE_MODULE_LINKER_FLAGS ""                        CACHE STRING "module linker flags" )
 set( CMAKE_EXE_LINKER_FLAGS    "-Wl,-z,nocopyreloc"      CACHE STRING "executable linker flags" )

+# put flags to cache (for debug purpose only)
+set( ANDROID_CXX_FLAGS         "${ANDROID_CXX_FLAGS}"         CACHE INTERNAL "Android specific c/c++ flags" )
+set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE}" CACHE INTERNAL "Android specific c/c++ Release flags" )
+set( ANDROID_CXX_FLAGS_DEBUG   "${ANDROID_CXX_FLAGS_DEBUG}"   CACHE INTERNAL "Android specific c/c++ Debug flags" )
+set( ANDROID_LINKER_FLAGS      "${ANDROID_LINKER_FLAGS}"      CACHE INTERNAL "Android specific c/c++ linker flags" )
+
 # finish flags
 set( CMAKE_CXX_FLAGS           "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
 set( CMAKE_C_FLAGS             "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
@@ -1338,9 +1471,9 @@
 set( CMAKE_EXE_LINKER_FLAGS    "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )

 if( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" )
- set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" )
- set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" )
- set( CMAKE_EXE_LINKER_FLAGS    "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" )
+ set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" )
+ set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" )
+ set( CMAKE_EXE_LINKER_FLAGS    "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" )
 endif()

 # configure rtti
@@ -1366,6 +1499,43 @@
 # global includes and link directories
 include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_STL_INCLUDE_DIRS} )
 link_directories( "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )
+
+# detect if need link crtbegin_so.o explicitly
+if( NOT DEFINED ANDROID_EXPLICIT_CRT_LINK )
+ set( __cmd "${CMAKE_CXX_CREATE_SHARED_LIBRARY}" )
+ string( REPLACE "<CMAKE_CXX_COMPILER>" "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" __cmd "${__cmd}" )
+ string( REPLACE "<CMAKE_C_COMPILER>"   "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}"   __cmd "${__cmd}" )
+ string( REPLACE "<CMAKE_SHARED_LIBRARY_CXX_FLAGS>" "${CMAKE_CXX_FLAGS}" __cmd "${__cmd}" )
+ string( REPLACE "<LANGUAGE_COMPILE_FLAGS>" "" __cmd "${__cmd}" )
+ string( REPLACE "<LINK_FLAGS>" "${CMAKE_SHARED_LINKER_FLAGS}" __cmd "${__cmd}" )
+ string( REPLACE "<CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>" "-shared" __cmd "${__cmd}" )
+ string( REPLACE "<CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG>" "" __cmd "${__cmd}" )
+ string( REPLACE "<TARGET_SONAME>" "" __cmd "${__cmd}" )
+ string( REPLACE "<TARGET>" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toolchain_crtlink_test.so" __cmd "${__cmd}" )
+ string( REPLACE "<OBJECTS>" "\"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" __cmd "${__cmd}" )
+ string( REPLACE "<LINK_LIBRARIES>" "" __cmd "${__cmd}" )
+ separate_arguments( __cmd )
+ foreach( __var ANDROID_NDK ANDROID_NDK_TOOLCHAINS_PATH ANDROID_STANDALONE_TOOLCHAIN )
+  if( ${__var} )
+   set( __tmp "${${__var}}" )
+   separate_arguments( __tmp )
+   string( REPLACE "${__tmp}" "${${__var}}" __cmd "${__cmd}")
+  endif()
+ endforeach()
+ string( REPLACE "'" "" __cmd "${__cmd}" )
+ string( REPLACE "\"" "" __cmd "${__cmd}" )
+ execute_process( COMMAND ${__cmd} RESULT_VARIABLE __cmd_result OUTPUT_QUIET ERROR_QUIET )
+ if( __cmd_result EQUAL 0 )
+  set( ANDROID_EXPLICIT_CRT_LINK ON )
+ else()
+  set( ANDROID_EXPLICIT_CRT_LINK OFF )
+ endif()
+endif()
+
+if( ANDROID_EXPLICIT_CRT_LINK )
+ set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" )
+ set( CMAKE_CXX_CREATE_SHARED_MODULE  "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" )
+endif()

 # setup output directories
 set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" )
@@ -1456,7 +1626,9 @@
 if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
  set( __toolchain_config "")
  foreach( __var NDK_CCACHE  LIBRARY_OUTPUT_PATH_ROOT  ANDROID_FORBID_SYGWIN  ANDROID_SET_OBSOLETE_VARIABLES
+                ANDROID_NDK_HOST_X64
                 ANDROID_NDK
+                ANDROID_NDK_LAYOUT
                 ANDROID_STANDALONE_TOOLCHAIN
                 ANDROID_TOOLCHAIN_NAME
                 ANDROID_ABI
@@ -1470,6 +1642,8 @@
                 ANDROID_GOLD_LINKER
                 ANDROID_NOEXECSTACK
                 ANDROID_RELRO
+                ANDROID_LIBM_PATH
+                ANDROID_EXPLICIT_CRT_LINK
                 )
   if( DEFINED ${__var} )
    if( "${__var}" MATCHES " ")
@@ -1512,6 +1686,8 @@
 #   ANDROID_NDK
 #   ANDROID_STANDALONE_TOOLCHAIN
 #   ANDROID_TOOLCHAIN_NAME : the NDK name of compiler toolchain
+#   ANDROID_NDK_HOST_X64 : try to use x86_64 toolchain (default for x64 host systems)
+#   ANDROID_NDK_LAYOUT : the inner NDK structure (RELEASE, LINARO, ANDROID)
 #   LIBRARY_OUTPUT_PATH_ROOT : <any valid path>
 #   NDK_CCACHE : <path to your ccache executable>
 # Obsolete:
@@ -1536,7 +1712,7 @@
 #   BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used
 #   ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform
 #   ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "x86" or "mips" depending on ANDROID_ABI
-#   ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d; set only for NDK
+#   ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d, r8e; set only for NDK
 #   ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI
 #   ANDROID_SYSROOT : path to the compiler sysroot
 #   TOOL_OS_SUFFIX : "" or ".exe" depending on host platform
@@ -1557,6 +1733,7 @@
 #   ANDROID_EXCEPTIONS : if exceptions are enabled by the runtime
 #   ANDROID_GCC_TOOLCHAIN_NAME : read-only, differs from ANDROID_TOOLCHAIN_NAME only if clang is used
 #   ANDROID_CLANG_VERSION : version of clang compiler if clang is used
+#   ANDROID_LIBM_PATH : path to libm.so (set to something like $(TOP)/out/target/product/<product_name>/obj/lib/libm.so) to workaround unresolved `sincos`
 #
 # Defaults:
 #   ANDROID_DEFAULT_NDK_API_LEVEL


remove gtest

remove gtest

--- facts/facts.cmake
+++ facts/facts.cmake
@@ -515,7 +515,6 @@
 endfunction()

 macro(cmaki2_gtest)
-	cmaki_find_package(google-gtest)
 	cmaki_find_package(google-gmock)
 	cmaki2_test(${ARGV})
 endmacro()


Update facts.cmake

Update facts.cmake

--- facts/facts.cmake
+++ facts/facts.cmake
@@ -156,10 +156,10 @@
 			endif()

 			#######################################################
-			# 6: obtengo la version del paquete recien creado
-			message("python ${ARTIFACTS_PATH}/check_remote_version.py --server=${CMAKI_REPOSITORY} --artifacts=${CMAKE_PREFIX_PATH} --platform=${CMAKI_PLATFORM} --name=${PACKAGE}")
-			execute_process(
-				COMMAND python ${ARTIFACTS_PATH}/check_remote_version.py --server=${CMAKI_REPOSITORY} --artifacts=${CMAKE_PREFIX_PATH} --platform=${CMAKI_PLATFORM} --name=${PACKAGE}
+			# 6: obtengo la version del paquete creado
+			message("python ${ARTIFACTS_PATH}/check_remote_version.py --server=${CMAKI_REPOSITORY} --artifacts=${CMAKE_PREFIX_PATH} --platform=${CMAKI_PLATFORM} --name=${PACKAGE} ${EXTRA_VERSION}")
+			execute_process(
+				COMMAND python ${ARTIFACTS_PATH}/check_remote_version.py --server=${CMAKI_REPOSITORY} --artifacts=${CMAKE_PREFIX_PATH} --platform=${CMAKI_PLATFORM} --name=${PACKAGE} ${EXTRA_VERSION}
 				WORKING_DIRECTORY "${ARTIFACTS_PATH}"
 				OUTPUT_VARIABLE RESULT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
 			if(RESULT_VERSION)


physx support for vs 2017

physx support for vs 2017

--- Tools/CMake/modules/module_physx3.cmake
+++ Tools/CMake/modules/module_physx3.cmake
@@ -52,6 +52,9 @@
       set(PHYSX3_LIBPATH_PREFIX vc12win32)
    elseif(MSVC14)
       set(PHYSX3_LIBPATH_PREFIX vc14win32)
+   #VS 2017 uses 14.x toolchain so can't use MSVC15
+   elseif(MSVC_VERSION GREATER_OR_EQUAL_TO 1910)
+      set(PHYSX3_LIBPATH_PREFIX vc15win32)
    else()
       message(FATAL_ERROR "This version of VS is not supported")
       return()
@@ -65,6 +68,9 @@
       set(PHYSX3_LIBPATH_PREFIX vc12win64)
    elseif(MSVC14)
       set(PHYSX3_LIBPATH_PREFIX vc14win64)
+   #VS 2017 uses 14.x toolchain so can't use MSVC15
+   elseif(MSVC_VERSION GREATER_OR_EQUAL_TO 1910)
+      set(PHYSX3_LIBPATH_PREFIX vc15win64)
    else()
       message(FATAL_ERROR "This version of VS is not supported")
       return()


BUG: wrong indexes in SuperBuild macro

BUG: wrong indexes in SuperBuild macro

--- SuperBuild/CMake/SuperBuild_Macro.cmake
+++ SuperBuild/CMake/SuperBuild_Macro.cmake
@@ -148,16 +148,16 @@

 macro(SUPERBUILD_UPDATE_CMAKE_VARIABLES PROJECT with_prefix)

+  if("${ARGV2}" STREQUAL "")
+    string(TOLOWER ${PROJECT} lib_file_we)
+  else()
+    set(lib_file_we "${ARGV2}")
+  endif()
+
   if("${ARGV3}" STREQUAL "")
-    string(TOLOWER ${PROJECT} lib_file_we)
-  else()
-    set(lib_file_we "${ARGV3}")
-  endif()
-
-  if("${ARGV4}" STREQUAL "")
     set(include_dir "include")
   else()
-    set(include_dir "include/${ARGV4}")
+    set(include_dir "include/${ARGV3}")
   endif()

   if(WIN32)


NEW: cuda-hm test

NEW: cuda-hm test

--- tests/system_tests/run_system_tests.sh.cmake
+++ tests/system_tests/run_system_tests.sh.cmake
@@ -372,6 +372,15 @@

     done
     echo $new_configs
+}
+
+function generate_translation_configurations_cuda_hm()
+{
+    if [ $# -gt 0 ]; then
+		echo $1
+    else
+		generate_empty_translation_configuration
+    fi
 }

 function generate_translation_configurations_mpi()
@@ -516,6 +525,9 @@
 		cuda)
 			generate_translation_configurations_cuda
 			;;
+		cuda-hm)
+			generate_translation_configurations_cuda_hm
+			;;
 		mpi|mpi2)
 			generate_translation_configurations_mpi
 			;;
@@ -619,7 +631,7 @@
 				return 1
 			fi
 			;;
-		cuda)
+		cuda|cuda-hm)
 			if [ "@CUDA_FOUND@" != "TRUE" ]; then
 				echo "[COMPILE] Skipping CUDA compilation (not supported)"
 				return 0
@@ -725,7 +737,7 @@
 		mpi|mpi2)
 			target=ref
 			;;
-		mpi-cuda)
+		cuda-hm|mpi-cuda)
 			target=cuda
 			;;
 		opencl)
@@ -800,7 +812,7 @@
 		ref)
 			./$exename $TRACE > $exename.out 2> $exename.err
 			;;
-		cuda)
+		cuda|cuda-hm)
 			./$exename $TRACE > $exename.out 2> $exename.err
 			;;
 		mpi|mpi2)
@@ -977,7 +989,7 @@
 {
 	if is_module_test $1; then
 		case "$2" in
-			mpi|mpi2|mpi-cuda|opencl|mpi-opencl|mpi-openmp|mpi-openmp-numa)
+			cuda-hm|mpi|mpi2|mpi-cuda|opencl|mpi-opencl|mpi-openmp|mpi-openmp-numa)
 				return 0
 		esac
 	fi


Moving things around to make it nice

Moving things around to make it nice

Also rewrite some comments

--- build_settings.cmake
+++ build_settings.cmake
@@ -1,8 +1,8 @@
 # Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
 # @author Vegard Sjonfjell
-if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
-    set(OS_IS_MACOSX true)
-endif()
+
+include(vtag.cmake)
+
 # Build options
 # Whether to build unit tests as part of the 'all' target
 set(EXCLUDE_TESTS_FROM_ALL FALSE CACHE BOOL "If TRUE, do not build tests as part of the 'all' target")
@@ -13,7 +13,6 @@
 # C and C++ compiler flags
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O3 ${WARN_OPTS} -fPIC -D_GLIBCXX_USE_CXX11_ABI=0 -DBOOST_DISABLE_ASSERTS -DWITH_SHIPPED_GEOIP -march=westmere -mtune=intel")

-include(vtag.cmake)
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VTAG_DEFINES}")

 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -Wnon-virtual-dtor -fvisibility-inlines-hidden -fdiagnostics-color=auto")
@@ -27,6 +26,8 @@
 # Always build shared libs if not explicitly specified
 set(BUILD_SHARED_LIBS ON)

+set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
+
 # Default RPATH settings for CMake 3.4:
 # For non-installed targets, reference external libraries using an RPATH into the build tree.
 # For installed targets, reference external libraries using INSTALL_RPATH (i.e. /home/y/lib64 on ylinux)
@@ -34,8 +35,8 @@
 set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)

-# OSX Stuff
-if(OS_IS_MACOSX)
+# OS X Stuff
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
     set(MACOSX_RPATH ON)

     if(__COMPILER_GNU)
@@ -44,13 +45,14 @@
     endif()
 endif()

-# Use ccache if it is found
+# Find ccache and use it if it is found
 find_program(CCACHE_EXECUTABLE ccache)
 if(CCACHE_EXECUTABLE)
     set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_EXECUTABLE})
     set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_EXECUTABLE})
 endif()

+# Check for valgrind and set flags
 find_program(VALGRIND_EXECUTABLE valgrind)
 if(VALGRIND_EXECUTABLE)
     set(VALGRIND_SUPPRESSIONS_FILE "${PROJECT_SOURCE_DIR}/valgrind-suppressions.txt")
@@ -58,8 +60,6 @@
     set(VALGRIND_COMMAND "${VALGRIND_EXECUTABLE} ${VALGRIND_OPTIONS}")
 endif()

-set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
-
 if(EXTRA_LINK_DIRECTORY)
     link_directories(${EXTRA_LINK_DIRECTORY})
 endif()


cmake: Bump version to 1.2.90

cmake: Bump version to 1.2.90

In preparation for waffle-1.3.0.

Signed-off-by: Chad Versace <a557f7f75bf28dc19ac99107f5cc7cd6b3fbdb1a@linux.intel.com>

--- cmake/Modules/WaffleDefineVersion.cmake
+++ cmake/Modules/WaffleDefineVersion.cmake
@@ -36,9 +36,11 @@
 #
 # !!! Must be updated in tandem with the Android.mk !!!
 #
+# Bump this to x.y.90 immediately after each waffle-x.y.0 release.
+#
 set(waffle_major_version "1")
 set(waffle_minor_version "2")
-set(waffle_patch_version "75")
+set(waffle_patch_version "90")

 set(waffle_version "${waffle_major_version}.${waffle_minor_version}.${waffle_patch_version}")


Fixing misspelling of 'ADDRESSS'

Fixing misspelling of 'ADDRESSS'

--- cmake/RepositoryDependenciesSetup.cmake
+++ cmake/RepositoryDependenciesSetup.cmake
@@ -1 +1 @@
-SET_DEFAULT(DataTransferKit_REPOSITORY_MASTER_EMAIL_ADDRESSS coupler-infrastructure@casl-dev.ornl.gov)
+SET_DEFAULT(DataTransferKit_REPOSITORY_MASTER_EMAIL_ADDRESS coupler-infrastructure@casl-dev.ornl.gov)


update ffmpeg dependencies in use script

issue https://github.com/smanders/externpro/issues/276

--- projects/use/usexp-ffmpeg-config.cmake
+++ projects/use/usexp-ffmpeg-config.cmake
@@ -33,8 +33,8 @@
 xpGetPkgVar(openh264 LIBRARIES) # sets OPENH264_LIBRARIES
 set(_ffmpeg_avcodec_libs ${OPENH264_LIBRARIES})
 # _ffmpeg_*_deps
-set(_ffmpeg_avdevice_deps avformat)
-set(_ffmpeg_avfilter_deps swresample swscale) # libavfilter code calls swr_*, sws_* functions
+set(_ffmpeg_avdevice_deps avfilter avformat)
+set(_ffmpeg_avfilter_deps avcodec swresample swscale) # libavfilter code calls swr_*, sws_* functions
 set(_ffmpeg_avformat_deps avcodec)
 set(_ffmpeg_avcodec_deps swresample) # libavcodec code calls swr_* functions
 set(_ffmpeg_swresample_deps avutil)


COMP: additional check for module conf file

--- CMake/CoreHelpers.cmake
+++ CMake/CoreHelpers.cmake
@@ -176,6 +176,14 @@
 MACRO(MITK_CREATE_MODULE MODULE_NAME_IN)
   MACRO_PARSE_ARGUMENTS(MODULE "INCLUDE_DIRS;INTERNAL_INCLUDE_DIRS;DEPENDS;DEPENDS_INTERNAL;PROVIDES;PACKAGE_DEPENDS;EXPORT_DEFINE;ADDITIONAL_LIBS;GENERATED_CPP" "QT_MODULE;FORCE_STATIC" ${ARGN})
   SET(MODULE_NAME ${MODULE_NAME_IN})
+
+  # first of all we check for the dependencies
+  MITK_CHECK_MODULE(_MISSING_DEP ${MODULE_DEPENDS})
+  IF(_MISSING_DEP)
+    MESSAGE("Warning: Module ${MODULE_NAME} won't be built, missing dependency: ${_MISSING_DEP}")
+     # remove possibly existing config, to avoid strange errors
+     FILE(REMOVE ${MITK_MODULES_CONF_DIR}/${MODULE_NAME}Config.cmake )
+   ELSE(_MISSING_DEP)
   _MITK_CREATE_MODULE_CONF()

   IF(NOT MODULE_EXPORT_DEFINE)
@@ -248,7 +256,8 @@
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib/static
-)
+  )
+ENDIF(_MISSING_DEP)
 ENDMACRO(MITK_CREATE_MODULE)

 MACRO(MITK_USE_MODULE)


px4-same70xplained-v1:Update to master rename trone to teraranger

--- cmake/configs/nuttx_px4-same70xplained-v1_default.cmake
+++ cmake/configs/nuttx_px4-same70xplained-v1_default.cmake
@@ -28,7 +28,7 @@
 	drivers/srf02
 	drivers/sf0x
 	drivers/ll40ls
-	drivers/trone
+	drivers/teraranger
 	drivers/gps
 #WIP 	drivers/pwm_out_sim
 	drivers/hott


px4_fmu-v3 include icm20948 (Here+ compass)

--- boards/px4/fmu-v3/default.cmake
+++ boards/px4/fmu-v3/default.cmake
@@ -34,6 +34,7 @@
 		imu/lsm303d
 		imu/mpu6000
 		imu/mpu9250
+		imu/icm20948
 		irlock
 		lights/blinkm
 		lights/oreoled


qemu_x86: use icount for 32-bit

qemu_x86: use icount for 32-bit

Options summary:

 -icount shift=5: Execute one instruction every 32ns of virtual time
 -icount align=off: Do not synchronise the host and guest clocks
 -icount sleep=off: Advance virtual time without sleeping/waiting
 -rtc clock=vm: Isolate the guest RTC time from the host

64-bit still has some issues that are being looked at.

Signed-off-by: Andrew Boie <aab045b28152628be6af0e556050d0381fd0a34d@intel.com>

--- boards/x86/qemu_x86/board.cmake
+++ boards/x86/qemu_x86/board.cmake
@@ -11,6 +11,7 @@
   set(QEMU_CPU_TYPE_${ARCH} qemu64,+x2apic)
 else()
   set(QEMU_CPU_TYPE_${ARCH} qemu32,+nx,+pae)
+  set(ICOUNT_ARG -icount shift=5,align=off,sleep=off -rtc clock=vm)
 endif()

 set(QEMU_FLAGS_${ARCH}
@@ -19,6 +20,7 @@
   -device isa-debug-exit,iobase=0xf4,iosize=0x04
   ${REBOOT_FLAG}
   -nographic
+  ${ICOUNT_ARG}
   )

 # TODO: Support debug


update openni2-camera-lcm and cv-utils externals

--- distro/superbuild/cmake/externals.cmake
+++ distro/superbuild/cmake/externals.cmake
@@ -416,7 +416,7 @@

   ExternalProject_Add(cv-utils
     GIT_REPOSITORY https://github.com/patmarion/cv-utils
-    GIT_TAG 1d1465d
+    GIT_TAG 481f429
     CMAKE_CACHE_ARGS
       ${default_cmake_args}
     DEPENDS


[CMake][Darwin] Match cxx-headers -> cxx_headers libcxx target rename.

This was changed in r334477.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@334550 91177308-0d34-0410-b5e6-96231b3b80d8

--- cmake/caches/Apple-stage2.cmake
+++ cmake/caches/Apple-stage2.cmake
@@ -61,7 +61,7 @@
   LTO
   clang-format
   clang-headers
-  cxx-headers
+  cxx_headers
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")


Added folders like arduino-0022 to the search path

--- cmake/modules/FindArduino.cmake
+++ cmake/modules/FindArduino.cmake
@@ -46,10 +46,12 @@
 #
 #       generate_arduino_library(test)

+file(GLOB SDK_PATHS /usr/share/arduino*)

 find_path(ARDUINO_SDK_PATH
           NAMES lib/version.txt hardware libraries
-          PATH_SUFFIXES  share/arduino
+		  PATH_SUFFIXES  share/arduino
+		  HINTS ${SDK_PATHS}
           DOC "Arduino Development Kit path.")


Fix for ROOT-7333 (Pythia 6 is not found by CMake in ROOT if the 'general_pythia.inc' file is not found)

--- cmake/modules/FindPythia6.cmake
+++ cmake/modules/FindPythia6.cmake
@@ -24,8 +24,9 @@
            PATH_SUFFIXES include
            DOC "Specify the Pythia6 include dir here.")

-set(PYTHIA6_INCLUDE_DIRS ${PYTHIA6_INCLUDE_DIR})
-
+if(PYTHIA6_INCLUDE_DIR)
+  set(PYTHIA6_INCLUDE_DIRS ${PYTHIA6_INCLUDE_DIR})
+endif()

 find_library(PYTHIA6_LIBRARY NAMES pythia6 Pythia6
              HINTS ${_pythia6dirs}
@@ -49,7 +50,7 @@
 # all listed variables are TRUE

 include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(Pythia6 DEFAULT_MSG PYTHIA6_INCLUDE_DIR PYTHIA6_LIBRARY)
+find_package_handle_standard_args(Pythia6 DEFAULT_MSG PYTHIA6_LIBRARY)

 mark_as_advanced(PYTHIA6_INCLUDE_DIR
                  PYTHIA6_LIBRARY


CI: disallow testing

CI: disallow testing

--- CI/main_ci.cmake
+++ CI/main_ci.cmake
@@ -84,6 +84,8 @@
   message( SEND_ERROR "An error occurs during ctest_build.")
 endif()

+# TODO
+if ( is_ready for_test )
 ctest_test(PARALLEL_LEVEL 8
            RETURN_VALUE _test_rv
            CAPTURE_CMAKE_ERROR _test_error
@@ -94,4 +96,5 @@
   message( SEND_ERROR "An error occurs during ctest_test.")
 endif()

+endif()
 ctest_submit()


MINIFICPP-1906 Restore original timeout for CivetServer

There was a change in CivetWeb (commit hash: a7361235) where a
previously used poll function with constant timeout of 200 ms was
replaced with the mg_poll function. This function uses the
SOCKET_TIMEOUT_QUANTUM constant for the timeout value of a single poll
call. The default value of this constant is 2000 ms and due to this the
shutdown of the CivetServer had to wait 10 times more for the ongoing
poll to finish in every single test case, which increased the runtime of
the test cases. The SOCKET_TIMEOUT_QUANTUM is changed back to 200 ms in
this PR.

Closes #1403
Signed-off-by: Marton Szasz <31b5bd3b18a572d1fc7a9fcda5b5dbc3d4eb31ff@apache.org>

--- cmake/CivetWeb.cmake
+++ cmake/CivetWeb.cmake
@@ -35,6 +35,7 @@
 add_dependencies(civetweb-c-library OpenSSL::Crypto OpenSSL::SSL)
 add_dependencies(civetweb-cpp OpenSSL::Crypto OpenSSL::SSL)

+target_compile_definitions(civetweb-c-library PRIVATE SOCKET_TIMEOUT_QUANTUM=200)
 if (NOT WIN32)
   target_compile_options(civetweb-c-library PRIVATE -Wno-error)
   target_compile_options(civetweb-cpp PRIVATE -Wno-error)


update FindFFTW.cmake

update FindFFTW.cmake

--- cmake/FindFFTW.cmake
+++ cmake/FindFFTW.cmake
@@ -1,22 +1,139 @@
-# - Find FFTW
-# Find the native FFTW includes and library
+# ########################################################################
+# Copyright 2013 Advanced Micro Devices, Inc.
 #
-#  FFTW_INCLUDES    - where to find fftw3.h
-#  FFTW_LIBRARIES   - List of libraries when using FFTW.
-#  FFTW_FOUND       - True if FFTW found.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ########################################################################

-if (FFTW_INCLUDES)
-  # Already in cache, be silent
-  set (FFTW_FIND_QUIETLY TRUE)
-endif (FFTW_INCLUDES)

-find_path (FFTW_INCLUDES fftw3.h)
+# Locate the FFTW (http://www.fftw.org/) Framework.
+#
+# Defines the following variables:
+#
+#   FFTW_FOUND - Found the FFTW framework
+#   FFTW_INCLUDE_DIRS - Include directories
+#
+# Also defines the library variables below as normal
+# variables.  These contain debug/optimized keywords when
+# a debugging library is found.
+#
+#   FFTW_LIBRARIES - libfftw
+#
+# Accepts the following variables as input:
+#
+#   FFTW_ROOT - (as a CMake or environment variable)
+#                The root directory of the fftw install prefix
+#
+#   FIND_LIBRARY_USE_LIB64_PATHS - Global property that controls whether
+#               findFFTW should search for 64bit or 32bit libs
+#-----------------------------------------------
+# Example Usage:
+#
+#    find_package(FFTW REQUIRED)
+#    include_directories(${FFTW_INCLUDE_DIRS})
+#
+#    add_executable(foo foo.cc)
+#    target_link_libraries(foo ${FFTW_LIBRARIES})
+#
+#-----------------------------------------------

-find_library (FFTW_LIBRARIES NAMES fftw3)
+find_path(FFTW_INCLUDE_DIRS
+    NAMES fftw3.h
+    HINTS
+        ${FFTW_ROOT}/include
+        ${FFTW_ROOT}/api
+        ${FFTW_ROOT}
+        $ENV{FFTW_ROOT}/include
+        $ENV{FFTW_ROOT}/api
+        ENV FFTW_ROOT
+    PATHS
+        /usr/include
+        /usr/local/include
+)
+mark_as_advanced( FFTW_INCLUDE_DIRS )

-# handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
-# all listed variables are TRUE
-include (FindPackageHandleStandardArgs)
-find_package_handle_standard_args (FFTW DEFAULT_MSG FFTW_LIBRARIES FFTW_INCLUDES)
+find_library( FFTW_SINGLE_PRECISION_LIBRARIES
+    NAMES fftw3f libfftw3f-3
+    HINTS
+        ${FFTW_ROOT}/lib
+        ${FFTW_ROOT}/.libs
+        ${FFTW_ROOT}
+        $ENV{FFTW_ROOT}/lib
+        $ENV{FFTW_ROOT}/.libs
+        ENV FFTW_ROOT
+    PATHS
+        /usr/lib
+        /usr/local/lib
+    DOC "FFTW dynamic library"
+)
+mark_as_advanced( FFTW_SINGLE_PRECISION_LIBRARIES )

-mark_as_advanced (FFTW_LIBRARIES FFTW_INCLUDES)
+find_library( FFTW_SINGLE_THREADS_LIBRARIES
+    NAMES fftw3f_threads libfftw3f_threads-3
+    HINTS
+        ${FFTW_ROOT}/lib
+        ${FFTW_ROOT}/.libs
+        ${FFTW_ROOT}
+        $ENV{FFTW_ROOT}/lib
+        $ENV{FFTW_ROOT}/.libs
+        ENV FFTW_ROOT
+    PATHS
+        /usr/lib
+        /usr/local/lib
+    DOC "FFTW dynamic library"
+)
+mark_as_advanced( FFTW_SINGLE_THREADS_LIBRARIES )
+
+find_library( FFTW_DOUBLE_THREADS_LIBRARIES
+    NAMES fftw3_threads libfftw3_threads-3
+    HINTS
+        ${FFTW_ROOT}/lib
+        ${FFTW_ROOT}/.libs
+        ${FFTW_ROOT}
+        $ENV{FFTW_ROOT}/lib
+        $ENV{FFTW_ROOT}/.libs
+        ENV FFTW_ROOT
+    PATHS
+        /usr/lib
+        /usr/local/lib
+    DOC "FFTW dynamic library"
+)
+mark_as_advanced( FFTW_DOUBLE_THREADS_LIBRARIES )
+
+find_library( FFTW_DOUBLE_PRECISION_LIBRARIES
+    NAMES fftw3 libfftw3-3
+    HINTS
+        ${FFTW_ROOT}/lib
+        ${FFTW_ROOT}/.libs
+        ${FFTW_ROOT}
+        $ENV{FFTW_ROOT}/lib
+        $ENV{FFTW_ROOT}/.libs
+        ENV FFTW_ROOT
+    PATHS
+        /usr/lib
+        /usr/local/lib
+    DOC "FFTW dynamic library"
+)
+mark_as_advanced( FFTW_DOUBLE_PRECISION_LIBRARIES )
+
+set( FFTW_LIBRARIES ${FFTW_SINGLE_PRECISION_LIBRARIES} ${FFTW_DOUBLE_PRECISION_LIBRARIES} ${FFTW_SINGLE_THREADS_LIBRARIES} ${FFTW_DOUBLE_THREADS_LIBRARIES})
+mark_as_advanced( FFTW_LIBRARIES )
+
+include( FindPackageHandleStandardArgs )
+FIND_PACKAGE_HANDLE_STANDARD_ARGS( FFTW DEFAULT_MSG FFTW_LIBRARIES FFTW_INCLUDE_DIRS )
+
+if( NOT FFTW_FOUND )
+    message( STATUS "FindFFTW looked for single precision threads libraries named: fftw3_threads or libfftw3_threads-3" )
+    message( STATUS "FindFFTW looked for single precision threads libraries named: fftw3f_threads or libfftw3f_threads-3" )
+    message( STATUS "FindFFTW looked for single precision libraries named: fftw3f or libfftw3f-3" )
+    message( STATUS "FindFFTW looked for double precision libraries named: fftw3 or libfftw3-3" )
+endif()


Fix FindPOPT.cmake when find_package(PkgConfig) fails.

It's possible for find_package() to fail, and thus pkg_search_module() will not be available.

Also FIND_PACKAGE_HANDLE_STANDARD_ARGS() should only be needed when PkgConfig didn't work.

--- cmake/FindPOPT.cmake
+++ cmake/FindPOPT.cmake
@@ -44,12 +44,16 @@
   ##_____________________________________________________________________________
   ## Check with PkgConfig (to retrieve static dependencies such as iconv)
   find_package(PkgConfig QUIET)
-  pkg_search_module (POPT QUIET popt)
+  if (PKG_CONFIG_FOUND)
+    pkg_search_module (POPT QUIET popt)
+  endif (PKG_CONFIG_FOUND)
+
+  ##_____________________________________________________________________________
+  ## Fallback to searching if PkgConfig didn't work.
   if (NOT POPT_FOUND)

     ##_____________________________________________________________________________
     ## Check for the header files
-
     find_path (POPT_INCLUDE_DIRS popt.h
       HINTS ${POPT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX} $ENV{programfiles}\\GnuWin32 $ENV{programfiles32}\\GnuWin32
       PATH_SUFFIXES include
@@ -57,18 +61,19 @@

     ##_____________________________________________________________________________
     ## Check for the library
-
     find_library (POPT_LIBRARIES popt
       HINTS ${POPT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX} $ENV{programfiles}\\GnuWin32 $ENV{programfiles32}\\GnuWin32
       PATH_SUFFIXES lib
       )
+
+    ##_____________________________________________________________________________
+    ## Check the libraries and include dirs and set POPT_FOUND.
+    FIND_PACKAGE_HANDLE_STANDARD_ARGS (POPT DEFAULT_MSG POPT_LIBRARIES POPT_INCLUDE_DIRS)
+
   endif (POPT_FOUND)

   ##_____________________________________________________________________________
   ## Actions taken when all components have been found
-
-  FIND_PACKAGE_HANDLE_STANDARD_ARGS (POPT DEFAULT_MSG POPT_LIBRARIES POPT_INCLUDE_DIRS)
-
   if (POPT_FOUND)
     if (NOT POPT_FIND_QUIETLY)
       message (STATUS "Found components for POPT")
@@ -84,7 +89,6 @@

   ##_____________________________________________________________________________
   ## Mark advanced variables
-
   mark_as_advanced (
     POPT_ROOT_DIR
     POPT_INCLUDE_DIRS


cmake fix

cmake fix

git-svn-id: 6b1c4fe79111c0bc0cce83313250759594f8984b@6130 e128ff1e-fa79-4151-a8cb-522299a2c450

--- cmake/gsConfig.cmake
+++ cmake/gsConfig.cmake
@@ -12,8 +12,8 @@

 include(CheckCXXCompilerFlag)

-if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
-  #fixme: enable for Darwin (probably no export explicit template instantiations)
+if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  #fixme: enable for Darwin/clang (probably no export explicit template instantiations)
   set(GISMO_CXX_VISIBILITY_PRESET hidden)
   set(CMAKE_C_VISIBILITY_PRESET   hidden)
   set(CMAKE_VISIBILITY_INLINES_HIDDEN 1 )
@@ -166,8 +166,8 @@
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj")
     #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -Wl,--gc-sections")
   endif()
-elseif(NOT MSVC AND NOT POLICY CMP0063 AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
-  #fixme: enable for Darwin (probably no export explicit template instantiations)
+elseif(NOT MSVC AND NOT POLICY CMP0063 AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  #fixme: enable for Darwin/clang (probably no export explicit template instantiations)
   check_cxx_compiler_flag(-fvisibility=hidden visibility)
     if (visibility) # for object libraries with cmake less than 3.3
       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")


CMakeCache.txt: Flush OpenSSL path variables

--- cmake/modules/hunter_flush_cache_variables.cmake
+++ cmake/modules/hunter_flush_cache_variables.cmake
@@ -45,6 +45,12 @@
     endif()

     if(x MATCHES "^OpenCV_CONFIG_PATH$")
+      set(cleanup TRUE)
+    endif()
+    # }
+
+    # From FindOpenSSL.cmake {
+    if(x MATCHES "^OPENSSL_(SSL|CRYPTO)_LIBRARY$")
       set(cleanup TRUE)
     endif()
     # }


Fallback to CMAKE_CXX_COMPILER_VERSION if VS version unknown

--- cmake/EigenDetermineVSServicePack.cmake
+++ cmake/EigenDetermineVSServicePack.cmake
@@ -26,6 +26,8 @@
                         set(_sp "vc110sp2")
                     elseif(${_cl_version} VERSION_EQUAL "17.00.60610.1")
                         set(_sp "vc110sp3")
+                    else()
+                        set(_sp ${CMAKE_CXX_COMPILER_VERSION})
                     endif()
                 endif()


Show fatal error for tools missing

Show fatal error for tools missing

--- cmake/toolchains/Toolchain-native.cmake
+++ cmake/toolchains/Toolchain-native.cmake
@@ -3,7 +3,7 @@
 	string(TOUPPER ${tool} TOOL)
 	find_program(${TOOL} ${tool})
 	if(NOT ${TOOL})
-		#message(FATAL_ERROR "could not find ${tool}")
+		message(FATAL_ERROR "could not find ${tool}")
 	endif()
 endforeach()


Enable SHA256 to be used as hashing algorithm for compiler/assembler

--- compileoptions.cmake
+++ compileoptions.cmake
@@ -91,6 +91,7 @@
   add_compile_options(/Zm200) # Specify Precompiled Header Memory Allocation Limit of 150MB
   add_compile_options(/wd4960 /wd4961 /wd4603 /wd4627 /wd4838 /wd4456 /wd4457 /wd4458 /wd4459 /wd4091 /we4640)
   add_compile_options(/Zi) # enable debugging information
+  add_compile_options(/ZH:SHA_256) # use SHA256 for generating hashes of compiler processed source files.

   if (CLR_CMAKE_PLATFORM_ARCH_I386)
     add_compile_options(/Gz)
@@ -116,6 +117,8 @@
   add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/MT>)
   add_compile_options($<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:/MTd>)

+  set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /ZH:SHA_256")
+
 endif (WIN32)

 if(CMAKE_ENABLE_CODE_COVERAGE)


ENH: Added a USE_DOXYGEN setting

ENH: Added a USE_DOXYGEN setting

--- DartConfig.cmake
+++ DartConfig.cmake
@@ -11,8 +11,9 @@
 SET (CVS_WEB_CVSROOT "Insight")

 OPTION(BUILD_DOXYGEN "Build source documentation using doxygen" "On")
+SET (DOXYGEN_CONFIG "${PROJECT_BINARY_DIR}/doxygen.config" )
+SET (USE_DOXYGEN "On")
 SET (DOXYGEN_URL "http://${DROP_SITE}/Insight/Doxygen/html/" )
-SET (DOXYGEN_CONFIG "${PROJECT_BINARY_DIR}/doxygen.config" )

 SET (USE_GNATS "On")
 SET (GNATS_WEB_URL "http://${DROP_SITE}/cgi-bin/gnatsweb.pl/Insight/")


rmw include directories were missing from typesupport library

--- rosidl_typesupport_opensplice_cpp/cmake/rosidl_typesupport_opensplice_cpp_generate_interfaces.cmake
+++ rosidl_typesupport_opensplice_cpp/cmake/rosidl_typesupport_opensplice_cpp_generate_interfaces.cmake
@@ -243,6 +243,7 @@
   "${_output_path}/msg/dds_opensplice"
   "${_output_path}/srv/dds_opensplice"
 )
+ament_target_dependencies(${rosidl_generate_interfaces_TARGET}${_target_suffix} "rmw")
 foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES})
   set(_msg_include_dir "${${_pkg_name}_DIR}/../../../include/${_pkg_name}/msg/dds_opensplice")
   set(_srv_include_dir "${${_pkg_name}_DIR}/../../../include/${_pkg_name}/srv/dds_opensplice")


Tweak tarball target

Tweak tarball target

--- GitTargets.cmake
+++ GitTargets.cmake
@@ -71,7 +71,7 @@

 add_custom_target(tarball-prepare
   COMMAND ${GIT_EXECUTABLE} checkout -q release-${VERSION}
-  COMMAND ${CMAKE_COMMAND} -E remove_directory ".git"
+  COMMAND ${CMAKE_COMMAND} -E remove_directory .git
   DEPENDS tarball-clone
   WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}"
   COMMENT "Preparing ${CMAKE_PROJECT_NAME}-${VERSION}"
@@ -85,7 +85,8 @@
   COMMENT "Creating ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}.tar.gz"
   )

-set(_gittargets_TARGETS branch cut tag erase)
+set(_gittargets_TARGETS branch cut tag erase tarball tarball-clone
+  tarball-prepare)
 foreach(_gittargets_TARGET ${_gittargets_TARGETS})
   set_target_properties(${_gittargets_TARGET} PROPERTIES EXCLUDE_FROM_ALL ON)
   set_target_properties(${_gittargets_TARGET} PROPERTIES FOLDER "git")


Update ITK download SHA

Update ITK download SHA


COMP: Fix macOS packaging ensuring *Python.so module are correctly installed

Prior to this commit the vtk*Python.so modules where installed in

  lib/Slicer-4.11/qt-loadable-modules/Python

Following this commit, modules are installed in the correct directory
allowing them to be fixed up:

  lib/Slicer-4.11/qt-loadable-modules/

See https://discourse.slicer.org/t/vmtk-vessel-filtering-not-working/1263/26?u=jcfr

--- SuperBuild/External_VMTK.cmake
+++ SuperBuild/External_VMTK.cmake
@@ -61,7 +61,7 @@
       # installation location for all vtkvmtk stuff
       -DVTK_VMTK_INSTALL_BIN_DIR:PATH=${Slicer_INSTALL_QTLOADABLEMODULES_BIN_DIR}
       -DVTK_VMTK_INSTALL_LIB_DIR:PATH=${Slicer_INSTALL_QTLOADABLEMODULES_LIB_DIR}
-      -DVTK_VMTK_MODULE_INSTALL_LIB_DIR:PATH=${Slicer_INSTALL_QTLOADABLEMODULES_PYTHON_LIB_DIR}
+      -DVTK_VMTK_MODULE_INSTALL_LIB_DIR:PATH=${Slicer_INSTALL_QTLOADABLEMODULES_LIB_DIR}
       -DVTK_VMTK_WRAP_PYTHON:BOOL=ON
       # we don't want superbuild since it will override our CMake settings
       -DVMTK_USE_SUPERBUILD:BOOL=OFF


Fixed VMTK master

Fixed VMTK master

--- SuperBuild/External_VMTK.cmake
+++ SuperBuild/External_VMTK.cmake
@@ -27,7 +27,7 @@
     #GIT_TAG "master"
     # Use this repository/branch to test changes using nightly builds:
     GIT_REPOSITORY "${git_protocol}://github.com/rlizzo/vmtk"
-    GIT_TAG "update_cmake_policies"
+    GIT_TAG "master"
     SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}
     BINARY_DIR ${proj}-build
     CMAKE_CACHE_ARGS


Fix FindFBX.

Fix FindFBX.

--- FindFBX.cmake
+++ FindFBX.cmake
@@ -67,7 +67,7 @@
     find_library(${_name}
         NAMES ${_lib}
         HINTS ${FBX_SEARCH_LOCATIONS}
-        PATH_SUFFIXES lib/${fbx_compiler}/ub/${_suffix} lib/${VS_PREFIX}/x64/${_suffix}
+        PATH_SUFFIXES lib/${fbx_compiler}/release lib/${fbx_compiler}/ub/${_suffix} lib/${VS_PREFIX}/x64/${_suffix}
     )
     mark_as_advanced(${_name})
 endfunction()


COMP:Check Cpp11 Keywords

COMP:Check Cpp11 Keywords

--- CMake/OTBCheckCpp11Keywords.cmake
+++ CMake/OTBCheckCpp11Keywords.cmake
@@ -1,32 +1,5 @@
-include(CheckCXXSourceRuns)

-unset(CMAKE_REQUIRED_INCLUDES)
-unset(CMAKE_REQUIRED_LIBRARIES)
-set(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS})
-unset(CMAKE_REQUIRED_DEFINES)
+try_compile(OTB_IS_UNIQUE_PTR_DEFINED ${CMAKE_CURRENT_BINARY_DIR}/CMake ${CMAKE_SOURCE_DIR}/CMake/otbTestUniquePtr.cpp)
+try_compile(OTB_IS_OVERRIDE_DEFINED ${CMAKE_CURRENT_BINARY_DIR}/CMake ${CMAKE_SOURCE_DIR}/CMake/otbTestUniquePtr.cpp)
+try_compile(OTB_IS_NULLPTR_DEFINED ${CMAKE_CURRENT_BINARY_DIR}/CMake ${CMAKE_SOURCE_DIR}/CMake/otbTestUniquePtr.cpp)

-# check if unique_ptr is defined
-file(READ ${CMAKE_SOURCE_DIR}/CMake/otbTestUniquePtr.cpp
-  OTB_TEST_UNIQUE_PTR_SOURCE)
-check_cxx_source_runs(
-  "${OTB_TEST_UNIQUE_PTR_SOURCE}"
-  OTB_IS_UNIQUE_PTR_DEFINED
-  )
-
-# check if override keyword is known
-file(READ ${CMAKE_SOURCE_DIR}/CMake/otbTestOverride.cpp
-  OTB_TEST_OVERRIDE_SOURCE)
-check_cxx_source_runs(
-  "${OTB_TEST_OVERRIDE_SOURCE}"
-  OTB_IS_OVERRIDE_DEFINED
-  )
-
-# check if nullptr keyword is known
-file(READ ${CMAKE_SOURCE_DIR}/CMake/otbTestNullPtr.cpp
-  OTB_TEST_NULLPTR_SOURCE)
-check_cxx_source_runs(
-  "${OTB_TEST_NULLPTR_SOURCE}"
-  OTB_IS_NULLPTR_DEFINED
-  )
-
-unset(CMAKE_REQUIRED_FLAGS)


Don't look up system boost libraries on Android, since we are cross-compiling.

--- cmake/ConfigurePackages.cmake
+++ cmake/ConfigurePackages.cmake
@@ -34,6 +34,11 @@

 message("** Configuring Boost")
 message(STATUS "Using BOOST_ROOT = " ${BOOST_ROOT})
+
+# We build boost from custom deps directory, so don't look up boost from system.
+if (ANDROID)
+   set(Boost_NO_SYSTEM_PATHS TRUE)
+endif()

 set(Boost_FIND_REQUIRED TRUE)
 set(Boost_FIND_QUIETLY TRUE)


Changing default path to find Caffe libraries

--- cmake/Modules/FindCaffe.cmake
+++ cmake/Modules/FindCaffe.cmake
@@ -13,7 +13,7 @@

 find_library(Caffe_LIBRARIES NAMES caffe
   HINTS
-  ${Caffe_DIR}/lib)
+  ${Caffe_DIR}/build/lib)

 message("lib_dirs:${Caffe_LIBRARIES}")


Bundle utility cmake configuration now allow Engine tests on CI.

--- cmake/application_setup.cmake
+++ cmake/application_setup.cmake
@@ -1,19 +1,20 @@
-# -------------------------- Usefull fonctions for application and plugins client  ------------------------------------
-# CMAKE tips : To delay evaluation of some variable to build time, just escape their name (e.g \${NAME} instead of ${NAME}
-# TODO : works well on MacOs : must be tested on other systems
-# TODO, some part are only for MACOS but could be generalized to all systems (MACOSX_BUNDLE on MacOs, Bundle like directories on other systems
+#-- -- -- -- -- -- -- -- --  Usefull fonctions for application and plugins client -- -- -- -- -- -- -- -- -- -- -- --
+#CMAKE tips : To delay evaluation of some variable to build time, just escape their name( e.g \${NAME} instead of ${NAME}
+#TODO : works well on MacOs : must be tested on other systems
+#TODO, some part are only for MACOS but could be generalized to all systems
+#   (MACOSX_BUNDLE on MacOs, Bundle like directories on other systems
 include(CMakeParseArguments)
-# Install resources : link (copy under window) the resource dir DIRECTORY into the buildtree at the given BUILDLOCATION and install the
-# required files into the <bundle>/Resources
-# If called only with a directory, all the files in this directory and subdirs will be installed
-# to be called with
-# installResources ( TARGET theTarget`
-#                    [BUILDLOCATION whereToLinkInTheBuildTree]
-#                    DIRECTORY theBaseRessourceDirectory
-#                    [FILES [file1 [file2 ... ]]]
+#Install resources : link( copy under window ) the resource dir DIRECTORY into the buildtree at the given BUILDLOCATION
+# and install the required files into the < bundle> / Resources
+#If called only with a directory, all the files in this directory and subdirs will be installed
+#to be called with
+#installResources( TARGET theTarget`
+#                  [BUILDLOCATION whereToLinkInTheBuildTree]
+#                  DIRECTORY theBaseRessourceDirectory
+#                  [FILES[file1[file2...]]]
 #
 function(installTargetResources)
-    # "declare" and parse parameters
+    #"declare" and parse parameters
     cmake_parse_arguments(
             ARGS
             ""
@@ -21,7 +22,7 @@
             "FILES"
             ${ARGN}
     )
-    # verify that the function was called with expected parameters
+    #verify that the function was called with expected parameters
     if (NOT ARGS_TARGET)
         message(FATAL_ERROR " [installResources] You must provide a target that need these resources")
     endif ()
@@ -29,13 +30,13 @@
         message(FATAL_ERROR " [installResources] You must provide a resource directory")
     endif ()
     if (NOT ARGS_BUILDLOCATION)
-        # linking resours in the current bin dir of the build tree
+        #linking resours in the current bin dir of the build tree
         set(ARGS_BUILDLOCATION ${CMAKE_CURRENT_BINARY_DIR})
     endif ()
-    # compute resources dir for build tree and install tree
+    #compute resources dir for build tree and install tree
     get_filename_component(rsc_dir ${ARGS_DIRECTORY} NAME)
     set(buildtree_dir ${ARGS_BUILDLOCATION})
-    # installing resources in the buildtree (link if available, copy if not)
+    #installing resources in the buildtree( link if available, copy if not)
     message(STATUS " [installResources] Linking resources directory ${ARGS_DIRECTORY} for target ${ARGS_TARGET} into ${buildtree_dir}/Resources/${rsc_dir}")
     file(MAKE_DIRECTORY "${buildtree_dir}")
     if (MSVC OR MSVC_IDE OR MINGW)
@@ -54,8 +55,8 @@
         )
     endif ()

-    # Install in the install tree
-    # Identify the individual files (to preserve directory structure)
+    #Install in the install tree
+    #Identify the individual files( to preserve directory structure )
     message(STATUS " [installResources] configuring install for requested files of ${ARGS_DIRECTORY}")
     if (NOT ARGS_FILES)
         file(GLOB_RECURSE ARGS_FILES RELATIVE ${ARGS_DIRECTORY} ${ARGS_DIRECTORY}/*)
@@ -181,6 +182,7 @@
     if (ARGS_USE_PLUGINS)
         install(CODE "
         include(BundleUtilities)
+        set(BU_CHMOD_BUNDLE_ITEMS TRUE)
         file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/${ARGS_NAME}.app/Contents/Resources)
         file(COPY ${RADIUM_RESOURCES_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}/${ARGS_NAME}.app/Contents)
         if (EXISTS ${RADIUM_PLUGINS_DIR})
@@ -202,6 +204,7 @@
         install(CODE "
             message(STATUS \"Installing ${ARGS_NAME} without plugins\")
             include(BundleUtilities)
+            set(BU_CHMOD_BUNDLE_ITEMS TRUE)
             file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/${ARGS_NAME}.app/Contents/Resources)
             file(COPY ${RADIUM_RESOURCES_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}/${ARGS_NAME}.app/Contents)
             fixup_bundle(${CMAKE_INSTALL_PREFIX}/${ARGS_NAME}.app \"\" \"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\")


Undo previous change to curl

Undo previous change to curl

--- cmake/modules/BuildCURL.cmake
+++ cmake/modules/BuildCURL.cmake
@@ -31,12 +31,9 @@
 set(CURL_INCLUDE_DIRS "${install_dir}/include")

 if(WIN32)
-#  set(CURL_LIBRARY "$<$<CONFIG:Release>:${install_dir}/lib/libcurl_imp.lib>$<$<CONFIG:Debug>:${install_dir}/lib/libcurl-d_imp.lib>")
-#  set(CURL_LIBRARIES "${CURL_LIBRARY}")
-#  set(CURL_INSTALL_LIBS "$<$<CONFIG:Release>:${install_dir}/bin/libcurl.dll>$<$<CONFIG:Debug>:${install_dir}/bin/libcurl-d.dll>")
-  set(CURL_LIBRARY "$<TARGET_LINKER_FILE:curl>")
+  set(CURL_LIBRARY "$<$<CONFIG:Release>:${install_dir}/lib/libcurl_imp.lib>$<$<CONFIG:Debug>:${install_dir}/lib/libcurl-d_imp.lib>")
   set(CURL_LIBRARIES "${CURL_LIBRARY}")
-  set(CURL_INSTALL_LIBS "$<TARGET_FILE:curl>")
+  set(CURL_INSTALL_LIBS "$<$<CONFIG:Release>:${install_dir}/bin/libcurl.dll>$<$<CONFIG:Debug>:${install_dir}/bin/libcurl-d.dll>")
 else()
   set(CURL_LIBRARY "${install_dir}/lib/libcurl.so")
   set(CURL_LIBRARIES "${CURL_LIBRARY}")


FindGMock.cmake: put GMOCK_LIBRARY as first argument after DEFAULT_MSG

Putting GMock as the first argument, make the message better:

    -- Found GMock: /home/user/.../lib/libgmock.a

Instead of:

    -- Found GMock: TRUE

This matches the FindGTest output:

    -- Found GTest: /home/user/.../lib/libgtest.a

--- cmake/modules/FindGMock.cmake
+++ cmake/modules/FindGMock.cmake
@@ -18,8 +18,10 @@

 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(GMock DEFAULT_MSG
+  GMOCK_LIBRARY GMOCK_MAIN_LIBRARY
+  GMOCK_INCLUDE_DIR
   GTEST_FOUND
-  GMOCK_INCLUDE_DIR GMOCK_LIBRARY GMOCK_MAIN_LIBRARY)
+)
 mark_as_advanced(GMOCK_INCLUDE_DIR GMOCK_LIBRARY GMOCK_MAIN_LIBRARY)

 if (GMOCK_FOUND AND NOT TARGET GMock::GMock)


Quote the Python interpreter path

Quote the Python interpreter path

--- cmake/modules/FindNumPy.cmake
+++ cmake/modules/FindNumPy.cmake
@@ -10,7 +10,7 @@

 if (PYTHON_EXECUTABLE)
   execute_process(
-    COMMAND         ${PYTHON_EXECUTABLE} -c
+    COMMAND         "${PYTHON_EXECUTABLE}" -c
                     "import numpy, sys; sys.stdout.write(numpy.get_include())"
     RESULT_VARIABLE __numpy_include_dir_res
     OUTPUT_VARIABLE __numpy_include_dir


[cmake] Fix test run command line

[cmake] Fix test run command line

Summary: Useless arguement are passed to test, which is ok most of the time as they ignore it, but sometime, it's not.

Test Plan:
Change the command line for ctest to pass the -V flag.

  ninja check

Ensure no superfluous flags are passed.

Reviewers: #bitcoin_abc, schancel

Reviewed By: #bitcoin_abc, schancel

Subscribers: teamcity

Differential Revision: https://reviews.bitcoinabc.org/D1273

--- cmake/modules/TestSuite.cmake
+++ cmake/modules/TestSuite.cmake
@@ -13,6 +13,6 @@

 function(add_test_to_suite SUITE NAME)
 	add_executable(${NAME} EXCLUDE_FROM_ALL ${ARGN})
-	add_test(${NAME} ${NAME} COMMAND ${NAME})
+	add_test(${NAME} ${NAME})
 	add_dependencies("check-${SUITE}" ${NAME})
 endfunction(add_test_to_suite)


Fix bundled curl's installation paths

Fix bundled curl's installation paths

--- cmake/modules/buildCurl.cmake
+++ cmake/modules/buildCurl.cmake
@@ -10,13 +10,13 @@
       SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps/curl"
       BINARY_DIR "${CMAKE_BINARY_DIR}/deps/curl"
       PREFIX "${CMAKE_BINARY_DIR}/deps/curl"
-      CONFIGURE_COMMAND bash -c "${CMAKE_COMMAND} -DHTTP_ONLY=ON -DBUILD_CURL_EXE=OFF -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_USE_LIBSSH2=OFF ${CMAKE_SOURCE_DIR}/deps/curl && ${CMAKE_SOURCE_DIR}/patch-curl-clock-gettime.sh"
+      CONFIGURE_COMMAND bash -c "${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=/ -DCMAKE_INSTALL_LIBDIR=lib -DHTTP_ONLY=ON -DBUILD_CURL_EXE=OFF -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_USE_LIBSSH2=OFF ${SECURE_TRANSPORT_FLAGS} ${CMAKE_SOURCE_DIR}/deps/curl && ${CMAKE_SOURCE_DIR}/patch-curl-clock-gettime.sh"
       BUILD_COMMAND make
       INSTALL_COMMAND make DESTDIR=${CMAKE_BINARY_DIR}/deps/curl-install install
   )

   add_library(libcurl STATIC IMPORTED)
-  set_property(TARGET libcurl PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/deps/curl-install/usr/local/lib/libcurl.a)
+  set_property(TARGET libcurl PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/deps/curl-install/usr/lib/libcurl.a)
   add_dependencies(libcurl BuildCurlBundled)

   # Replace with the following when possible: