FindDirectX11: Try harder to find DX11 SDK as part of Modern SDK, use version passed by CMake or highest available, search in standard and obtaines from registry location, restored support for ARM and ARM64 library archs.

--- CMake/Packages/FindDirectX11.cmake
+++ CMake/Packages/FindDirectX11.cmake
@@ -23,48 +23,46 @@
 		# Windows Phone 8.1 SDK
 		if(WINDOWS_PHONE AND MSVC12)
 			find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS "C:/Program Files (x86)/Windows Phone Kits/8.1/include" "C:/Program Files/Windows Phone Kits/8.1/include")
-			set(DirectX11_LIBRARY d3d11.lib dxgi.lib dxguid.lib) # in "C:/Program Files (x86)/Windows Phone Kits/8.1/lib/${MSVC_CXX_ARCHITECTURE_ID}/"

 		# Windows Phone 8.0 SDK
 		elseif(WINDOWS_PHONE AND MSVC11)
 			find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS "C:/Program Files (x86)/Windows Phone Kits/8.0/include" "C:/Program Files/Windows Phone Kits/8.0/include")
-			set(DirectX11_LIBRARY d3d11.lib dxgi.lib dxguid.lib) # in "C:/Program Files (x86)/Windows Phone Kits/8.0/lib/${MSVC_CXX_ARCHITECTURE_ID}/"

 		endif()
 	elseif( NOT MSVC90 )
 		# Windows 10.x SDK
-		if(CMAKE_CL_64)
-			set(DirectX11_LIBPATH_SUFFIX "x64")
-		else(CMAKE_CL_64)
-			set(DirectX11_LIBPATH_SUFFIX "x86")
-		endif(CMAKE_CL_64)
 		get_filename_component(kit10_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" REALPATH)
-		file(GLOB kit10_list ${kit10_dir}/Include/10.*)
-		foreach(tmp_elem ${kit10_list})
-			if(IS_DIRECTORY ${tmp_elem})
-				get_filename_component(kit10_ver ${tmp_elem} NAME)
-				set(DirectX11_LIB_SEARCH_PATH "${kit10_dir}/Lib/${kit10_ver}/um")
-				find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS "${tmp_elem}/um")
-				find_library(DirectX11_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX11_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX11_LIBPATH_SUFFIX})
-				find_library(DirectX11_DXGI_LIBRARY NAMES dxgi HINTS ${DirectX11_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX11_LIBPATH_SUFFIX})
-				find_library(DirectX11_D3D11_LIBRARY NAMES d3d11 HINTS ${DirectX11_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX11_LIBPATH_SUFFIX})
-				set(DirectX11_LIBRARY
-					${DirectX11_D3D11_LIBRARY}
-					${DirectX11_DXGI_LIBRARY}
-					${DirectX11_DXGUID_LIBRARY}
-				)
-			endif()
+		file(GLOB W10SDK_VERSIONS RELATIVE ${kit10_dir}/Include ${kit10_dir}/Include/10.*) 			# enumerate pre-release and not yet known release versions
+		list(APPEND W10SDK_VERSIONS "10.0.10240.0" "10.0.14393.0" "10.0.15063.0" "10.0.16299.0")	# enumerate well known release versions
+		list(REMOVE_DUPLICATES W10SDK_VERSIONS)
+		list(SORT W10SDK_VERSIONS)
+		list(REVERSE W10SDK_VERSIONS)																# sort from high to low
+		if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
+			list(INSERT W10SDK_VERSIONS 0 ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})				# prefer version passed by CMake, if any
+		endif()
+		foreach(W10SDK_VER ${W10SDK_VERSIONS})
+			find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS "${kit10_dir}/Include/${W10SDK_VER}/um" "C:/Program Files (x86)/Windows Kits/10/Include/${W10SDK_VER}/um" "C:/Program Files/Windows Kits/10/Include/${W10SDK_VER}/um")
 		endforeach()
 		# Windows 8.1 SDK
 		if(NOT DirectX11_INCLUDE_DIR)
 			find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS "C:/Program Files (x86)/Windows Kits/8.1/include/um" "C:/Program Files/Windows Kits/8.1/include/um")
-			set(DirectX11_LIBRARY d3d11.lib dxgi.lib dxguid.lib) # in "C:/Program Files (x86)/Windows Kits/8.1/lib/winv6.3/um/${MSVC_CXX_ARCHITECTURE_ID}/"
 		endif()
 		# Windows 8.0 SDK
 		if(NOT DirectX11_INCLUDE_DIR)
 			find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS "C:/Program Files (x86)/Windows Kits/8.0/include/um" "C:/Program Files/Windows Kits/8.0/include/um")
-			set(DirectX11_LIBRARY d3d11.lib dxgi.lib dxguid.lib) # in "C:/Program Files (x86)/Windows Kits/8.0/lib/win8/um/${MSVC_CXX_ARCHITECTURE_ID}/"
 		endif()
+	endif()
+
+	if(DirectX11_INCLUDE_DIR)
+		# No need to specify full path to libraries, proper version would be found as part of SDK, in one of the following places
+		# "C:/Program Files (x86)/Windows Kits/10/lib/${W10SDK_VER}/um/${MSVC_CXX_ARCHITECTURE_ID}/"
+		# "C:/Program Files (x86)/Windows Kits/8.1/lib/winv6.3/um/${MSVC_CXX_ARCHITECTURE_ID}/"
+		# "C:/Program Files (x86)/Windows Kits/8.0/lib/win8/um/${MSVC_CXX_ARCHITECTURE_ID}/"
+		# "C:/Program Files (x86)/Windows Phone Kits/8.1/lib/${MSVC_CXX_ARCHITECTURE_ID}/"
+		# "C:/Program Files (x86)/Windows Phone Kits/8.0/lib/${MSVC_CXX_ARCHITECTURE_ID}/"
+		set(DirectX11_LIBRARY d3d11.lib dxgi.lib dxguid.lib)
+		# but it is usefull to output selected version to the log
+		message(STATUS "Found DirectX11 headers: ${DirectX11_INCLUDE_DIR}")
 	endif()

 	# Legacy Direct X SDK


update FindImageMagick so it works with cmake 0.6, add full copy of the license into the cmake file.

--- CMakeModules/FindImageMagick.cmake
+++ CMakeModules/FindImageMagick.cmake
@@ -63,19 +63,67 @@
 # (i.e., QUIET, REQUIRED, etc.).

 #=============================================================================
-# Copyright 2007-2009 Kitware, Inc.
+# CMake - Cross Platform Makefile Generator
+# Copyright 2000-2014 Kitware, Inc.
+# Copyright 2000-2011 Insight Software Consortium
 # Copyright 2007-2008 Miguel A. Figueroa-Villanueva <miguelf at ieee dot org>
 # Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
+# All rights reserved.
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+
+# * Neither the names of Kitware, Inc., the Insight Software Consortium,
+#   nor the names of their contributors may be used to endorse or promote
+#   products derived from this software without specific prior written
+#   permission.
+
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# ------------------------------------------------------------------------------
+
+# The above copyright and license notice applies to distributions of
+# CMake in source and binary form.  Some source files contain additional
+# notices of original copyright by their contributors; see each source
+# for details.  Third-party software packages supplied with CMake under
+# compatible licenses provide their own copyright notices documented in
+# corresponding subdirectories.
+
+# ------------------------------------------------------------------------------
+
+# CMake was initially developed by Kitware with the following sponsorship:
+
+#  * National Library of Medicine at the National Institutes of Health
+#    as part of the Insight Segmentation and Registration Toolkit (ITK).
+
+#  * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
+#    Visualization Initiative.
+
+#  * National Alliance for Medical Image Computing (NAMIC) is funded by the
+#    National Institutes of Health through the NIH Roadmap for Medical Research,
+#    Grant U54 EB005149.
+
+#  * Kitware, Inc.
 #=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-#  License text for the above reference.)
+

 #---------------------------------------------------------------------
 # Helper functions
@@ -147,8 +195,9 @@
 # Find each component. Search for all tools in same dir
 # <ImageMagick_EXECUTABLE_DIR>; otherwise they should be found
 # independently and not in a cohesive module such as this one.
-unset(ImageMagick_REQUIRED_VARS)
-unset(ImageMagick_DEFAULT_EXECUTABLES)
+#unset(ImageMagick_REQUIRED_VARS)
+#unset(ImageMagick_DEFAULT_EXECUTABLES)
+set(ImageMagick_FOUND TRUE)
 foreach(component ${ImageMagick_FIND_COMPONENTS}
     # DEPRECATED: forced components for backward compatibility
     convert mogrify import montage composite
@@ -172,50 +221,25 @@
     if(ImageMagick_EXECUTABLE_DIR)
       FIND_IMAGEMAGICK_EXE(${component})
     endif()
-
-    if(ImageMagick_FIND_COMPONENTS)
-      list(FIND ImageMagick_FIND_COMPONENTS ${component} is_requested)
-      if(is_requested GREATER -1)
-        list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_${component}_EXECUTABLE)
-      endif()
-    elseif(ImageMagick_${component}_EXECUTABLE)
-      # if no components were requested explicitly put all (default) executables
-      # in the list
-      list(APPEND ImageMagick_DEFAULT_EXECUTABLES ImageMagick_${component}_EXECUTABLE)
-    endif()
-  endif()
-endforeach()
-
-if(NOT ImageMagick_FIND_COMPONENTS AND NOT ImageMagick_DEFAULT_EXECUTABLES)
-  # No components were requested, and none of the default components were
-  # found. Just insert mogrify into the list of the default components to
-  # find so FPHSA below has something to check
-  list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_mogrify_EXECUTABLE)
-elseif(ImageMagick_DEFAULT_EXECUTABLES)
-  list(APPEND ImageMagick_REQUIRED_VARS ${ImageMagick_DEFAULT_EXECUTABLES})
-endif()
-
-set(ImageMagick_INCLUDE_DIRS ${ImageMagick_INCLUDE_DIRS})
-set(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES})
-
-if(ImageMagick_mogrify_EXECUTABLE)
-  execute_process(COMMAND ${ImageMagick_mogrify_EXECUTABLE} -version
-                  OUTPUT_VARIABLE imagemagick_version
-                  ERROR_QUIET
-                  OUTPUT_STRIP_TRAILING_WHITESPACE)
-  if(imagemagick_version MATCHES "^Version: ImageMagick [0-9]")
-    string(REGEX REPLACE "^Version: ImageMagick ([-0-9\\.]+).*" "\\1" ImageMagick_VERSION_STRING "${imagemagick_version}")
-  endif()
-  unset(imagemagick_version)
-endif()
+ENDIF(component STREQUAL "Magick++")
+
+  IF(NOT ImageMagick_${component}_FOUND)
+    LIST(FIND ImageMagick_FIND_COMPONENTS ${component} is_requested)
+    IF(is_requested GREATER -1)
+      SET(ImageMagick_FOUND FALSE)
+    ENDIF(is_requested GREATER -1)
+  ENDIF(NOT ImageMagick_${component}_FOUND)
+ENDFOREACH(component)
+
+SET(ImageMagick_INCLUDE_DIRS ${ImageMagick_INCLUDE_DIRS})
+SET(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES})

 #---------------------------------------------------------------------
 # Standard Package Output
 #---------------------------------------------------------------------
-include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(ImageMagick
-                                  REQUIRED_VARS ${ImageMagick_REQUIRED_VARS}
-                                  VERSION_VAR ImageMagick_VERSION_STRING
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+  ImageMagick DEFAULT_MSG ImageMagick_LIBRARIES
   )
 # Maintain consistency with all other variables.
 set(ImageMagick_FOUND ${IMAGEMAGICK_FOUND})


label todo with author

label todo with author

--- ament_cmake_python/cmake/ament_python_install_package.cmake
+++ ament_cmake_python/cmake/ament_python_install_package.cmake
@@ -57,7 +57,7 @@
     PATTERN "*.pyc" EXCLUDE
     PATTERN "__pycache__" EXCLUDE
   )
-  # TODO optionally compile Python files
+  # TODO(dirk-thomas): optionally compile Python files

   list(FIND AMENT_CMAKE_PYTHON_INSTALL_INSTALLED_NAMES "${package_name}" index)
   if(NOT index EQUAL -1)


Fix sasl2 library detection (#1070)

Fix sasl2 library detection (#1070)

--- build/cmake/FindSASL2.cmake
+++ build/cmake/FindSASL2.cmake
@@ -1,4 +1,5 @@
 include (CheckSymbolExists)
+include (CMakePushCheckState)

 message (STATUS "Searching for sasl/sasl.h")
 find_path (
@@ -27,12 +28,16 @@
 if (SASL_INCLUDE_DIRS AND SASL_LIBRARIES)
     set (SASL_FOUND 1)

+    cmake_push_check_state ()
+    list (APPEND CMAKE_REQUIRED_INCLUDES ${SASL_INCLUDE_DIRS})
+    list (APPEND CMAKE_REQUIRED_LIBRARIES ${SASL_LIBRARIES})
     check_symbol_exists (
         sasl_client_done
-        ${SASL_INCLUDE_DIRS}/sasl/sasl.h
-        MONGOC_HAVE_SASL_CLIENT_DONE)
+        sasl/sasl.h
+        HAVE_SASL_CLIENT_DONE)
+    cmake_pop_check_state()

-    if (MONGOC_HAVE_SASL_CLIENT_DONE)
+    if (HAVE_SASL_CLIENT_DONE)
         set (MONGOC_HAVE_SASL_CLIENT_DONE 1)
     else ()
         set (MONGOC_HAVE_SASL_CLIENT_DONE 0)


Build statically when used as subproject

--- qtssh.cmake
+++ qtssh.cmake
@@ -1,3 +1,4 @@
 message(STATUS "QtSsh subdir: ${CMAKE_CURRENT_LIST_DIR}")
+set(BUILD_STATIC ON)
 add_subdirectory(${CMAKE_CURRENT_LIST_DIR})
 include_directories(${CMAKE_CURRENT_LIST_DIR}/qtssh)


add header text to generated __init__.py files (#118)

--- lcm-cmake/lcmUtilities.cmake
+++ lcm-cmake/lcmUtilities.cmake
@@ -88,6 +88,11 @@
     if(EXISTS ${_init})
       file(REMOVE ${_init})
     endif()
+    file(APPEND ${_init}
+      "\"\"\"LCM package __init__.py file\n"
+      "This file automatically generated by lcm_wrap_types.\n"
+      "DO NOT MODIFY BY HAND!!!!\n"
+      "\"\"\"\n\n")
     _lcm_parent_list_append(_python_packages ${PATH})
     _lcm_parent_list_append(${_PYTHON_SOURCES} ${_init})
   endif()


Update facts.cmake

Update facts.cmake

--- facts/facts.cmake
+++ facts/facts.cmake
@@ -156,7 +156,7 @@
 			# 5. compilo y genera el paquete en local
 			message("Generating artifact ${PACKAGE} ...")
 			execute_process(
-				COMMAND python ${ARTIFACTS_PATH}/build.py ${PACKAGE} --depends=${DEPENDS_PATHFILE} --cmakefiles=${CMAKI_PATH} --prefix=${CMAKE_PREFIX_PATH} --third-party-dir=${CMAKE_PREFIX_PATH} --server=${CMAKI_REPOSITORY} -o
+				COMMAND python ${ARTIFACTS_PATH}/build.py ${PACKAGE} --depends=${DEPENDS_PATHFILE} --cmakefiles=${CMAKI_PATH} --prefix=${CMAKE_PREFIX_PATH} --third-party-dir=${CMAKE_PREFIX_PATH} --server=${CMAKI_REPOSITORY} --no-upload -o
 				WORKING_DIRECTORY "${ARTIFACTS_PATH}"
 				RESULT_VARIABLE artifacts_result
 				)


Use cmake VISIBILITY_PRESET property instead of compiler flag

--- prosoft/core/config/cmake/config_compiler.cmake
+++ prosoft/core/config/cmake/config_compiler.cmake
@@ -113,16 +113,11 @@
     endif()
 endmacro()

-macro(ps_core_config_symbols_hidden TARGET_NAME)
-    include(CheckCCompilerFlag)
-    if (NOT DEFINED HAS_FVISIBILITY_FLAG AND NOT MINGW)
-        include(CheckCCompilerFlag)
-        check_c_compiler_flag(-fvisibility=hidden HAS_FVISIBILITY_FLAG)
-    endif()
-    if (HAS_FVISIBILITY_FLAG)
-        target_compile_options(${TARGET_NAME} PRIVATE "-fvisibility=hidden")
-    endif()
-endmacro()
+set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
+function(ps_core_config_symbols_hidden TARGET_NAME)
+    set_target_properties(${TARGET_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
+    set_target_properties(${TARGET_NAME} PROPERTIES C_VISIBILITY_PRESET hidden)
+endfunction()

 macro(ps_core_config_compiler_defaults TARGET_NAME)
     ps_core_config_compiler_default_flags(${TARGET_NAME})


Updated

Updated

--- cmake/CMakeBuildFlags.cmake
+++ cmake/CMakeBuildFlags.cmake
@@ -16,6 +16,6 @@

 if(CMAKE_COMPILER_IS_GNUC)
 	if(CMAKE_C_COMPILER_VERSION VERSION_GREATER "5.3.0" AND NOT APPLE)
-		SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Ofast -DCML_DOUBLE_PRECISION=ON -Dmfloat_t=double")
+		SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Ofast -DCML_DOUBLE_PRECISION=ON -Dmfloat_t=double")
 	endif()
 endif()


Undo previous commit

Undo previous commit

--- cmake/InstallSymlinks.cmake
+++ cmake/InstallSymlinks.cmake
@@ -4,13 +4,6 @@
     install(CODE "
         set(SUBDIR \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${SUBDIR})
         file(GLOB_RECURSE FILES RELATIVE \${SUBDIR} \${SUBDIR}/*)
-        list(FILTER FILES EXCLUDE REGEX cmake)
-        file(GLOB_RECURSE CMAKE_FILES RELATIVE \${SUBDIR} \${SUBDIR}/*.cmake)
-        foreach(FILE \${CMAKE_FILES})
-            get_filename_component(CMAKE_DIR \${FILE} DIRECTORY)
-            list(APPEND FILES \${CMAKE_DIR})
-        endforeach()
-        list(REMOVE_DUPLICATES FILES)
         foreach(FILE \${FILES})
             set(SRC \${SUBDIR}/\${FILE})
             set(DEST \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/\${FILE})


Don't die if setuptools isn't present #683 Print warning that it is needed for python wheel.

--- cmake/MakePythonWheel.cmake
+++ cmake/MakePythonWheel.cmake
@@ -27,7 +27,13 @@
 "
         OUTPUT_VARIABLE wheel_filename
         OUTPUT_STRIP_TRAILING_WHITESPACE
+        ERROR_QUIET
     )
+    if(NOT wheel_filename)
+        message(STATUS "Python module `setuptools` required for correct wheel filename generation. Please install if needed.")
+        set(wheel_filename "unknown;unknown")
+    endif()
+
     list(GET wheel_filename 0 distname)
     list(GET wheel_filename 1 platformtag)
     set(complete_tag "${distname}-${platformtag}")


Copy doc if build on mac

Copy doc if build on mac

git-svn-id: e0b5bbb11d0e9fdbbfcabba14dc32ad5d6b235bd@356 fdac6126-5c0c-442c-9429-916003d36597

--- cmake/OpenMeshPackage.cmake
+++ cmake/OpenMeshPackage.cmake
@@ -129,7 +129,7 @@
   endif()

    # copy the documentation if it exists
-   IF ( WIN32)
+   IF ( WIN32 )
      if (EXISTS ${CMAKE_BINARY_DIR}/Build/Doc)
 	     install(DIRECTORY ${CMAKE_BINARY_DIR}/Build/Doc
 	     DESTINATION ./
@@ -171,6 +171,15 @@
   include (InstallRequiredSystemLibraries)
 endif ()

+if (APPLE)
+  if (EXISTS ${CMAKE_BINARY_DIR}/Build/share/OpenMesh/Doc)
+	     install(DIRECTORY ${CMAKE_BINARY_DIR}/Build/share/OpenMesh/Doc
+	     DESTINATION ./
+         COMPONENT Applications
+     )
+  endif()
+endif()
+

 include (CPack)

@@ -184,4 +193,4 @@
   add_custom_target (PACKAGE_SOURCE
     ${CMAKE_CPACK_COMMAND} --config "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake"
   )
-endif ()+endif ()


cmake: remove policy CMP0079 old behavior

Fixes: #38558

This commit removes: `cmake_policy(SET CMP0079 OLD)`

This means Zephyr will now allow the new CMP0079 behavior introduced
with CMake version 3.13.

Code has now been examined and no occurences has been found where the
INTERFACE keyword was used with `target_link_libraries()` outside the
CMakeLists.txt scope where the original libraries were created.

As an additional safeguard `./scripts/twister -c -N --cmake-only`
has been executed before and after this change and all `build.ninja`
files for each test / sample have been diffed.
Removing the CMP0079 policy creates identical build files, hence removal
of the old policy will not impact the build.

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

--- cmake/app/boilerplate.cmake
+++ cmake/app/boilerplate.cmake
@@ -30,11 +30,6 @@

 # CMP0002: "Logical target names must be globally unique"
 cmake_policy(SET CMP0002 NEW)
-
-# Use the old CMake behaviour until the build scripts have been ported
-# to the new behaviour.
-# CMP0079: "target_link_libraries() allows use with targets in other directories"
-cmake_policy(SET CMP0079 OLD)

 # Use the old CMake behaviour until we are updating the CMake 3.20 as minimum
 # required. This ensure that CMake >=3.20 will be consistent with older CMakes.


Revert "cmake: Error-out when 'project' is invoked too early"

This reverts commit 48f97ecf463d642297f61ac8b2ce3748469b98b4.

This is causing CI failures, so revert for now.

Signed-off-by: Carles Cufi <853081dc8dca4fe6a7e3c984752718b5db36e060@nordicsemi.no>

--- cmake/app/boilerplate.cmake
+++ cmake/app/boilerplate.cmake
@@ -27,14 +27,6 @@
 # to the new behaviour.
 # CMP0079: "target_link_libraries() allows use with targets in other directories"
 cmake_policy(SET CMP0079 OLD)
-
-# Error-out if 'project' has been invoked to avoid obscure user
-# errors.
-if(DEFINED CMAKE_PROJECT_NAME)
-  message(FATAL_ERROR
-    "'project()' was called before boilerplate.cmake was included, this is not supported."
-    )
-endif()

 define_property(GLOBAL PROPERTY ZEPHYR_LIBS
     BRIEF_DOCS "Global list of all Zephyr CMake libs that should be linked in"


Update comments

Update comments

[skip ci]

--- cmake/configs/default.cmake
+++ cmake/configs/default.cmake
@@ -1,12 +1,25 @@
-# Copyright (c) 2013-2014, Ruslan Baratov
+# Copyright (c) 2013-2015, Ruslan Baratov
 # All rights reserved.

 # Do not place header guards here

+# Unset:
+#   * ${PACKAGE_NAME}_ROOT (CMake variable)
+#   * ${PACKAGE_NAME}_ROOT (CMake cache variable)
+#   * ${PACKAGE_NAME}_ROOT (environment variable)
+
+# Set CMake variables:
+#   * HUNTER_${PACKAGE_NAME}_VERSION
+#   * HUNTER_${PACKAGE_NAME}_CMAKE_ARGS (optionally)
+
+# Usage:
+#   hunter_config(Foo VERSION 1.0.0)
+#   hunter_config(Boo VERSION 1.2.3z CMAKE_ARGS BOO_WITH_A=ON)
+
+# Wiki:
+#   * https://github.com/ruslo/hunter/wiki/dev.modules#hunter_config
+
 include(hunter_config)
-
-# unset <NAME>_ROOT (cache, environment, ...)
-# set HUNTER_<name>_VERSION or <NAME>_ROOT

 # NOTE: no names with spaces!


Make MKLDNN_ENABLE_CONCURRENT_EXEC ON to use concurrent scratchpad in mkldnn. (#2170)

--- cmake/external_mkldnn.cmake
+++ cmake/external_mkldnn.cmake
@@ -113,6 +113,7 @@
             -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
             -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
             -DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/mkldnn
+            -DMKLDNN_ENABLE_CONCURRENT_EXEC=ON
             -DMKLROOT=${MKL_ROOT}
             "-DARCH_OPT_FLAGS=-march=${NGRAPH_TARGET_ARCH} -mtune=${NGRAPH_TARGET_ARCH}"
         TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/tmp"
@@ -145,6 +146,7 @@
             -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
             -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
             -DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/mkldnn
+            -DMKLDNN_ENABLE_CONCURRENT_EXEC=ON
             -DMKLROOT=${MKL_ROOT}
             "-DARCH_OPT_FLAGS=-march=${NGRAPH_TARGET_ARCH} -mtune=${NGRAPH_TARGET_ARCH}"
         TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/tmp"


[CMake] Fix llvm_setup_rpath function

[CMake] Fix llvm_setup_rpath function

Summary:
Set _install_rpath to CMAKE_INSTALL_RPATH if it is defined, so that eventually
INSTALL_RPATH is set to CMAKE_INSTALL_RPATH.
The "if(NOT DEFINED CMAKE_INSTALL_RPATH)" was missing a corresponding else
clause.
This also cleans up the fix made in r285908.

Patch by Azharuddin Mohammed

Reviewers: john.brawn, sgundapa, beanz

Subscribers: chapuni, mgorny, llvm-commits

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

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

--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -1342,6 +1342,10 @@
 endfunction()

 function(llvm_setup_rpath name)
+  if(CMAKE_INSTALL_RPATH)
+    return()
+  endif()
+
   if(LLVM_INSTALL_PREFIX AND NOT (LLVM_INSTALL_PREFIX STREQUAL CMAKE_INSTALL_PREFIX))
     set(extra_libdir ${LLVM_LIBRARY_DIR})
   elseif(LLVM_BUILD_LIBRARY_DIR)
@@ -1352,25 +1356,21 @@
     set(_install_name_dir INSTALL_NAME_DIR "@rpath")
     set(_install_rpath "@loader_path/../lib" ${extra_libdir})
   elseif(UNIX)
-    if(NOT DEFINED CMAKE_INSTALL_RPATH)
-      set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
-      if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
-        set_property(TARGET ${name} APPEND_STRING PROPERTY
-                     LINK_FLAGS " -Wl,-z,origin ")
-      elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT LLVM_LINKER_IS_GOLD)
-        # $ORIGIN is not interpreted at link time by ld.bfd
-        set_property(TARGET ${name} APPEND_STRING PROPERTY
-                     LINK_FLAGS " -Wl,-rpath-link,${LLVM_LIBRARY_OUTPUT_INTDIR} ")
-      endif()
+    set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
+    if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
+      set_property(TARGET ${name} APPEND_STRING PROPERTY
+                   LINK_FLAGS " -Wl,-z,origin ")
+    elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT LLVM_LINKER_IS_GOLD)
+      # $ORIGIN is not interpreted at link time by ld.bfd
+      set_property(TARGET ${name} APPEND_STRING PROPERTY
+                   LINK_FLAGS " -Wl,-rpath-link,${LLVM_LIBRARY_OUTPUT_INTDIR} ")
     endif()
   else()
     return()
   endif()

-  if(DEFINED _install_rpath)
-    set_target_properties(${name} PROPERTIES
-                          BUILD_WITH_INSTALL_RPATH On
-                          INSTALL_RPATH "${_install_rpath}"
-                          ${_install_name_dir})
-  endif()
-endfunction()
+  set_target_properties(${name} PROPERTIES
+                        BUILD_WITH_INSTALL_RPATH On
+                        INSTALL_RPATH "${_install_rpath}"
+                        ${_install_name_dir})
+endfunction()


Update FindICU.cmake

Update FindICU.cmake

--- cmake_modules/FindICU.cmake
+++ cmake_modules/FindICU.cmake
@@ -1,156 +1,313 @@
-# Copyright 2006-2008 The FLWOR Foundation.
-#
-# 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.
-
-# - Find the International Components for Unicode (ICU) Library
-#
-# Once done this will define
-#
-#  ICU_FOUND          - True if ICU found.
-#  ICU_I18N_FOUND     - True if ICU's internationalization library found.
-#  ICU_DATA_FOUND     - True if ICU data library found.
-#
-#  ICU_INCLUDE_DIRS   - Directory to include to get ICU headers
-#                       Note: always include ICU headers as, e.g.,
-#                       unicode/utypes.h
-#  ICU_LIBRARIES      - Libraries to link against for the common ICU
-#  ICU_I18N_LIBRARIES - Libraries to link against for ICU internationaliation
-#                       (note: in addition to ICU_LIBRARIES)
-#  ICU_DATA_LIBRARIES - Libraries to link against for ICU data
-#
-#  ICU_VERSION        - ICU's version number.
-#
-
-# Look for the header file.
+# This module can find the International Components for Unicode (ICU) Library
+#
+# Requirements:
+# - CMake >= 2.8.3 (for new version of find_package_handle_standard_args)
+#
+# The following variables will be defined for your use:
+#   - ICU_FOUND             : were all of your specified components found (include dependencies)?
+#   - ICU_INCLUDE_DIRS      : ICU include directory
+#   - ICU_LIBRARIES         : ICU libraries
+#   - ICU_VERSION           : complete version of ICU (x.y.z)
+#   - ICU_MAJOR_VERSION     : major version of ICU
+#   - ICU_MINOR_VERSION     : minor version of ICU
+#   - ICU_PATCH_VERSION     : patch version of ICU
+#   - ICU_<COMPONENT>_FOUND : were <COMPONENT> found? (FALSE for non specified component if it is not a dependency)
+#
+# For windows or non standard installation, define ICU_ROOT variable to point to the root installation of ICU. Two ways:
+#   - run cmake with -DICU_ROOT=<PATH>
+#   - define an environment variable with the same name before running cmake
+# With cmake-gui, before pressing "Configure":
+#   1) Press "Add Entry" button
+#   2) Add a new entry defined as:
+#     - Name: ICU_ROOT
+#     - Type: choose PATH in the selection list
+#     - Press "..." button and select the root installation of ICU
+#
+# Example Usage:
+#
+#   1. Copy this file in the root of your project source directory
+#   2. Then, tell CMake to search this non-standard module in your project directory by adding to your CMakeLists.txt:
+#     set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
+#   3. Finally call find_package() once, here are some examples to pick from
+#
+#   Require ICU 4.4 or later
+#     find_package(ICU 4.4 REQUIRED)
+#
+#   if(ICU_FOUND)
+#      include_directories(${ICU_INCLUDE_DIRS})
+#      add_executable(myapp myapp.c)
+#      target_link_libraries(myapp ${ICU_LIBRARIES})
+#   endif(ICU_FOUND)
+
+#=============================================================================
+# Copyright (c) 2011-2013, julp
+#
+# Distributed under the OSI-approved BSD License
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#=============================================================================
+
+find_package(PkgConfig QUIET)
+
+########## Private ##########
+if(NOT DEFINED ICU_PUBLIC_VAR_NS)
+    set(ICU_PUBLIC_VAR_NS "ICU")                          # Prefix for all ICU relative public variables
+endif(NOT DEFINED ICU_PUBLIC_VAR_NS)
+if(NOT DEFINED ICU_PRIVATE_VAR_NS)
+    set(ICU_PRIVATE_VAR_NS "_${ICU_PUBLIC_VAR_NS}")       # Prefix for all ICU relative internal variables
+endif(NOT DEFINED ICU_PRIVATE_VAR_NS)
+if(NOT DEFINED PC_ICU_PRIVATE_VAR_NS)
+    set(PC_ICU_PRIVATE_VAR_NS "_PC${ICU_PRIVATE_VAR_NS}") # Prefix for all pkg-config relative internal variables
+endif(NOT DEFINED PC_ICU_PRIVATE_VAR_NS)
+
+function(icudebug _VARNAME)
+    if(${ICU_PUBLIC_VAR_NS}_DEBUG)
+        if(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME})
+            message("${ICU_PUBLIC_VAR_NS}_${_VARNAME} = ${${ICU_PUBLIC_VAR_NS}_${_VARNAME}}")
+        else(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME})
+            message("${ICU_PUBLIC_VAR_NS}_${_VARNAME} = <UNDEFINED>")
+        endif(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME})
+    endif(${ICU_PUBLIC_VAR_NS}_DEBUG)
+endfunction(icudebug)
+
+set(${ICU_PRIVATE_VAR_NS}_ROOT "")
+if(DEFINED ENV{ICU_ROOT})
+    set(${ICU_PRIVATE_VAR_NS}_ROOT "$ENV{ICU_ROOT}")
+endif(DEFINED ENV{ICU_ROOT})
+if (DEFINED ICU_ROOT)
+    set(${ICU_PRIVATE_VAR_NS}_ROOT "${ICU_ROOT}")
+endif(DEFINED ICU_ROOT)
+
+set(${ICU_PRIVATE_VAR_NS}_BIN_SUFFIXES )
+set(${ICU_PRIVATE_VAR_NS}_LIB_SUFFIXES )
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+    list(APPEND ${ICU_PRIVATE_VAR_NS}_BIN_SUFFIXES "bin64")
+    list(APPEND ${ICU_PRIVATE_VAR_NS}_LIB_SUFFIXES "lib64")
+endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
+list(APPEND ${ICU_PRIVATE_VAR_NS}_BIN_SUFFIXES "bin")
+list(APPEND ${ICU_PRIVATE_VAR_NS}_LIB_SUFFIXES "lib")
+
+set(${ICU_PRIVATE_VAR_NS}_COMPONENTS )
+# <icu component name> <library name 1> ... <library name N>
+macro(icu_declare_component _NAME)
+    list(APPEND ${ICU_PRIVATE_VAR_NS}_COMPONENTS ${_NAME})
+    set("${ICU_PRIVATE_VAR_NS}_COMPONENTS_${_NAME}" ${ARGN})
+endmacro(icu_declare_component)
+
+icu_declare_component(data icudata)
+icu_declare_component(uc   icuuc)         # Common and Data libraries
+icu_declare_component(i18n icui18n icuin) # Internationalization library
+icu_declare_component(io   icuio ustdio)  # Stream and I/O Library
+icu_declare_component(le   icule)         # Layout library
+icu_declare_component(lx   iculx)         # Paragraph Layout library
+
+########## Public ##########
+set(${ICU_PUBLIC_VAR_NS}_FOUND TRUE)
+set(${ICU_PUBLIC_VAR_NS}_LIBRARIES )
+set(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS )
+set(${ICU_PUBLIC_VAR_NS}_C_FLAGS "")
+set(${ICU_PUBLIC_VAR_NS}_CXX_FLAGS "")
+set(${ICU_PUBLIC_VAR_NS}_CPP_FLAGS "")
+set(${ICU_PUBLIC_VAR_NS}_C_SHARED_FLAGS "")
+set(${ICU_PUBLIC_VAR_NS}_CXX_SHARED_FLAGS "")
+set(${ICU_PUBLIC_VAR_NS}_CPP_SHARED_FLAGS "")
+foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PRIVATE_VAR_NS}_COMPONENTS})
+    string(TOUPPER "${${ICU_PRIVATE_VAR_NS}_COMPONENT}" ${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT)
+    set("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" FALSE) # may be done in the icu_declare_component macro
+endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
+
+# Check components
+if(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS) # uc required at least
+    set(${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS uc)
+else(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS)
+    list(APPEND ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS uc)
+    list(REMOVE_DUPLICATES ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS)
+    foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS})
+        if(NOT DEFINED ${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT})
+            message(FATAL_ERROR "Unknown ICU component: ${${ICU_PRIVATE_VAR_NS}_COMPONENT}")
+        endif(NOT DEFINED ${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT})
+    endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
+endif(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS)
+
+# Includes
 find_path(
-  ICU_INCLUDE
-  NAMES unicode/utypes.h
-  PATHS ${ICU_INCLUDE_DIR}
-  DOC "Include directory for the ICU library")
-mark_as_advanced(ICU_INCLUDE)
-
-# Look for the library.
-find_library(
-  ICU_LIBRARY
-  NAMES icuuc cygicuuc cygicuuc32 cygicuuc38
-  PATHS ${ICU_LIBRARY_DIR}
-  DOC "Libraries to link against for the common parts of ICU (icuuc, cygicuuc, cygicuuc32 or cygicuuc38)")
-mark_as_advanced(ICU_LIBRARY)
-
-if (ICU_LIBRARY)
-  MESSAGE(STATUS "Found ICU library -- " ${ICU_LIBRARY})
-else (ICU_LIBRARY)
-  MESSAGE(STATUS "Could not find ICU library")
-endif (ICU_LIBRARY)
-
-# Discover the version.
-IF (NOT ICU_INCLUDE STREQUAL "")
-  # ICU 3.x has the relevant #defines in uversion.h; 4.x uses uvernum.h.
-  FIND_PATH(ICUVERHPPPATH NAMES unicode/uvernum.h unicode/uversion.h
-    PATHS ${ICU_INCLUDE} NO_DEFAULT_PATH)
-
-  IF ( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
-    SET(ICU_VERSION "0")
-    MESSAGE(STATUS "Found ICU but unable to determine version - assuming version 0")
-  ELSE( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
-    SET (ICUVERHPP)
-    # One of these files has to exist, or else ICUVERHPPPATH wouldn't be set.
-    # If uvernum.h exists, it has the data we want; otherwise, that data is
-    # in uversion.h.
-    FOREACH (header uvernum.h uversion.h)
-      SET (headerfile "${ICUVERHPPPATH}/unicode/${header}")
-      IF (EXISTS "${headerfile}")
-	FILE(READ "${headerfile}" ICUVERHPP)
-	BREAK()
-      ENDIF (EXISTS "${headerfile}")
-    ENDFOREACH (header)
-
-    STRING(REGEX MATCH "\n *#define U_ICU_VERSION_MAJOR_NUM +[0-9]+" ICUVERMAJ
-      ${ICUVERHPP})
-    STRING(REGEX MATCH "\n *#define U_ICU_VERSION_MINOR_NUM +[0-9]+" ICUVERMIN
-      ${ICUVERHPP})
-    STRING(REGEX
-      MATCH "\n *#define U_ICU_VERSION_PATCHLEVEL_NUM +[0-9]+" ICUVERPATCH
-      ${ICUVERHPP})
-
-    STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_MAJOR_NUM +" ""
-      ICUVERMAJ ${ICUVERMAJ})
-    STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_MINOR_NUM +" ""
-      ICUVERMIN ${ICUVERMIN})
-    STRING(REGEX REPLACE "\n *#define U_ICU_VERSION_PATCHLEVEL_NUM +" ""
-      ICUVERPATCH ${ICUVERPATCH})
-
-    SET(ICU_VERSION ${ICUVERMAJ}.${ICUVERMIN}.${ICUVERPATCH})
-    MESSAGE(STATUS "ICU Version: ${ICU_VERSION}")
-
-  ENDIF ( ${ICUVERHPPPATH} STREQUAL ICUVERHPPPATH-NOTFOUND )
-ENDIF (NOT ICU_INCLUDE STREQUAL "")
-
-
-# Copy the results to the output variables.
-if(ICU_INCLUDE AND ICU_LIBRARY)
-  set(ICU_FOUND 1)
-  set(ICU_LIBRARIES ${ICU_LIBRARY})
-  set(ICU_INCLUDE_DIRS ${ICU_INCLUDE})
-
-  # Look for the ICU internationalization libraries
-  find_library(
-    ICU_I18N_LIBRARY
-    NAMES icuin icui18n cygicuin cygicuin32 cygicuin38
-    PATHS ${ICU_LIBRARY_DIR}
-    DOC "Libraries to link against for ICU internationalization (icuin, icui18n, cygicuin, cygicuin32 or cygicuin38)")
-  mark_as_advanced(ICU_I18N_LIBRARY)
-  if (ICU_I18N_LIBRARY)
-    MESSAGE(STATUS "Found ICU internationalization library -- " ${ICU_I18N_LIBRARY})
-    set(ICU_I18N_FOUND 1)
-    set(ICU_I18N_LIBRARIES ${ICU_I18N_LIBRARY})
-  else (ICU_I18N_LIBRARY)
-    MESSAGE(STATUS "Could not find ICU internationalization library")
-    set(ICU_I18N_FOUND 0)
-    set(ICU_I18N_LIBRARIES)
-  endif (ICU_I18N_LIBRARY)
-
-  # On cygwin, the data library is called icudt
-  if (CYGWIN OR MSVC)
-    SET (ICU_DATA_NAMES icudt cygicudt cygicudt38)
-  else (CYGWIN OR MSVC)
-    SET (ICU_DATA_NAMES icudata)
-  endif (CYGWIN OR MSVC)
-
-  # Look for ICU data library
-  find_library(
-    ICU_DATA_LIBRARY
-    NAMES ${ICU_DATA_NAMES}
-    PATHS ${ICU_LIBRARY_DIR}
-    DOC "icudata library (icudt, cygicudt or cygicudt38)")
-  mark_as_advanced(ICU_DATA_LIBRARY)
-  if (ICU_DATA_LIBRARY)
-    MESSAGE(STATUS "Found ICU data library -- " ${ICU_DATA_LIBRARY})
-    SET(ICU_DATA_FOUND 1)
-    SET(ICU_DATA_LIBRARIES ${ICU_DATA_LIBRARY})
-  else (ICU_DATA_LIBRARY)
-    MESSAGE(STATUS "Could not find ICU data library")
-    SET(ICU_DATA_FOUND 0)
-    SET(ICU_DATA_LIBRARIES)
-  endif (ICU_DATA_LIBRARY)
-
-else(ICU_INCLUDE AND ICU_LIBRARY)
-  set(ICU_FOUND 0)
-  set(ICU_I18N_FOUND 0)
-  set(ICU_DATA_FOUND 0)
-  set(ICU_LIBRARIES)
-  set(ICU_I18N_LIBRARIES)
-  set(ICU_DATA_LIBRARIES)
-  set(ICU_INCLUDE_DIRS)
-  set(ICU_VERSION 0)
-endif(ICU_INCLUDE AND ICU_LIBRARY)
+    ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS
+    NAMES unicode/utypes.h utypes.h
+    HINTS ${${ICU_PRIVATE_VAR_NS}_ROOT}
+    PATH_SUFFIXES "include"
+    DOC "Include directories for ICU"
+)
+
+if(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS)
+    ########## <part to keep synced with tests/version/CMakeLists.txt> ##########
+    if(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uvernum.h") # ICU >= 4
+        file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uvernum.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
+    elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uversion.h") # ICU [2;4[
+        file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uversion.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
+    elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/utypes.h") # ICU [1.4;2[
+        file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/utypes.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
+    elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/utypes.h") # ICU 1.3
+        file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/utypes.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
+    else()
+        message(FATAL_ERROR "ICU version header not found")
+    endif()
+
+    if(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *ICU_VERSION *\"([0-9]+)\".*") # ICU 1.3
+        # [1.3;1.4[ as #define ICU_VERSION "3" (no patch version, ie all 1.3.X versions will be detected as 1.3.0)
+        set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "1")
+        set(${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${CMAKE_MATCH_1}")
+        set(${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "0")
+    elseif(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *U_ICU_VERSION_MAJOR_NUM *([0-9]+).*")
+        #
+        # Since version 4.9.1, ICU release version numbering was totaly changed, see:
+        # - http://site.icu-project.org/download/49
+        # - http://userguide.icu-project.org/design#TOC-Version-Numbers-in-ICU
+        #
+        set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "${CMAKE_MATCH_1}")
+        string(REGEX REPLACE ".*# *define *U_ICU_VERSION_MINOR_NUM *([0-9]+).*" "\\1" ${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS}")
+        string(REGEX REPLACE ".*# *define *U_ICU_VERSION_PATCHLEVEL_NUM *([0-9]+).*" "\\1" ${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "${${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS}")
+    elseif(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *U_ICU_VERSION *\"(([0-9]+)(\\.[0-9]+)*)\".*") # ICU [1.4;1.8[
+        # [1.4;1.8[ as #define U_ICU_VERSION "1.4.1.2" but it seems that some 1.4.1(?:\.\d)? have releasing error and appears as 1.4.0
+        set(${ICU_PRIVATE_VAR_NS}_FULL_VERSION "${CMAKE_MATCH_1}") # copy CMAKE_MATCH_1, no longer valid on the following if
+        if(${ICU_PRIVATE_VAR_NS}_FULL_VERSION MATCHES "^([0-9]+)\\.([0-9]+)$")
+            set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "${CMAKE_MATCH_1}")
+            set(${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${CMAKE_MATCH_2}")
+            set(${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "0")
+        elseif(${ICU_PRIVATE_VAR_NS}_FULL_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)")
+            set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "${CMAKE_MATCH_1}")
+            set(${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${CMAKE_MATCH_2}")
+            set(${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "${CMAKE_MATCH_3}")
+        endif()
+    else()
+        message(FATAL_ERROR "failed to detect ICU version")
+    endif()
+    set(${ICU_PUBLIC_VAR_NS}_VERSION "${${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION}.${${ICU_PUBLIC_VAR_NS}_MINOR_VERSION}.${${ICU_PUBLIC_VAR_NS}_PATCH_VERSION}")
+    ########## </part to keep synced with tests/version/CMakeLists.txt> ##########
+
+    # Check dependencies (implies pkg-config)
+    if(PKG_CONFIG_FOUND)
+        set(${ICU_PRIVATE_VAR_NS}_COMPONENTS_DUP ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS})
+        foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PRIVATE_VAR_NS}_COMPONENTS_DUP})
+            pkg_check_modules(PC_ICU_PRIVATE_VAR_NS "icu-${${ICU_PRIVATE_VAR_NS}_COMPONENT}" QUIET)
+
+            if(${PC_ICU_PRIVATE_VAR_NS}_FOUND)
+                foreach(${PC_ICU_PRIVATE_VAR_NS}_LIBRARY ${PC_ICU_LIBRARIES})
+                    string(REGEX REPLACE "^icu" "" ${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY ${${PC_ICU_PRIVATE_VAR_NS}_LIBRARY})
+                    list(APPEND ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS ${${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY})
+                endforeach(${PC_ICU_PRIVATE_VAR_NS}_LIBRARY)
+            endif(${PC_ICU_PRIVATE_VAR_NS}_FOUND)
+        endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
+        list(REMOVE_DUPLICATES ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS)
+    endif(PKG_CONFIG_FOUND)
+
+    # Check libraries
+    foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS})
+        set(${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES )
+        set(${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES )
+        foreach(${ICU_PRIVATE_VAR_NS}_BASE_NAME ${${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT}})
+            list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}")
+            list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}d")
+            list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}${ICU_MAJOR_VERSION}${ICU_MINOR_VERSION}")
+            list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}${ICU_MAJOR_VERSION}${ICU_MINOR_VERSION}d")
+        endforeach(${ICU_PRIVATE_VAR_NS}_BASE_NAME)
+
+        find_library(
+            ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT}
+            NAMES ${${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES}
+            HINTS ${${ICU_PRIVATE_VAR_NS}_ROOT}
+            PATH_SUFFIXES ${_ICU_LIB_SUFFIXES}
+            DOC "Release libraries for ICU"
+        )
+        find_library(
+            ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}
+            NAMES ${${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES}
+            HINTS ${${ICU_PRIVATE_VAR_NS}_ROOT}
+            PATH_SUFFIXES ${_ICU_LIB_SUFFIXES}
+            DOC "Debug libraries for ICU"
+        )
+
+        string(TOUPPER "${${ICU_PRIVATE_VAR_NS}_COMPONENT}" ${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT)
+        if(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # both not found
+            set("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" FALSE)
+            set("${ICU_PUBLIC_VAR_NS}_FOUND" FALSE)
+        else(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # one or both found
+            set("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" TRUE)
+            if(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # release not found => we are in debug
+                set(${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT} "${${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}")
+            elseif(NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # debug not found => we are in release
+                set(${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT} "${${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}")
+            else() # both found
+                set(
+                    ${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT}
+                    optimized ${${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}
+                    debug ${${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}
+                )
+            endif()
+            list(APPEND ${ICU_PUBLIC_VAR_NS}_LIBRARIES ${${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT}})
+        endif(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT})
+    endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
+
+    # Try to find out compiler flags
+    find_program(${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE icu-config HINTS ${${ICU_PRIVATE_VAR_NS}_ROOT})
+    if(${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE)
+        execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cflags OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_C_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
+        execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cxxflags OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CXX_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
+        execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cppflags OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CPP_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+        execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cflags-dynamic OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_C_SHARED_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
+        execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cxxflags-dynamic OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CXX_SHARED_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
+        execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cppflags-dynamic OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CPP_SHARED_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
+    endif(${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE)
+
+    # Check find_package arguments
+    include(FindPackageHandleStandardArgs)
+    if(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
+        find_package_handle_standard_args(
+            ${ICU_PUBLIC_VAR_NS}
+            REQUIRED_VARS ${ICU_PUBLIC_VAR_NS}_LIBRARIES ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS
+            VERSION_VAR ${ICU_PUBLIC_VAR_NS}_VERSION
+        )
+    else(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
+        find_package_handle_standard_args(${ICU_PUBLIC_VAR_NS} "ICU not found" ${ICU_PUBLIC_VAR_NS}_LIBRARIES ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS)
+    endif(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
+else(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS)
+    if(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
+        message(FATAL_ERROR "Could not find ICU include directory")
+    endif(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
+endif(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS)
+
+mark_as_advanced(
+    ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS
+    ${ICU_PUBLIC_VAR_NS}_LIBRARIES
+)
+
+# IN (args)
+icudebug("FIND_COMPONENTS")
+icudebug("FIND_REQUIRED")
+icudebug("FIND_QUIETLY")
+icudebug("FIND_VERSION")
+# OUT
+# Found
+icudebug("FOUND")
+icudebug("UC_FOUND")
+icudebug("I18N_FOUND")
+icudebug("IO_FOUND")
+icudebug("LE_FOUND")
+icudebug("LX_FOUND")
+icudebug("DATA_FOUND")
+# Flags
+icudebug("C_FLAGS")
+icudebug("CPP_FLAGS")
+icudebug("CXX_FLAGS")
+icudebug("C_SHARED_FLAGS")
+icudebug("CPP_SHARED_FLAGS")
+icudebug("CXX_SHARED_FLAGS")
+# Linking
+icudebug("INCLUDE_DIRS")
+icudebug("LIBRARIES")
+# Version
+icudebug("MAJOR_VERSION")
+icudebug("MINOR_VERSION")
+icudebug("PATCH_VERSION")
+icudebug("VERSION")


#55 Made FindsfeMovie.cmake more standard (works on OS X)

--- cmake/Modules/FindsfeMovie.cmake
+++ cmake/Modules/FindsfeMovie.cmake
@@ -11,7 +11,7 @@
 # set( SFEMOVIE_STATIC_LIBRARIES TRUE )
 # find_package( sfeMovie )
 #
-# If sfeMovie is not installed in a standard path, you can use the SFEMOVIEDIR or
+# If sfeMovie is not installed in a standard path, you can set
 # SFEMOVIE_ROOT CMake (or environment) variables to tell CMake where to look for
 # sfeMovie.
 #
@@ -21,7 +21,7 @@
 # This script defines the following variables:
 #   - SFEMOVIE_LIBRARY_DEBUG:   the path to the debug library
 #   - SFEMOVIE_LIBRARY_RELEASE: the path to the release library
-#   - SFEMOVIE_LIBRARY:         the path to the library to link to
+#   - SFEMOVIE_LIBRARY:         the path to the library to link to for current configuration
 #   - SFEMOVIE_FOUND:           true if the sfeMovie library is found
 #   - SFEMOVIE_INCLUDE_DIR:     the path where sfeMovie headers are located (the directory containing the sfeMovie/Movie.hpp file)
 #
@@ -33,7 +33,7 @@
 # add_executable( myapp ... )
 # target_link_libraries( myapp ${SFEMOVIE_LIBRARY} ... )

-set( SFEMOVIE_FOUND false )
+include(FindPackageHandleStandardArgs)

 if( SFEMOVIE_STATIC_LIBRARIES )
 	set( SFEMOVIE_SUFFIX "-s" )
@@ -42,18 +42,18 @@
 	set( SFEMOVIE_SUFFIX "" )
 endif()

+set (LIBRARY_SEARCH_PATHS
+	/usr
+	/usr/local
+	${SFEMOVIE_ROOT}
+	$ENV{SFEMOVIE_ROOT})
+
 find_path(
 	SFEMOVIE_INCLUDE_DIR
 	sfeMovie/Movie.hpp
 	PATH_SUFFIXES
 		include
-	PATHS
-		/usr
-		/usr/local
-		${SFEMOVIEDIR}
-		${SFEMOVIE_ROOT}
-		$ENV{SFEMOVIEDIR}
-		$ENV{SFEMOVIE_ROOT}
+	PATHS ${LIBRARY_SEARCH_PATHS}}
 )

 find_library(
@@ -62,13 +62,7 @@
 	PATH_SUFFIXES
 		lib
 		lib64
-	PATHS
-		/usr
-		/usr/local
-		${SFEMOVIEDIR}
-		${SFEMOVIE_ROOT}
-		$ENV{SFEMOVIEDIR}
-		$ENV{SFEMOVIE_ROOT}
+	PATHS ${LIBRARY_SEARCH_PATHS}
 )

 find_library(
@@ -77,13 +71,7 @@
 	PATH_SUFFIXES
 		lib
 		lib64
-	PATHS
-		/usr
-		/usr/local
-		${SFEMOVIEDIR}
-		${SFEMOVIE_ROOT}
-		$ENV{SFEMOVIEDIR}
-		$ENV{SFEMOVIE_ROOT}
+	PATHS ${LIBRARY_SEARCH_PATHS}
 )

 if( SFEMOVIE_LIBRARY_RELEASE AND SFEMOVIE_LIBRARY_DEBUG )
@@ -100,9 +88,8 @@
 	set( SFEMOVIE_LIBRARY ${SFEMOVIE_LIBRARY_DEBUG} )
 endif()

-if( NOT SFEMOVIE_INCLUDE_DIR OR NOT SFEMOVIE_LIBRARY )
-	message( FATAL_ERROR "sfeMovie not found." )
-else()
-	set( SFEMOVIE_FOUND true )
-	message( STATUS "sfeMovie found: ${SFEMOVIE_INCLUDE_DIR}" )
-endif()
+# handle the QUIETLY and REQUIRED arguments and set SFEMOVIE_FOUND to TRUE if
+# all listed variables are TRUE
+find_package_handle_standard_args(sfeMovie
+	FAIL_MESSAGE "Could NOT find sfeMovie. Make sure it is installed or define SFEMOVIE_ROOT if it is located in a custom path"
+    REQUIRED_VARS SFEMOVIE_LIBRARY SFEMOVIE_INCLUDE_DIR)


Improved examples in FindBuzz.cmake.

Improved examples in FindBuzz.cmake.

--- src/utility/FindBuzz.cmake
+++ src/utility/FindBuzz.cmake
@@ -22,7 +22,16 @@
 # ::
 #
 #   find_package(Buzz)
+#   if(BUZZ_FOUND)
+#     include_directories(${BUZZ_INCLUDE_DIR})
+#     ...
+#     target_link_libraries(... ${BUZZ_LIBRARY})
+#   endif(BUZZ_FOUND)
+#
 #   find_package(Buzz REQUIRED)
+#   include_directories(${BUZZ_INCLUDE_DIR})
+#   ...
+#   target_link_libraries(... ${BUZZ_LIBRARY})

 #=============================================================================
 # Copyright 2016 Carlo Pinciroli <carlo@pinciroli.net>


android/android.toolchain.cmake: Update from https://github.com/taka-no-me/android-cmake/blob/master/android.toolchain.cmake.

--- android/android.toolchain.cmake
+++ android/android.toolchain.cmake
@@ -1,5 +1,5 @@
 # Copyright (c) 2010-2011, Ethan Rublee
-# Copyright (c) 2011-2013, Andrey Kamaev
+# Copyright (c) 2011-2014, Andrey Kamaev
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -12,9 +12,9 @@
 #     this list of conditions and the following disclaimer in the documentation
 #     and/or other materials provided with the distribution.
 #
-# 3.  The name of the copyright holders may be used to endorse or promote
-#     products derived from this software without specific prior written
-#     permission.
+# 3.  Neither the name of the copyright holder nor the names of its
+#     contributors may be used to endorse or promote products derived from this
+#     software without specific prior written permission.
 #
 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -29,7 +29,7 @@
 # POSSIBILITY OF SUCH DAMAGE.

 # ------------------------------------------------------------------------------
-#  Android CMake toolchain file, for use with the Android NDK r5-r8
+#  Android CMake toolchain file, for use with the Android NDK r5-r9
 #  Requires cmake 2.6.3 or newer (2.8.5 or newer is recommended).
 #  See home page: https://github.com/taka-no-me/android-cmake
 #
@@ -87,8 +87,7 @@
 #        "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP.
 #        "x86" - matches to the NDK ABI with the same name.
 #            See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
-#        "mips" - matches to the NDK ABI with the same name
-#            (It is not tested on real devices by the authos of this toolchain)
+#        "mips" - matches to the NDK ABI with the same name.
 #            See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
 #
 #    ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for.
@@ -292,6 +291,18 @@
 #   - April 2013
 #     [+] support non-release NDK layouts (from Linaro git and Android git)
 #     [~] automatically detect if explicit link to crtbegin_*.o is needed
+#   - June 2013
+#     [~] fixed stl include path for standalone toolchain made by NDK >= r8c
+#   - July 2013
+#     [+] updated for NDK r9
+#   - November 2013
+#     [+] updated for NDK r9b
+#   - December 2013
+#     [+] updated for NDK r9c
+#   - January 2014
+#     [~] fix copying of shared STL
+#   - April 2014
+#     [+] updated for NDK r9d
 # ------------------------------------------------------------------------------

 cmake_minimum_required( VERSION 2.6.3 )
@@ -318,7 +329,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} -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
+set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r9d -r9c -r9b -r9 -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 )
@@ -464,7 +475,7 @@

 # detect current host platform
-if( NOT DEFINED ANDROID_NDK_HOST_X64 AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
+if( NOT DEFINED ANDROID_NDK_HOST_X64 AND (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64" OR CMAKE_HOST_APPLE) )
  set( ANDROID_NDK_HOST_X64 1 CACHE BOOL "Try to use 64-bit compiler toolchain" )
  mark_as_advanced( ANDROID_NDK_HOST_X64 )
 endif()
@@ -484,9 +495,7 @@
  message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" )
 endif()

-# CMAKE_HOST_SYSTEM_PROCESSOR on MacOS X always says i386 on Intel platform
-# So we do not trust ANDROID_NDK_HOST_X64 on Apple hosts
-if( NOT ANDROID_NDK_HOST_X64 AND NOT CMAKE_HOST_APPLE)
+if( NOT ANDROID_NDK_HOST_X64 )
  set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} )
 endif()

@@ -634,30 +643,27 @@

 macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __toolchain_subpath )
  foreach( __toolchain ${${__availableToolchainsLst}} )
-  # Skip renderscript folder. It's not C++ toolchain
-  if (NOT ${__toolchain} STREQUAL "renderscript")
-   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}" )
+  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_PATH}/${__gcc_toolchain}${__toolchain_subpath}" )
+  if( __machine )
+   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()
-   __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" )
-   if( __machine )
-    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}" )
-    list( APPEND ${__availableToolchainsVar} "${__toolchain}" )
-   endif()
-   unset( __gcc_toolchain )
-  endif()
+   list( APPEND __availableToolchainMachines "${__machine}" )
+   list( APPEND __availableToolchainArchs "${__arch}" )
+   list( APPEND __availableToolchainCompilerVersions "${__version}" )
+   list( APPEND ${__availableToolchainsVar} "${__toolchain}" )
+  endif()
+  unset( __gcc_toolchain )
  endforeach()
 endmacro()

@@ -687,6 +693,7 @@
   endif()
   __LIST_FILTER( __availableToolchainsLst "^[.]" )
   __LIST_FILTER( __availableToolchainsLst "llvm" )
+  __LIST_FILTER( __availableToolchainsLst "renderscript" )
   __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}" )
@@ -975,7 +982,11 @@
  set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" )

  if( NOT ANDROID_STL STREQUAL "none" )
-  set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" )
+  set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/include/c++/${ANDROID_COMPILER_VERSION}" )
+  if( NOT EXISTS "${ANDROID_STL_INCLUDE_DIRS}" )
+   # old location ( pre r8c )
+   set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" )
+  endif()
   if( ARMEABI_V7A AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" )
    list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" )
   elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" )
@@ -1130,15 +1141,7 @@
 # case of shared STL linkage
 if( ANDROID_STL MATCHES "shared" AND DEFINED __libstl )
  string( REPLACE "_static.a" "_shared.so" __libstl "${__libstl}" )
- if( NOT _CMAKE_IN_TRY_COMPILE AND __libstl MATCHES "[.]so$" )
-  get_filename_component( __libstlname "${__libstl}" NAME )
-  execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess )
-  if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}")
-   message( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" )
-  endif()
-  unset( __fileCopyProcess )
-  unset( __libstlname )
- endif()
+ # TODO: check if .so file exists before the renaming
 endif()

@@ -1503,7 +1506,8 @@

 # 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}" )
+get_filename_component(__android_install_path "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ABSOLUTE) # avoid CMP0015 policy warning
+link_directories( "${__android_install_path}" )

 # detect if need link crtbegin_so.o explicitly
 if( NOT DEFINED ANDROID_EXPLICIT_CRT_LINK )
@@ -1554,6 +1558,18 @@
  endif()
  set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )
 endif()
+
+# copy shaed stl library to build directory
+if( NOT _CMAKE_IN_TRY_COMPILE AND __libstl MATCHES "[.]so$" )
+ get_filename_component( __libstlname "${__libstl}" NAME )
+ execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess )
+ if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}")
+  message( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" )
+ endif()
+ unset( __fileCopyProcess )
+ unset( __libstlname )
+endif()
+

 # set these global flags for cmake client scripts to change behavior
 set( ANDROID True )
@@ -1663,6 +1679,19 @@
 endif()

+# force cmake to produce / instead of \ in build commands for Ninja generator
+if( CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_HOST_WIN32 )
+ # it is a bad hack after all
+ # CMake generates Ninja makefiles with UNIX paths only if it thinks that we are going to build with MinGW
+ set( CMAKE_COMPILER_IS_MINGW TRUE ) # tell CMake that we are MinGW
+ set( CMAKE_CROSSCOMPILING TRUE )    # stop recursion
+ enable_language( C )
+ enable_language( CXX )
+ # unset( CMAKE_COMPILER_IS_MINGW ) # can't unset because CMake does not convert back-slashes in response files without it
+ unset( MINGW )
+endif()
+
+
 # set some obsolete variables for backward compatibility
 set( ANDROID_SET_OBSOLETE_VARIABLES ON CACHE BOOL "Define obsolete Andrid-specific cmake variables" )
 mark_as_advanced( ANDROID_SET_OBSOLETE_VARIABLES )
@@ -1717,7 +1746,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, r8e; set only for NDK
+#   ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d, r8e, r9, r9b, r9c, r9d; 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


Add support for all NDK runtimes

Add support for all NDK runtimes

--- android/android.toolchain.cmake
+++ android/android.toolchain.cmake
@@ -82,6 +82,35 @@
 #      obsolete variables which were used by previous versions of this file for
 #      backward compatibility.
 #
+#    ANDROID_STL=gnustl_static - specify the runtime to use.
+#
+#      Possible values are:
+#        none           -> Do not configure the runtime.
+#        system         -> Use the default minimal system C++ runtime library.
+#                          Implies -fno-rtti -fno-exceptions.
+#        system_re      -> Use the default minimal system C++ runtime library.
+#                          Implies -frtti -fexceptions.
+#        gabi++_static  -> Use the GAbi++ runtime as a static library.
+#                          Implies -frtti -fno-exceptions.
+#                          Available for NDK r7 and newer.
+#        gabi++_shared  -> Use the GAbi++ runtime as a shared library.
+#                          Implies -frtti -fno-exceptions.
+#                          Available for NDK r7 and newer.
+#        stlport_static -> Use the STLport runtime as a static library.
+#                          Implies -fno-rtti -fno-exceptions for NDK before r7.
+#                          Implies -frtti -fno-exceptions for NDK r7 and newer.
+#        stlport_shared -> Use the STLport runtime as a shared library.
+#                          Implies -fno-rtti -fno-exceptions for NDK before r7.
+#                          Implies -frtti -fno-exceptions for NDK r7 and newer.
+#        gnustl_static  -> Use the GNU STL as a static library.
+#                          Implies -frtti -fexceptions.
+#        gnustl_shared  -> Use the GNU STL as a shared library.
+#                          Implies -frtti -fno-exceptions.
+#                          Available for NDK r7b and newer.
+#
+#    ANDROID_STL_FORCE_FEATURES=ON - turn rtti and exceptions support based on
+#      chosen runtime. If disabled, then the user is responsible for settings
+#      these options.
 #
 #  What?:
 #    android-cmake toolchain searches for NDK/toolchain in the following order:
@@ -338,18 +367,6 @@
  endif()
 endmacro()

-macro( __COPY_IF_DIFFERENT _source _destination )
- execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_source}" "${_destination}" RESULT_VARIABLE __fileCopyProcess )
- if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${_destination}")
-  message( SEND_ERROR "Failed copying of ${_source} to the ${_destination}" )
- endif()
- unset( __fileCopyProcess )
-endmacro()
-
-
-# stl version: by default gnustl_static will be used
-set( ANDROID_USE_STLPORT FALSE CACHE BOOL "Experimental: use stlport_static instead of gnustl_static")
-mark_as_advanced( ANDROID_USE_STLPORT )

 # fight against cygwin
 set( ANDROID_FORBID_SYGWIN TRUE CACHE BOOL "Prevent cmake from working under cygwin and using cygwin tools")
@@ -676,27 +693,149 @@
  set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
 endif()

-# setup paths
+# 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" )
+set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" )
+
+if(NOT _CMAKE_IN_TRY_COMPILE)
+ if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" )
+  set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" )
+ else()
+  set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" )
+ endif()
+ set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )
+endif()
+
+# runtime choice (STL, rtti, exceptions)
+if( NOT ANDROID_STL )
+ if( DEFINED ANDROID_USE_STLPORT )
+  if( ANDROID_USE_STLPORT )
+   set( ANDROID_STL stlport_static )
+  endif()
+  message( WARNING "You are using an obsolete variable ANDROID_USE_STLPORT to select the STL. Use -DANDROID_STL=stlport_static instead." )
+ endif()
+ if( NOT ANDROID_STL )
+  set( ANDROID_STL gnustl_static )
+ endif()
+endif()
+set( ANDROID_STL "${ANDROID_STL}" CACHE STRING "C++ runtime" )
+set( ANDROID_STL_FORCE_FEATURES ON CACHE BOOL "automatically configure rtti and exceptions support based on C++ runtime" )
+mark_as_advanced( ANDROID_STL ANDROID_STL_FORCE_FEATURES )
+
+if( NOT "${ANDROID_STL}" MATCHES "^(none|system|system_re|gabi\\+\\+_static|gabi\\+\\+_shared|stlport_static|stlport_shared|gnustl_static|gnustl_shared)$")
+ message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\".
+The possible values are:
+  none           -> Do not configure the runtime.
+  system         -> Use the default minimal system C++ runtime library.
+  system_re      -> Same as system but with rtti and exceptions.
+  gabi++_static  -> Use the GAbi++ runtime as a static library.
+  gabi++_shared  -> Use the GAbi++ runtime as a shared library.
+  stlport_static -> Use the STLport runtime as a static library.
+  stlport_shared -> Use the STLport runtime as a shared library.
+  gnustl_static  -> (default) Use the GNU STL as a static library.
+  gnustl_shared  -> Use the GNU STL as a shared library.
+  " )
+endif()
+
+unset( ANDROID_RTTI )
+unset( ANDROID_EXCEPTIONS )
+unset( ANDROID_STL_INCLUDE_DIRS )
+unset( __libstl )
+unset( __libsupcxx )
+
+# setup paths and STL for NDK
+if( BUILD_WITH_ANDROID_NDK )
+ set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
+ set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" )
+
+ if( ANDROID_STL STREQUAL "none" )
+  # do nothing
+ elseif( ANDROID_STL STREQUAL "system" )
+  set( ANDROID_RTTI             OFF )
+  set( ANDROID_EXCEPTIONS       OFF )
+  set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" )
+ elseif( ANDROID_STL STREQUAL "system_re" )
+  set( ANDROID_RTTI             ON )
+  set( ANDROID_EXCEPTIONS       ON )
+  set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" )
+ elseif( ANDROID_STL MATCHES "gabi" )
+  if( ANDROID_NDK_RELEASE STRLESS "r7" )
+   message( FATAL_ERROR "gabi++ is not awailable in your NDK. You have to upgrade to NDK r7 or newer to use gabi++.")
+  endif()
+  set( ANDROID_RTTI             ON )
+  set( ANDROID_EXCEPTIONS       OFF )
+  set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/gabi++/include" )
+  set( __libstl                 "${ANDROID_NDK}/sources/cxx-stl/gabi++/libs/${ANDROID_NDK_ABI_NAME}/libgabi++_static.a" )
+ elseif( ANDROID_STL MATCHES "stlport" )
+  set( ANDROID_EXCEPTIONS       OFF )
+  if( ANDROID_NDK_RELEASE STRLESS "r7" )
+   set( ANDROID_RTTI            OFF )
+  else()
+   set( ANDROID_RTTI            ON )
+  endif()
+  set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/stlport/stlport" )
+  set( __libstl                 "${ANDROID_NDK}/sources/cxx-stl/stlport/libs/${ANDROID_NDK_ABI_NAME}/libstlport_static.a" )
+ elseif( ANDROID_STL MATCHES "gnustl" )
+  set( ANDROID_EXCEPTIONS       ON )
+  set( ANDROID_RTTI             ON )
+  if( EXISTS "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" )
+   set( __libstl                "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" )
+  else()
+   set( __libstl                "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++" )
+  endif()
+  set( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" )
+  if( EXISTS "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" )
+   set( __libstl                "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" )
+  else()
+   set( __libstl                "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
+  endif()
+ else()
+  message( FATAL_ERROR "Unknown runtime: ${ANDROID_STL}" )
+ endif()
+
+ if( ANDROID_STL STREQUAL "system_re" OR ANDROID_STL MATCHES "gnustl" )
+  # find libsupc++.a
+  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" )
+   if( ARMEABI_V7A )
+    if( ANDROID_FORCE_ARM_BUILD )
+     set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" )
+    else()
+     set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" )
+    endif()
+   elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD )
+    set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" )
+   else()
+    set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" )
+   endif()
+  endif()
+  if( NOT EXISTS "${__libsupcxx}")
+   message( ERROR "Could not find libsupc++.a for a chosen platform. Either your NDK is not supported or is broken.")
+  endif()
+ endif()
+endif()
+
+# setup paths and STL for standalone toolchain
 if( BUILD_WITH_STANDALONE_TOOLCHAIN )
  set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" )
  set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" )
- set( __stlLibPath "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" )
-endif()
-if( BUILD_WITH_ANDROID_NDK )
- set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
- set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" )
- if( ANDROID_USE_STLPORT )
-  set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/stlport/stlport" )
-  set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/stlport/libs/${ANDROID_NDK_ABI_NAME}" )
- else()
-  if( EXISTS "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" )
-   set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/include" )
-   set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}" )
-  else()
-   set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/include" )
-   set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}" )
-  endif()
- endif()
+ #set( __stlLibPath "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" )
+ #TODO: configure stl
+endif()
+
+
+if( ANDROID_STL MATCHES "shared" AND DEFINED __libstl )
+ string( REPLACE "_static.a" "_shared.so" __libstl "${__libstl}" )
+ get_filename_component( __libstlname "${__libstl}" NAME )
+ execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess )
+ if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}")
+  message( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" )
+ endif()
+ unset( __fileCopyProcess )
+ unset( __libstlname )
 endif()

 # ccache support
@@ -737,43 +876,6 @@
   message( FATAL_ERROR "Could not find install_name_tool, please check your installation." )
  endif()
  mark_as_advanced( CMAKE_INSTALL_NAME_TOOL )
-endif()
-
-# export directories
-set( ANDROID_SYSTEM_INCLUDE_DIRS "" )
-set( ANDROID_SYSTEM_LIB_DIRS "" )
-
-# 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" )
-set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" )
-
-if(NOT _CMAKE_IN_TRY_COMPILE)
- if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" )
-  set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" )
- else()
-  set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" )
- endif()
- set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )
-endif()
-
-# includes
-list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_SYSROOT}/usr/include" )
-if( __stlIncludePath AND EXISTS "${__stlIncludePath}" )
- list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlIncludePath}" )
-endif()
-
-# c++ bits includes
-if( __stlLibPath AND EXISTS "${__stlLibPath}/include" )
- list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlLibPath}/include" )
-endif()
-if( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/thumb/bits" )
- list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/thumb" )
-elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" )
- list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" )
-elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" )
- list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" )
-elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/bits" )
- list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" )
 endif()

 # flags and definitions
@@ -831,14 +933,6 @@
  set( _CMAKE_C_FLAGS "" )
 endif()

-if( ANDROID_USE_STLPORT )
- set( _CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions" )
- set( _CMAKE_C_FLAGS "${_CMAKE_C_FLAGS} -fno-exceptions" )
-else()
- set( _CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS} -frtti -fexceptions" )
- set( _CMAKE_C_FLAGS "${_CMAKE_C_FLAGS} -fexceptions" )
-endif()
-
 # release and debug flags
 if( ARMEABI OR ARMEABI_V7A )
  if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 )
@@ -891,50 +985,23 @@
  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" )#sse?
 endif()

+# STL
+if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" )
+ 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> <SONAME_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> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
+ 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}\"")
+ endif()
+ if( EXISTS "${__libsupcxx}" )
+  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libsupcxx}\"")
+  set( CMAKE_CXX_CREATE_SHARED_MODULE  "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libsupcxx}\"")
+ endif()
+endif()
+
 # linker flags
-if( NOT DEFINED __ndklibspath )
- set( __ndklibspath "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ndklibs/${ANDROID_NDK_ABI_NAME}" )
-endif()
-list( APPEND ANDROID_SYSTEM_LIB_DIRS "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )
 set( ANDROID_LINKER_FLAGS "" )

-# STL
-if( ANDROID_USE_STLPORT )
- if( EXISTS "${__stlLibPath}/libstlport_static.a" )
-  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> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> \"${__stlLibPath}/libstlport_static.a\"")
-  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> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> \"${__stlLibPath}/libstlport_static.a\"")
- endif()
-else( ANDROID_USE_STLPORT )
- if( EXISTS "${__stlLibPath}/libgnustl_static.a" )
-  __COPY_IF_DIFFERENT( "${__stlLibPath}/libgnustl_static.a" "${__ndklibspath}/libstdc++.a" )
- elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" )
-  __COPY_IF_DIFFERENT( "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" "${__ndklibspath}/libstdc++.a" )
- elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" )
-  __COPY_IF_DIFFERENT( "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" "${__ndklibspath}/libstdc++.a" )
- elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/thumb/libstdc++.a" )
-  __COPY_IF_DIFFERENT( "${__stlLibPath}/thumb/libstdc++.a" "${__ndklibspath}/libstdc++.a" )
- elseif( EXISTS "${__stlLibPath}/libstdc++.a" )
-  __COPY_IF_DIFFERENT( "${__stlLibPath}/libstdc++.a" "${__ndklibspath}/libstdc++.a" )
- endif()
- if( EXISTS "${__stlLibPath}/libsupc++.a" )
-  __COPY_IF_DIFFERENT( "${__stlLibPath}/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
- elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" )
-  __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
- elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" )
-  __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
- elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" )
-  __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
- elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" )
-  __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
- endif()
- list( APPEND ANDROID_SYSTEM_LIB_DIRS "${__ndklibspath}" )
-endif( ANDROID_USE_STLPORT )
-
-# cleanup for STL search
-unset( __stlIncludePath )
-unset( __stlLibPath )
-
-# other linker flags
 __INIT_VARIABLE( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON )
 set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Show all undefined symbols as linker errors" FORCE )
 mark_as_advanced( ANDROID_NO_UNDEFINED )
@@ -943,7 +1010,7 @@
 endif()

 if (ANDROID_NDK_RELEASE STRLESS "r7")
- # libGLESv2.so in NDK's prior to r7 refers to missing exteranal symbols.
+ # libGLESv2.so in NDK's prior to r7 refers to missing external symbols.
  # So this flag option is required for all projects using OpenGL from native.
  __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES ON )
 else()
@@ -990,8 +1057,8 @@
 set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "linker flags" )
 set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "linker flags" )

-include_directories( SYSTEM ${ANDROID_SYSTEM_INCLUDE_DIRS} )
-link_directories( ${ANDROID_SYSTEM_LIB_DIRS} )
+include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_STL_INCLUDE_DIRS} )
+link_directories( "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )

 # finish flags
 set( ANDROID_CXX_FLAGS    "${ANDROID_CXX_FLAGS}"    CACHE INTERNAL "Extra Android compiler flags" )
@@ -1008,6 +1075,26 @@
  set( CMAKE_EXE_LINKER_FLAGS    "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
 endif()

+# configure rtti
+if( DEFINED ANDROID_RTTI AND ANDROID_STL_FORCE_FEATURES )
+ if( ANDROID_RTTI )
+  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti" )
+ else()
+  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti" )
+ endif()
+endif()
+
+# configure exceptios
+if( DEFINED ANDROID_EXCEPTIONS AND ANDROID_STL_FORCE_FEATURES )
+ if( ANDROID_EXCEPTIONS )
+  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions" )
+  set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" )
+ else()
+  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions" )
+  set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions" )
+ endif()
+endif()
+
 # set these global flags for cmake client scripts to change behavior
 set( ANDROID True )
 set( BUILD_ANDROID True )
@@ -1082,9 +1169,9 @@
 if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
  set( __toolchain_config "")
  foreach( __var NDK_CCACHE ANDROID_ABI ANDROID_FORCE_ARM_BUILD ANDROID_NATIVE_API_LEVEL ANDROID_NO_UNDEFINED
-                ANDROID_SO_UNDEFINED ANDROID_SET_OBSOLETE_VARIABLES LIBRARY_OUTPUT_PATH_ROOT ANDROID_USE_STLPORT
-                ANDROID_FORBID_SYGWIN ANDROID_NDK ANDROID_STANDALONE_TOOLCHAIN ANDROID_FUNCTION_LEVEL_LINKING
-                ANDROID_USE_GOLD_LINKER __ndklibspath )
+                ANDROID_SO_UNDEFINED ANDROID_SET_OBSOLETE_VARIABLES LIBRARY_OUTPUT_PATH_ROOT ANDROID_STL
+                ANDROID_STL_FORCE_FEATURES ANDROID_FORBID_SYGWIN ANDROID_NDK ANDROID_STANDALONE_TOOLCHAIN
+                ANDROID_FUNCTION_LEVEL_LINKING ANDROID_USE_GOLD_LINKER )
   if( DEFINED ${__var} )
    if( "${__var}" MATCHES " ")
     set( __toolchain_config "${__toolchain_config}set( ${__var} \"${${__var}}\" CACHE INTERNAL \"\" )\n" )
@@ -1095,7 +1182,6 @@
  endforeach()
  file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/android.toolchain.config.cmake" "${__toolchain_config}" )
  unset( __toolchain_config )
- unset( __ndklibspath )
 endif()

@@ -1113,7 +1199,6 @@
 #   ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips"
 #   ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14 (depends on NDK version)
 #   ANDROID_SET_OBSOLETE_VARIABLES : ON/OFF
-#   ANDROID_USE_STLPORT : OFF/ON - EXPERIMENTAL!!!
 #   ANDROID_FORBID_SYGWIN : ON/OFF
 #   ANDROID_NO_UNDEFINED : ON/OFF
 #   ANDROID_SO_UNDEFINED : OFF/ON  (default depends on NDK version)
@@ -1121,6 +1206,8 @@
 #   ANDROID_USE_GOLD_LINKER : ON/OFF   (default depends on NDK version and host & target platforms)
 # Variables that takes effect only at first run:
 #   ANDROID_FORCE_ARM_BUILD : ON/OFF
+#   ANDROID_STL : gnustl_static/gnustl_shared/stlport_static/stlport_shared/gabi++_static/gabi++_shared/system_re/system/none
+#   ANDROID_STL_FORCE_FEATURES : ON/OFF
 #   LIBRARY_OUTPUT_PATH_ROOT : <any valid path>
 #   NDK_CCACHE : <path to your ccache executable>
 # Can be set only at the first run:
@@ -1132,6 +1219,7 @@
 #   ARM_TARGET : superseded by ANDROID_ABI
 #   ARM_TARGETS : superseded by ANDROID_ABI (can be set only)
 #   ANDROID_NDK_TOOLCHAIN_ROOT : superseded by ANDROID_STANDALONE_TOOLCHAIN (can be set only)
+#   ANDROID_USE_STLPORT : superseded by ANDROID_STL=stlport_static
 #   ANDROID_LEVEL : superseded by ANDROID_NATIVE_API_LEVEL (completely removed)
 #
 # Primary read-only variables:
@@ -1151,8 +1239,6 @@
 #   ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b; set only for NDK
 #   ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI
 #   ANDROID_SYSROOT : path to the compiler sysroot
-#   ANDROID_SYSTEM_INCLUDE_DIRS
-#   ANDROID_SYSTEM_LIB_DIRS
 #   TOOL_OS_SUFFIX : "" or ".exe" depending on host platform
 # Obsolete:
 #   ARMEABI_NDK_NAME : superseded by ANDROID_NDK_ABI_NAME
@@ -1164,6 +1250,9 @@
 #   ANDROID_TOOLCHAIN_MACHINE_NAME : "arm-linux-androideabi", "arm-eabi" or "i686-android-linux"
 #   ANDROID_TOOLCHAIN_ROOT : path to the top level of toolchain (standalone or placed inside NDK)
 #   ANDROID_SUPPORTED_NATIVE_API_LEVELS : list of native API levels found inside NDK
+#   ANDROID_STL_INCLUDE_DIRS : stl include paths
+#   ANDROID_RTTI : if rtti is enabled by the runtime
+#   ANDROID_EXCEPTIONS : if exceptions are enabled by the runtime
 #
 # Defaults:
 #   ANDROID_DEFAULT_NDK_API_LEVEL


Squashed '3rdparty/github/cmake-utils/' changes from 11a4efae..75363415

75363415 cmake/MyPackageStart.cmake: do not install files where a directory component is "internal"
9936e769 Includes *.hpp for install candidates

git-subtree-dir: 3rdparty/github/cmake-utils
git-subtree-split: 7536341561069edfb5f27ee661fb1dce3f3e0067

--- cmake/MyPackageStart.cmake
+++ cmake/MyPackageStart.cmake
@@ -143,17 +143,33 @@
   # We consider that every .h file in the include directory is to be installed
   # unless it is starting with an '_'.
   #
-  FILE (GLOB_RECURSE _include include/*.h)
+  FILE (GLOB_RECURSE _include include/*.h include/*.hpp)
   FOREACH (_file ${_include} )
+    #
+    # Hiden file
+    #
     GET_FILENAME_COMPONENT(_basename ${_file} NAME)
     STRING (REGEX MATCH "^_" _hiden ${_basename})
     IF ("${_hiden}" STREQUAL "_")
       CONTINUE ()
     ENDIF ()
+    #
+    # Internal file
+    #
+    GET_FILENAME_COMPONENT(_directory ${_file} DIRECTORY)
+    STRING (REGEX MATCH "/internal/?" _internal ${_directory})
+    IF (("${_internal}" STREQUAL "/internal") OR ("${_internal}" STREQUAL "/internal/"))
+      CONTINUE ()
+    ENDIF ()
+    #
+    # Ok
+    #
     FILE (RELATIVE_PATH _relfile ${PROJECT_SOURCE_DIR} ${_file})
     GET_FILENAME_COMPONENT(_dir ${_relfile} DIRECTORY)
-    INSTALL(FILES ${_file} DESTINATION ${_dir} COMPONENT HeaderComponent)
-    SET (_HAVE_HEADERCOMPONENT TRUE CACHE INTERNAL "Have HeaderComponent" FORCE)
+    IF (${packageName}_CAN_INSTALL)
+      INSTALL(FILES ${_file} DESTINATION ${_dir} COMPONENT HeaderComponent)
+      SET (_HAVE_HEADERCOMPONENT TRUE CACHE INTERNAL "Have HeaderComponent" FORCE)
+    ENDIF ()
   ENDFOREACH()
   #
   # Make sure current project have a property associating its default directories


cmake: download tries, customizable download parameters

--- cmake/OpenCVDownload.cmake
+++ cmake/OpenCVDownload.cmake
@@ -22,6 +22,9 @@
 set(OPENCV_DOWNLOAD_LOG "${OpenCV_BINARY_DIR}/CMakeDownloadLog.txt")
 set(OPENCV_DOWNLOAD_WITH_CURL "${OpenCV_BINARY_DIR}/download_with_curl.sh")
 set(OPENCV_DOWNLOAD_WITH_WGET "${OpenCV_BINARY_DIR}/download_with_wget.sh")
+set(OPENCV_DOWNLOAD_TRIES_LIST 1 CACHE STRING "List of download tries") # a list
+set(OPENCV_DOWNLOAD_PARAMS INACTIVITY_TIMEOUT 60 TIMEOUT 600 CACHE STRING "Download parameters to be passed to file(DOWNLAOD ...)")
+mark_as_advanced(OPENCV_DOWNLOAD_TRIES_LIST OPENCV_DOWNLOAD_PARAMS)

 # Init download cache directory and log file and helper scripts
 if(NOT EXISTS "${OPENCV_DOWNLOAD_PATH}")
@@ -154,11 +157,17 @@
   # Download
   if(NOT EXISTS "${CACHE_CANDIDATE}")
     ocv_download_log("#cmake_download \"${CACHE_CANDIDATE}\" \"${DL_URL}\"")
-    file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}"
-         INACTIVITY_TIMEOUT 60
-         TIMEOUT 600
-         STATUS status
-         LOG __log)
+    foreach(try ${OPENCV_DOWNLOAD_TRIES_LIST})
+      ocv_download_log("#try ${try}")
+      file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}"
+           STATUS status
+           LOG __log
+           ${OPENCV_DOWNLOAD_PARAMS})
+      if(status EQUAL 0)
+        break()
+      endif()
+      message(STATUS "Try ${try} failed")
+    endforeach()
     if(NOT OPENCV_SKIP_FILE_DOWNLOAD_DUMP)  # workaround problem with old CMake versions: "Invalid escape sequence"
       string(LENGTH "${__log}" __log_length)
       if(__log_length LESS 65536)


Fix badly-formatted comment.

Fix badly-formatted comment.

--- cmake/external_rules.cmake
+++ cmake/external_rules.cmake
@@ -167,7 +167,7 @@
         set(CMAKE_SUB_CONFIGURE_OPTIONS ${CMAKE_SUB_CONFIGURE_OPTIONS}
             -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded)
       endif()
-    else()  // dynamic (DLL) runtime
+    else()  # dynamic (DLL) runtime
       set(CMAKE_SUB_CONFIGURE_OPTIONS ${CMAKE_SUB_CONFIGURE_OPTIONS}
           -DCMAKE_C_FLAGS_RELEASE="/MD"
           -DCMAKE_CXX_FLAGS_RELEASE="/MD"


also passing through generator

also passing through generator

--- cmake/external_rules.cmake
+++ cmake/external_rules.cmake
@@ -64,6 +64,7 @@
   execute_process(
     COMMAND
       ${ENV_COMMAND} ${CMAKE_COMMAND}
+      -G ${CMAKE_GENERATOR}
       -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
       -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
       -DCMAKE_INSTALL_PREFIX=${FIREBASE_INSTALL_DIR}


update: tell sinsp to use bundled openssl

Co-authored-by: Lorenzo Fontana <638e8f0171575864326f06d2a5f8e72287427b15@linux.com>
Signed-off-by: Leonardo Di Donato <2012e0ca99d70aa6c893822ff73002216e5dba72@gmail.com>

--- cmake/modules/sysdig.cmake
+++ cmake/modules/sysdig.cmake
@@ -43,12 +43,11 @@
 add_subdirectory("${SYSDIG_SOURCE_DIR}/userspace/libsinsp" "${PROJECT_BINARY_DIR}/userspace/libsinsp")
 add_dependencies(sinsp tbb b64 luajit)

-# explicitly force this dependency to use the system OpenSSL
-set(USE_BUNDLED_OPENSSL OFF)
-
 # explicitly disable the tests of this dependency
 set(CREATE_TEST_TARGETS OFF)

 if(USE_BUNDLED_DEPS)
   add_dependencies(scap grpc curl jq)
+  # explicitly force this dependency to use the system OpenSSL
+  set(USE_BUNDLED_OPENSSL ON)
 endif()


match SOVERSION with VERSION_MAJOR

match SOVERSION with VERSION_MAJOR

--- cmake/ospray_version.cmake
+++ cmake/ospray_version.cmake
@@ -17,7 +17,7 @@
 set(OSPRAY_VERSION_MAJOR 2)
 set(OSPRAY_VERSION_MINOR 0)
 set(OSPRAY_VERSION_PATCH 0)
-set(OSPRAY_SOVERSION 1)
+set(OSPRAY_SOVERSION 2)
 set(OSPRAY_VERSION_GITHASH 0)
 set(OSPRAY_VERSION_NOTE "alpha")


reverting iostreams for now until we find a solution (installer)

git-svn-id: e7ea667a1d39a4453c4efcc4ba7bca3d620c3f19@1331 a9d63959-f2ad-4865-b262-bf0e56cfafb6

--- cmake/pcl_find_boost.cmake
+++ cmake/pcl_find_boost.cmake
@@ -4,7 +4,7 @@
   set(Boost_USE_STATIC_LIBS ON)
 endif(NOT PCL_SHARED_LIBS OR WIN32)

-find_package(Boost 1.40.0 COMPONENTS system filesystem thread date_time iostreams)
+find_package(Boost 1.40.0 COMPONENTS system filesystem thread date_time)

 if(Boost_FOUND)
   # Obtain diagnostic information about Boost's automatic linking outputted


Translation for razor-sesion

Translation for razor-sesion

--- cmake/qtxdgTranslate.cmake
+++ cmake/qtxdgTranslate.cmake
@@ -149,5 +149,5 @@
     install(FILES ${_qmFilesLocal} DESTINATION ${_installDir})

     set(${_qmFiles} ${_qmFilesLocal} PARENT_SCOPE)
-endfunction(razor_translate_ts)
+endfunction(qtxdg_translate_ts)


matching cyclus find cyclus

matching cyclus find cyclus

--- cmake/FindCyclus.cmake
+++ cmake/FindCyclus.cmake
@@ -45,6 +45,7 @@
 # Look for the header files
 FIND_PATH(CYCLUS_CORE_SHARE_DIR cyclus.rng.in
   HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus"
+        "${CYCLUS_ROOT_DIR}/share" "${CYCLUS_ROOT_DIR}/share/cyclus"
   /usr/local/cyclus /opt/local/cyclus
   PATH_SUFFIXES cyclus/share share)


removed --recursive option when cloning libigl, itn't required anymore.

--- cmake/FindLIBIGL.cmake
+++ cmake/FindLIBIGL.cmake
@@ -28,7 +28,7 @@

 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(LIBIGL
-    "\nlibigl not found --- You can download it using:\n\tgit clone --recursive https://github.com/libigl/libigl.git ${CMAKE_SOURCE_DIR}/../libigl"
+    "\nlibigl not found --- You can download it using:\n\tgit clone https://github.com/libigl/libigl.git ${CMAKE_SOURCE_DIR}/../libigl"
     LIBIGL_INCLUDE_DIR)
 mark_as_advanced(LIBIGL_INCLUDE_DIR)


(only) include internals when phonon_add_executable macro is not present

this increases compatibility between phonon <4.7 and >=4.7. for <4.7 the
internals will not be included (as they are already present), and for
>=4.7 they will be included.

note that this also prevents general double-inclusion, which is why it uses
the macro check over a version check. for phonon5 we should find a better
solution though.

--- cmake/FindPhonon.cmake
+++ cmake/FindPhonon.cmake
@@ -1,6 +1,6 @@
 # Find Phonon

-# Copyright (c) 2010, Harald Sitter <sitter@kde.org>
+# Copyright (c) 2010-2013, Harald Sitter <sitter@kde.org>
 # Copyright (c) 2011, Alexander Neundorf <neundorf@kde.org>
 #
 # Redistribution and use is allowed according to the terms of the BSD license.
@@ -10,7 +10,11 @@

 if(PHONON_BUILDSYSTEM_DIR)
     set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PHONON_BUILDSYSTEM_DIR})
-    include(${PHONON_BUILDSYSTEM_DIR}/FindPhononInternal.cmake )
+    # Prevent double-include of internals, and make sure they are included
+    # In Phonon <4.7 the internals were auto-included, in >=4.7 they are not.
+    if(NOT COMMAND phonon_add_executable)
+        include(${PHONON_BUILDSYSTEM_DIR}/FindPhononInternal.cmake )
+    endif()
 endif()

 include(FindPackageHandleStandardArgs)


fix #199: Export liblbfgs target

fix #199: Export liblbfgs target

--- CMake/Config/Depends.cmake
+++ CMake/Config/Depends.cmake
@@ -70,12 +70,18 @@
   basis_check_if_package_is_needed_by_modules(is_needed LibLBFGS)
   if (is_needed AND EXISTS "${LibLBFGS_SOURCE_DIR}/CMakeLists.txt")
     message(STATUS "Configuring module ThirdParty/LBFGS...")
-    set(LibLBFGS_EXPORT_NAME         MIRTK)
+    set(LibLBFGS_TARGET_NAME         liblbfgs)
     set(LibLBFGS_INSTALL_STATIC_LIBS TRUE) # needed because of CMake install(EXPORT)
+    basis_add_export_target(export_args ${LibLBFGS_TARGET_NAME} FALSE ${LibLBFGS_INSTALL_STATIC_LIBS})
+    if (export_args)
+      list(GET export_args 1 LibLBFGS_EXPORT_NAME)
+    else ()
+      set(LibLBFGS_EXPORT_NAME)
+    endif ()
     add_subdirectory("${LibLBFGS_SOURCE_DIR}" "${MIRTK_BINARY_DIR}/ThirdParty/LBFGS")
     set(LibLBFGS_FOUND       TRUE)
     set(LibLBFGS_INCLUDE_DIR "${LibLBFGS_SOURCE_DIR}/include")
-    set(LibLBFGS_LIBRARIES   liblbfgs)
+    set(LibLBFGS_LIBRARIES   ${LibLBFGS_TARGET_NAME})
     set(LibLBFGS_DIR        "${MIRTK_BINARY_DIR}/ThirdParty/LBFGS")
     message(STATUS "Configuring module ThirdParty/LBFGS... - done")
   endif ()


Increment version to 3.1.2

Increment version to 3.1.2

--- CMakeModules/Version.cmake
+++ CMakeModules/Version.cmake
@@ -3,7 +3,7 @@
 #
 SET(AF_VERSION_MAJOR "3")
 SET(AF_VERSION_MINOR "1")
-SET(AF_VERSION_PATCH "1")
+SET(AF_VERSION_PATCH "2")

 SET(AF_VERSION "${AF_VERSION_MAJOR}.${AF_VERSION_MINOR}.${AF_VERSION_PATCH}")
 SET(AF_API_VERSION_CURRENT ${AF_VERSION_MAJOR}${AF_VERSION_MINOR})


Promote certain warnings to errors

Promote certain warnings to errors


Second try to make find_*-work on all platforms.

--- src/cmake/Modules/FindLibClangmm.cmake
+++ src/cmake/Modules/FindLibClangmm.cmake
@@ -4,7 +4,9 @@

 find_package(PkgConfig)

-find_path(LCL_INCLUDE_DIR clangmm.h)
+find_path(LCL_INCLUDE_DIR clangmm.h
+ PATH_SUFFIXES libclangmm
+)

 find_library(LCL_LIBRARY NAMES clangmm)