Output config files in dir with plugin shared libraries.

--- Plugins/PluginTemplate.cmake
+++ Plugins/PluginTemplate.cmake
@@ -20,12 +20,12 @@
 if(WIN32)
 	string(REGEX REPLACE "-D" "/D" WIN_DEFS "${DEFS}")
 	string(REGEX REPLACE ";" " " WIN_DEFS "${WIN_DEFS}")
-	FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_config.txt" "${PROJECT_ID}\n${INCLUDE_DIRS};\n${LINK_DIRS_DEBUG};${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/Debug\n${LINK_DIRS_RELEASE}${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/RelWithDebInfo;\n/DPROJECT_BUILD_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\" ${WIN_DEFS} /DPLUGIN_NAME=${PROJECT_NAME} /FI\"EagleLib/Detail/PluginExport.hpp\"")
+	FILE(WRITE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/Debug/${PROJECT_NAME}_config.txt" "${PROJECT_ID}\n${INCLUDE_DIRS};\n${LINK_DIRS_DEBUG};${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/Debug\n${LINK_DIRS_RELEASE}${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/RelWithDebInfo;\n/DPROJECT_BUILD_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\" ${WIN_DEFS} /DPLUGIN_NAME=${PROJECT_NAME} /FI\"EagleLib/Detail/PluginExport.hpp\"")
+	FILE(WRITE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/RelWithDebInfo/${PROJECT_NAME}_config.txt" "${PROJECT_ID}\n${INCLUDE_DIRS};\n${LINK_DIRS_DEBUG};${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/Debug\n${LINK_DIRS_RELEASE}${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/RelWithDebInfo;\n/DPROJECT_BUILD_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\" ${WIN_DEFS} /DPLUGIN_NAME=${PROJECT_NAME} /FI\"EagleLib/Detail/PluginExport.hpp\"")
 else(WIN32)
-	FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_config.txt" "${PROJECT_ID}\n${INCLUDE_DIRS};\n${LINK_DIRS_DEBUG};${LINK_DIRS}\n${LINK_DIRS_RELEASE};${LINK_DIRS}\n-DPROJECT_BUILD_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\" ${DEFS} -DPLUGIN_NAME=${PROJECT_NAME} -include \"EagleLib/Detail/PluginExport.hpp\"")
+	FILE(WRITE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PROJECT_NAME}_config.txt" "${PROJECT_ID}\n${INCLUDE_DIRS};\n${LINK_DIRS_DEBUG};${LINK_DIRS}\n${LINK_DIRS_RELEASE};${LINK_DIRS}\n-DPROJECT_BUILD_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\" ${DEFS} -DPLUGIN_NAME=${PROJECT_NAME} -include \"EagleLib/Detail/PluginExport.hpp\"")
 endif(WIN32)

-#ADD_DEFINITIONS(-DPROJECT_BUILD_DIR="${CMAKE_CURRENT_BINARY_DIR}")
 ADD_DEFINITIONS(-DPROJECT_CONFIG_FILE=\"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_config.txt\")
 ADD_DEFINITIONS(-DPLUGIN_NAME=${PROJECT_NAME})


CMake: Added OGRE_HOME/include/OGRE if using external OGRE_HOME

--- CMakeModules/ConfigurePackages.cmake
+++ CMakeModules/ConfigurePackages.cmake
@@ -163,6 +163,7 @@
         add_definitions(-DUSE_D3D9_SUBSURFACE_BLIT)
         include_directories($ENV{OGRE_HOME})
         include_directories($ENV{OGRE_HOME}/include)
+        include_directories($ENV{OGRE_HOME}/include/OGRE)
         link_directories($ENV{OGRE_HOME}/lib)
     endif()
 endmacro (configure_ogre)


Fix typo in previous.

Fix typo in previous.

--- CMakeModules/ConfigurePackages.cmake
+++ CMakeModules/ConfigurePackages.cmake
@@ -457,7 +457,7 @@
     if ("$ENV{BULLET_DIR}" STREQUAL "")
        if (WIN32)
           set(BULLET_DIR ${ENV_NAALI_DEP_PATH}/Bullet)
-       else # todo: This should be temporary? Always just use the above directory.
+       else() # todo: This should be temporary? Always just use the above directory.
           set(BULLET_DIR ${ENV_NAALI_DEP_PATH}/bullet-2.77)
        endif()
     else()


style: reformat cmake

style: reformat cmake

--- scripts/cmake/ElektraPackaging.cmake
+++ scripts/cmake/ElektraPackaging.cmake
@@ -1,7 +1,7 @@
 # ~~~
 # check_component_dependencies
 #
-# check and excludes a component from packaging if
+# check and excludes a component from packaging if
 # the plugin/binding/tool the component depends on
 # is missing
 #
@@ -11,15 +11,15 @@
 # BINDING          whether the dependency is a binding
 # TOOL             whether the dependency is a tool
 # ADDITIONAL_DEPENDENCIES additional dependencies if the component
-#				          has multiple dependencies
+# 				          has multiple dependencies
 # ~~~
 macro (check_component_dependencies dependency_name component_name)
 	cmake_parse_arguments (
-			ARG
-			"PLUGIN;BINDING;TOOL" # optional keywords
-			"" # one value keywords
-			"ADDITIONAL_DEPENDENCIES" # multi value keywords
-			${ARGN})
+		ARG
+		"PLUGIN;BINDING;TOOL" # optional keywords
+		"" # one value keywords
+		"ADDITIONAL_DEPENDENCIES" # multi value keywords
+		${ARGN})

 	set (TMP_DEPENDENCY_NAMES ${dependency_name})
 	if (ARG_ADDITIONAL_DEPENDENCIES)
@@ -29,7 +29,7 @@
 	set (TMP_UNFULFILLED_DEPENDENCIES "")

 	foreach (name ${TMP_DEPENDENCY_NAMES})
-
+
 		if (ARG_PLUGIN)
 			if (NOT ${name} IN_LIST ADDED_PLUGINS)
 				set (TMP_DEPENDENCY_TYPE "plugin")
@@ -53,22 +53,27 @@
 	endforeach ()

 	list (LENGTH TMP_UNFULFILLED_DEPENDENCIES UNFULFILLED_DEPENDENCIES_AMOUNT)
-	list (LENGTH TMP_DEPENDENCY_NAMES EXPECTED_DEPENDENCIES_AMOUNT)
+	list (LENGTH TMP_DEPENDENCY_NAMES EXPECTED_DEPENDENCIES_AMOUNT)
 	if (${UNFULFILLED_DEPENDENCIES_AMOUNT} GREATER 1)
 		set (TMP_DEPENDENCY_TYPE "${TMP_DEPENDENCY_TYPE}s")
 	endif ()
 	string (REPLACE ";" ", " TMP_UNFULFILLED_DEPENDENCIES_STR "${TMP_UNFULFILLED_DEPENDENCIES}")
 	if (TMP_UNFULFILLED_DEPENDENCIES AND ${UNFULFILLED_DEPENDENCIES_AMOUNT} EQUAL ${EXPECTED_DEPENDENCIES_AMOUNT})
 		# all dependencies of component are missing
-		message (STATUS "Exclude component ${component_name} because ${TMP_UNFULFILLED_DEPENDENCIES_STR} ${TMP_DEPENDENCY_TYPE} excluded.")
+		message (
+			STATUS
+				"Exclude component ${component_name} because ${TMP_UNFULFILLED_DEPENDENCIES_STR} ${TMP_DEPENDENCY_TYPE} excluded."
+		)
 		list (APPEND EXCLUDED_COMPONENTS ${component_name})
 	elseif (TMP_UNFULFILLED_DEPENDENCIES AND ${UNFULFILLED_DEPENDENCIES_AMOUNT} LESS ${EXPECTED_DEPENDENCIES_AMOUNT})
 		# at least one but not all dependencies of a component are missing
-		message (STATUS "Component ${component_name} is missing ${TMP_UNFULFILLED_DEPENDENCIES_STR} ${TMP_DEPENDENCY_TYPE}. This package will still be generated.")
-	endif ()
-
+		message (
+			STATUS
+				"Component ${component_name} is missing ${TMP_UNFULFILLED_DEPENDENCIES_STR} ${TMP_DEPENDENCY_TYPE}. This package will still be generated."
+		)
+	endif ()
+
 endmacro (check_component_dependencies)
-

 set (PACKAGE_URL "https://www.libelektra.org/")
 set (PACKAGE_BUGREPORT "https://bugs.libelektra.org/")
@@ -208,12 +213,12 @@
 	set (CPACK_COMPONENT_LIBELEKTRA4-AUGEAS_DISPLAY_NAME "libelektra4-augeas")
 	set (CPACK_COMPONENT_LIBELEKTRA4-AUGEAS_DESCRIPTION "This package contains the 'augeas' plugin.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-AUGEAS_DEPENDS "libelektra4")
-	check_component_dependencies(augeas libelektra4-augeas PLUGIN)
+	check_component_dependencies (augeas libelektra4-augeas PLUGIN)

 	set (CPACK_COMPONENT_LIBELEKTRA4-DBUS_DISPLAY_NAME "libelektra4-dbus")
 	set (CPACK_COMPONENT_LIBELEKTRA4-DBUS_DESCRIPTION "This package contains the 'dbus' plugins.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-DBUS_DEPENDS "libelektra4")
-	check_component_dependencies(dbus libelektra4-dbus PLUGIN)
+	check_component_dependencies (dbus libelektra4-dbus PLUGIN)

 	set (CPACK_COMPONENT_LIBELEKTRA-DEV_DISPLAY_NAME "libelektra-dev")
 	set (CPACK_COMPONENT_LIBELEKTRA-DEV_DESCRIPTION "This package contains the development files for the main Elektra library.")
@@ -222,72 +227,72 @@
 	set (CPACK_COMPONENT_LIBELEKTRA4-ZEROMQ_DISPLAY_NAME "libelektra4-zeromq")
 	set (CPACK_COMPONENT_LIBELEKTRA4-ZEROMQ_DESCRIPTION "This package contains the 'zeromq' plugins.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-ZEROMQ_DEPENDS "libelektra4")
-	check_component_dependencies(zeromqrecv libelektra4-zeromq PLUGIN ADDITIONAL_DEPENDENCIES zeromqsend)
+	check_component_dependencies (zeromqrecv libelektra4-zeromq PLUGIN ADDITIONAL_DEPENDENCIES zeromqsend)

 	set (CPACK_COMPONENT_LIBELEKTRA4-XMLTOOL_DISPLAY_NAME "libelektra4-xmltool")
 	set (CPACK_COMPONENT_LIBELEKTRA4-XMLTOOL_DESCRIPTION "This package contains the 'xmltool' plugin.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-XMLTOOL_DEPENDS "libelektra4")
-	check_component_dependencies(xmltool libelektra4-xmltool PLUGIN)
+	check_component_dependencies (xmltool libelektra4-xmltool PLUGIN)

 	set (CPACK_COMPONENT_LIBELEKTRA4-XERCES_DISPLAY_NAME "libelektra4-xerces")
 	set (CPACK_COMPONENT_LIBELEKTRA4-XERCES_DESCRIPTION "This package contains the 'xerces' plugin.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-XERCES_DEPENDS "libelektra4")
-	check_component_dependencies(xerces libelektra4-xerces PLUGIN)
+	check_component_dependencies (xerces libelektra4-xerces PLUGIN)

 	set (CPACK_COMPONENT_LIBELEKTRA4-YAJL_DISPLAY_NAME "libelektra4-yajl")
 	set (CPACK_COMPONENT_LIBELEKTRA4-YAJL_DESCRIPTION "This package contains the 'yajl' plugin.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-YAJL_DEPENDS "libelektra4")
-	check_component_dependencies(yajl libelektra4-yajl PLUGIN)
+	check_component_dependencies (yajl libelektra4-yajl PLUGIN)

 	set (CPACK_COMPONENT_LIBELEKTRA4-CRYPTO_DISPLAY_NAME "libelektra4-crypto")
 	set (CPACK_COMPONENT_LIBELEKTRA4-CRYPTO_DESCRIPTION "This package contains the crypto plugins.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-CRYPTO_DEPENDS "libelektra4")
-	check_component_dependencies(crypto libelektra4-crypto PLUGIN)
+	check_component_dependencies (crypto libelektra4-crypto PLUGIN)

 	set (CPACK_COMPONENT_LIBELEKTRA4-CURL_DISPLAY_NAME "libelektra4-curl")
 	set (CPACK_COMPONENT_LIBELEKTRA4-CURL_DESCRIPTION "This package contains the 'curlget' plugin.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-CURL_DEPENDS "libelektra4")
-	check_component_dependencies(curlget libelektra4-curl PLUGIN)
+	check_component_dependencies (curlget libelektra4-curl PLUGIN)

 	set (CPACK_COMPONENT_LIBELEKTRA4-JOURNALD_DISPLAY_NAME "libelektra4-journald")
 	set (CPACK_COMPONENT_LIBELEKTRA4-JOURNALD_DESCRIPTION "This package contains the 'journald' plugins.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-JOURNALD_DEPENDS "libelektra4")
-	check_component_dependencies(journald libelektra4-journald PLUGIN)
+	check_component_dependencies (journald libelektra4-journald PLUGIN)

 	set (CPACK_COMPONENT_LIBELEKTRA4-YAMLCPP_DISPLAY_NAME "libelektra4-yamlcpp")
 	set (CPACK_COMPONENT_LIBELEKTRA4-YAMLCPP_DESCRIPTION "This package contains the 'yamlcpp' plugin.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-YAMLCPP_DEPENDS "libelektra4")
-	check_component_dependencies(yamlcpp libelektra4-yamlcpp PLUGIN)
+	check_component_dependencies (yamlcpp libelektra4-yamlcpp PLUGIN)

 	set (CPACK_COMPONENT_LIBELEKTRA4-JAVA_DISPLAY_NAME "libelektra4-java")
 	set (CPACK_COMPONENT_LIBELEKTRA4-JAVA_DESCRIPTION "This package contains the 'jni' plugin.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-JAVA_DEPENDS "libelektra4" "java-elektra")
-	check_component_dependencies(jni libelektra4-java PLUGIN)
+	check_component_dependencies (jni libelektra4-java PLUGIN)

 	set (CPACK_COMPONENT_LIBELEKTRA4-LUA_DISPLAY_NAME "libelektra4-lua")
 	set (CPACK_COMPONENT_LIBELEKTRA4-LUA_DESCRIPTION "This package contains the 'lua' plugin.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-LUA_DEPENDS "libelektra4")
-	check_component_dependencies(lua libelektra4-lua PLUGIN)
+	check_component_dependencies (lua libelektra4-lua PLUGIN)

 	set (CPACK_COMPONENT_JAVA-ELEKTRA_DISPLAY_NAME "java-elektra")
 	set (CPACK_COMPONENT_JAVA-ELEKTRA_DESCRIPTION "This package contains the Java bindings.")
 	set (CPACK_COMPONENT_JAVA-ELEKTRA_DEPENDS "libelektra4")
-	check_component_dependencies(jna java-elektra BINDING)
+	check_component_dependencies (jna java-elektra BINDING)

 	set (CPACK_COMPONENT_LUA-ELEKTRA_DISPLAY_NAME "lua-elektra")
 	set (CPACK_COMPONENT_LUA-ELEKTRA_DESCRIPTION "This package contains the Lua bindings.")
 	set (CPACK_COMPONENT_LUA-ELEKTRA_DEPENDS "libelektra4")
-	check_component_dependencies(lua lua-elektra BINDING)
+	check_component_dependencies (lua lua-elektra BINDING)

 	set (CPACK_COMPONENT_PYTHON3-ELEKTRA_DISPLAY_NAME "python3-elektra")
 	set (CPACK_COMPONENT_PYTHON3-ELEKTRA_DESCRIPTION "This package contains the Python 3 bindings.")
 	set (CPACK_COMPONENT_PYTHON3-ELEKTRA_DEPENDS "libelektra4")
-	check_component_dependencies(python python3-elektra BINDING)
+	check_component_dependencies (python python3-elektra BINDING)

 	set (CPACK_COMPONENT_LIBELEKTRA4-PYTHON_DISPLAY_NAME "libelektra4-python")
 	set (CPACK_COMPONENT_LIBELEKTRA4-PYTHON_DESCRIPTION "This package contains the 'python' plugin.")
 	set (CPACK_COMPONENT_LIBELEKTRA4-PYTHON_DEPENDS "libelektra4" "python3-elektra")
-	check_component_dependencies(python libelektra4-python PLUGIN)
+	check_component_dependencies (python libelektra4-python PLUGIN)

 	set (CPACK_COMPONENT_ELEKTRA-BIN-EXTRA_DISPLAY_NAME "elektra-bin-extra")
 	set (CPACK_COMPONENT_ELEKTRA-BIN-EXTRA_DESCRIPTION
@@ -297,7 +302,7 @@
 	set (CPACK_COMPONENT_ELEKTRA-QT-GUI_DISPLAY_NAME "elektra-qt-gui")
 	set (CPACK_COMPONENT_ELEKTRA-QT-GUI_DESCRIPTION "This package contains a Qt-based graphical interface for Elektra.")
 	set (CPACK_COMPONENT_ELEKTRA-QT-GUI_DEPENDS "libelektra4")
-	check_component_dependencies(qt-gui elektra-qt-gui TOOL)
+	check_component_dependencies (qt-gui elektra-qt-gui TOOL)

 	set (CPACK_COMPONENT_ELEKTRA-TESTS_DISPLAY_NAME "elektra-tests")
 	set (CPACK_COMPONENT_ELEKTRA-TESTS_DESCRIPTION "This package contains the Elektra test suite.")
@@ -307,8 +312,7 @@
 	set (CPACK_COMPONENT_ELEKTRA-DOC_DESCRIPTION "This package contains the API documentation for the Elektra libraries.")

 	set (CPACK_COMPONENT_LIBELEKTRA4-ALL_DISPLAY_NAME "libelektra4-all")
-	set (CPACK_COMPONENT_LIBELEKTRA4-ALL_DESCRIPTION
-	     "This package provides the dependencies for all Elektra packages.")
+	set (CPACK_COMPONENT_LIBELEKTRA4-ALL_DESCRIPTION "This package provides the dependencies for all Elektra packages.")
 	set (
 		CPACK_COMPONENT_LIBELEKTRA4-ALL_DEPENDS
 		"libelektra4"
@@ -339,16 +343,16 @@
 	set (CPACK_COMPONENT_ELEKTRA-MISC_DESCRIPTION "This package contains all files not part of any of the released Elektra packages.")

 	# exclude components for package generation where dependencies are not fulfilled.
-	foreach(component ${EXCLUDED_COMPONENTS})
+	foreach (component ${EXCLUDED_COMPONENTS})
 		list (REMOVE_ITEM PACKAGES ${component})
-	endforeach(component)
+	endforeach (component)
 	# remove libelektra4-all package if a component is excluded
 	if (EXCLUDED_COMPONENTS)
 		list (REMOVE_ITEM PACKAGES libelektra4-all)
 		string (REPLACE ";" ", " EXCLUDED_COMPONENTS_STR "${EXCLUDED_COMPONENTS}")
 		message (STATUS "Excluding libelektra4-all because following components are excluded: ${EXCLUDED_COMPONENTS_STR}".)
 		list (APPEND EXCLUDED_COMPONENTS libelektra4-all)
-	endif()
+	endif ()
 	# For Debian-based distros we want to create DEB packages.
 	if ("${OS_NAME}" MATCHES "Ubuntu|Debian")
 		set (DEBIAN_DBG_PACKAGE_NAMES "")


force static build of Monteverdi on MSVC

--- CMake/External_Monteverdi.cmake
+++ CMake/External_Monteverdi.cmake
@@ -7,7 +7,7 @@
 set(MVD_SB_SRC ${CMAKE_BINARY_DIR}/${proj}/src/${proj})
 set(MVD_SB_BUILD_DIR ${CMAKE_BINARY_DIR}/${proj}/build)

-set(${proj}_DEPENDENCIES OTB)
+set(${proj}_DEPENDENCIES)# OTB)

 if(USE_SYSTEM_FLTK)
   message(STATUS "  Using FLTK system version")
@@ -16,6 +16,10 @@
     list(APPEND ${proj}_DEPENDENCIES FLTK)
 endif()

+set(MVD_SB_BUILD_SHARED ON)
+if(MSVC)
+  set(MVD_SB_BUILD_SHARED OFF)
+endif()

 ExternalProject_Add(${proj}
    PREFIX ${proj}
@@ -26,7 +30,7 @@
    DEPENDS ${${proj}_DEPENDENCIES}
    CMAKE_CACHE_ARGS
     -DCMAKE_BUILD_TYPE:STRING=Release
-    -DBUILD_SHARED_LIBS:BOOL=ON
+    -DBUILD_SHARED_LIBS:BOOL=${MVD_SB_BUILD_SHARED}
     -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
     ${MVD_SB_FLTK_CONFIG}
 )


CMake: windows - make sure that all required DLLS are copied

--- CMake/InstallDependencies.cmake
+++ CMake/InstallDependencies.cmake
@@ -14,9 +14,7 @@
   return()
 endif()

-# TODO - most of this file assumes a common dependencies root folder
-# This is not robust, we should instead source dependencies from their individual locations
-get_filename_component(OGRE_DEP_DIR ${FREETYPE_INCLUDE_DIR}/../../ ABSOLUTE)
+set(OGRE_DEP_DIR ${OGREDEPS_PATH})

 option(OGRE_INSTALL_DEPENDENCIES "Install dependency libs needed for samples" TRUE)
 option(OGRE_COPY_DEPENDENCIES "Copy dependency libs to the build directory" TRUE)
@@ -98,6 +96,10 @@
 		install(FILES DESTINATION lib/release CONFIGURATIONS Release)
 		install(FILES DESTINATION lib/minsizerel CONFIGURATIONS MinSizeRel)
 	endif () # WIN32
+
+    if (EXISTS ${OGRE_DEP_DIR}/bin/)
+        install(DIRECTORY ${OGRE_DEP_DIR}/bin/ DESTINATION bin)
+    endif ()
 endif () # OGRE_INSTALL_DEPENDENCIES

   if(WIN32)
@@ -222,15 +224,12 @@
 if (OGRE_COPY_DEPENDENCIES)

   if (WIN32)
-    # copy the required DLLs to the build directory (configure_file is the only copy-like op I found in CMake)
-	if( (OGRE_BUILD_SAMPLES OR OGRE_BUILD_TESTS) AND NOT (WINDOWS_STORE OR WINDOWS_PHONE) )
-		if(EXISTS "${SDL2_LIBRARY}")
-		  file(COPY ${SDL2_LIBRARY} DESTINATION ${OGRE_BINARY_DIR}/bin/debug)
-		  file(COPY ${SDL2_LIBRARY} DESTINATION ${OGRE_BINARY_DIR}/bin/release)
-		  file(COPY ${SDL2_LIBRARY} DESTINATION ${OGRE_BINARY_DIR}/bin/relwithdebinfo)
-		  file(COPY ${SDL2_LIBRARY} DESTINATION ${OGRE_BINARY_DIR}/bin/minsizerel)
-		endif()
-	endif()
+    # copy the required DLLs to the build directory
+    file(GLOB DLLS ${OGRE_DEP_DIR}/bin/*.dll)
+    file(COPY ${DLLS} DESTINATION ${OGRE_BINARY_DIR}/bin/debug)
+    file(COPY ${DLLS} DESTINATION ${OGRE_BINARY_DIR}/bin/release)
+    file(COPY ${DLLS} DESTINATION ${OGRE_BINARY_DIR}/bin/relwithdebinfo)
+    file(COPY ${DLLS} DESTINATION ${OGRE_BINARY_DIR}/bin/minsizerel)

     if (OGRE_BUILD_PLUGIN_CG)
       if (EXISTS ${Cg_BINARY_DBG} AND EXISTS ${Cg_BINARY_REL})


Add new search path for iOS SDK thanks to Xcode 4.3

--- CMake/Packages/FindiOSSDK.cmake
+++ CMake/Packages/FindiOSSDK.cmake
@@ -9,7 +9,7 @@
 # construct search paths
 set(iOSSDK_PREFIX_PATH ${iOSSDK_HOME} $ENV{iOSSDK_HOME}
   ${OGRE_HOME} $ENV{OGRE_HOME})
-create_search_paths(/Developer/Platforms)
+create_search_paths(/Developer/Platforms /Applications/Xcode.app/Contents/Developer/Platforms)
 # redo search if prefix path changed
 clear_if_changed(iOSSDK_PREFIX_PATH
   iOSSDK_LIBRARY_FWK
@@ -25,7 +25,7 @@

 #findpkg_framework(UIKit)

-find_path(iOSSDK_INCLUDE_DIR iPhoneOS.platform /Developer/Platforms)
+find_path(iOSSDK_INCLUDE_DIR iPhoneOS.platform /Developer/Platforms /Applications/Xcode.app/Contents/Developer/Platforms)

 if (iOSSDK_INCLUDE_DIR)
   unset(iOSSDK_INCLUDE_DIR)


Issue #44: Don't need numpy.

Issue #44: Don't need numpy.

--- CMake/mpAddPythonBindings.cmake
+++ CMake/mpAddPythonBindings.cmake
@@ -52,7 +52,7 @@
 	  # Add this if you want numpy. Depends on your build env.
 	  # I've left it out for now, as cloned projects can decide if they need it.
 	  # It doesn't warrant another top level flag.
-	  list(APPEND MYPROJECT_BOOST_LIBS "numpy${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
+	  # list(APPEND MYPROJECT_BOOST_LIBS "numpy${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
     else()
       list(APPEND MYPROJECT_BOOST_LIBS "python")
     endif()


reapply 4a8388c13e56: MAINT-646 Enable /fp:fast in Visual Studio

--- indra/cmake/00-Common.cmake
+++ indra/cmake/00-Common.cmake
@@ -69,6 +69,7 @@
       /Oy-
       /Zc:wchar_t-
       /arch:SSE2
+      /fp:fast
       )

   # Are we using the crummy Visual Studio KDU build workaround?


Remove unmatched endif

Remove unmatched endif

This addresses a new CMake error with 3.20

--- Testing/CI/Azure/azure.cmake
+++ Testing/CI/Azure/azure.cmake
@@ -122,7 +122,6 @@

 set_from_env(dashboard_cache "CTEST_CACHE" DEFAULT ${_dashboard_cache})

-endif()


Add latest freetype version

Add latest freetype version

--HG--
branch : v1-9

--- CMake/Packages/FindFreetype.cmake
+++ CMake/Packages/FindFreetype.cmake
@@ -31,7 +31,7 @@
   FREETYPE_INCLUDE_DIR
 )

-set(FREETYPE_LIBRARY_NAMES freetype2411 freetype2410 freetype249 freetype248 freetype246 freetype2311 freetype239 freetype238 freetype235 freetype219 freetype)
+set(FREETYPE_LIBRARY_NAMES freetype2412 freetype2411 freetype2410 freetype249 freetype248 freetype246 freetype2311 freetype239 freetype238 freetype235 freetype219 freetype)
 get_debug_names(FREETYPE_LIBRARY_NAMES)

 use_pkgconfig(FREETYPE_PKGC freetype2)


From Björn Blissing, fix for ambiguous defines in Atomic.cpp when compiling with MinGW and GCC

git-svn-id: aa838dfc23441284dd616281de4245daec5d2135@14513 16af8721-9629-0410-8352-f15c8da7e697

--- CMakeModules/CheckAtomicOps.cmake
+++ CMakeModules/CheckAtomicOps.cmake
@@ -143,6 +143,15 @@
           NOT _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC)
                   SET(_OPENTHREADS_ATOMIC_USE_MUTEX 1)
        ENDIF()
+
+
+       # MinGW can set both WIN32_INTERLOCKED and GCC_BUILTINS to true which results in compliation errors
+       IF (_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS AND _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
+          # In this case we prefer the GCC_BUILTINS
+          SET(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS 1)
+          SET(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED 0)
+       ENDIF()
+
     ENDIF()

 ENDIF()


Change directory in main_superbuild

Change directory in main_superbuild

--- CI/main_superbuild.cmake
+++ CI/main_superbuild.cmake
@@ -23,8 +23,6 @@
 # This script is a prototype for the future CI, it may evolve rapidly in a near future
 set (ENV{LANG} "C") # Only ascii output
 get_filename_component(OTB_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} DIRECTORY)
-get_filename_component(CI_PROJ_DIR ${OTB_SOURCE_DIR} DIRECTORY)
-get_filename_component(CI_ROOT_DIR ${CI_PROJ_DIR} DIRECTORY)

 ###########################################################################
 ###########################################################################
@@ -56,7 +54,7 @@
 execute_process(
   COMMAND ${GIT} "clone" "${REMOTE}" "--branch" "${BRANCH_NAME}"
   "--depth" "1" "superbuild-artifact"
-  WORKING_DIRECTORY ${CI_PROJ_DIR}
+  WORKING_DIRECTORY ${OTB_SOURCE_DIR}
   RESULT_VARIABLE clone_res
   OUTPUT_VARIABLE clone_out
   ERROR_VARIABLE clone_err
@@ -77,17 +75,17 @@
 set (CMAKE_COMMAND "cmake")
 execute_process(
   COMMAND ${CMAKE_COMMAND} "-E" "tar" "xf"
-  "${CI_PROJ_DIR}/superbuild-artifact/SuperBuild_Install.tar"
-  WORKING_DIRECTORY ${CI_ROOT_DIR}
+  "${OTB_SOURCE_DIR}/superbuild-artifact/SuperBuild_Install.tar"
+  WORKING_DIRECTORY ${OTB_SOURCE_DIR}
   )

-set( XDK_PATH "${CI_ROOT_DIR}/xdk")
+set( XDK_PATH "${OTB_SOURCE_DIR}/xdk")

 if ( DEBUG )
   if ( EXISTS "${XDK_PATH}")
-    message("Tar file exists at ${XDK_PATH}")
+    message("Xdk folder exists at ${XDK_PATH}")
   else()
-    message("Something went wrong no tar file in ${XDK_PATH}")
+    message("Something went wrong no folder in ${XDK_PATH}")
   endif()
 endif()

@@ -127,10 +125,11 @@
 set( PROJ_LIB "${XDK_PATH}/share" )
 set( CTEST_ENVIRONMENT
 "PATH=${XDK_PATH}/lib:${XDK_PATH}/bin:$ENV{PATH}
-GDAL_DATA= GDAL_DATA
-GEOTIFF_CSV= GEOTIFF_CSV
-PROJ_LIB= PROJ_LIB
 ")
+# It seems that we do not need that
+# GDAL_DATA= GDAL_DATA
+# GEOTIFF_CSV= GEOTIFF_CSV
+# PROJ_LIB= PROJ_LIB

 # Sources are already checked out : do nothing for update
 set(CTEST_GIT_UPDATE_CUSTOM echo No update)


remove missing-brace warning: https://stackoverflow.com/a/13905432

--- source/cmake_modules/CompilationFlags.cmake
+++ source/cmake_modules/CompilationFlags.cmake
@@ -24,7 +24,7 @@
 if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
     # it could be great to remove these warnings, but there is so much :
     # -Wno-shorten-64-to-32 -Wno-sign-conversion -Wno-conversion
-    set(CMAKE_CLANG_WARN_FLAGS "-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-global-constructors -Wno-exit-time-destructors -Wno-documentation -Wno-shadow -Wno-covered-switch-default -Wno-switch-enum -Wno-missing-noreturn -Wno-disabled-macro-expansion -Wno-shorten-64-to-32 -Wno-sign-conversion -Wno-conversion")
+    set(CMAKE_CLANG_WARN_FLAGS "-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-global-constructors -Wno-exit-time-destructors -Wno-documentation -Wno-shadow -Wno-covered-switch-default -Wno-switch-enum -Wno-missing-noreturn -Wno-disabled-macro-expansion -Wno-shorten-64-to-32 -Wno-sign-conversion -Wno-conversion -Wno-missing-braces")
     set(CMAKE_CLANG_COMMON_FLAGS "-std=c++14 -stdlib=libstdc++  -ferror-limit=10 -pthread -ftemplate-depth=1024")
     set(CMAKE_CXX_FLAGS "${CMAKE_CLANG_COMMON_FLAGS} ${CMAKE_CLANG_WARN_FLAGS}")
     set(CMAKE_C_FLAGS "-ferror-limit=10 -I/usr/local/include/c++/v1 -pthread")


PKG: missing dll on windows package

PKG: missing dll on windows package

--- Packaging/prepare_file_list.cmake
+++ Packaging/prepare_file_list.cmake
@@ -86,9 +86,11 @@

   # special case for msvc: ucrtbase.dll must be explicitly vetted.
   # for proj.dll, see Mantis-1424
+  # libEGL needed by Qt 5 at runtime
   if(MSVC)
     list(APPEND file_list "ucrtbase.dll")
     list(APPEND file_list "proj.dll")
+    list(APPEND file_list "libEGL.dll")
   endif()

   set(${file_list_result} ${file_list} PARENT_SCOPE)


Fix epel7 test

Fix epel7 test

--- Modules/CmakeFedoraScript.cmake
+++ Modules/CmakeFedoraScript.cmake
@@ -195,7 +195,7 @@

 IF(CMAKE_SCRIPT_MODE_FILE)
     GET_FILENAME_COMPONENT(CMAKE_FEDORA_SCRIPT_DIR ${CMAKE_SCRIPT_MODE_FILE}
-	DIRECTORY)
+	PATH)
     LIST(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_FEDORA_SCRIPT_DIR}")
 ENDIF()


Fixed URL for submitting tests to Dartboard


Fix unbalanced curly bracket.

Fix unbalanced curly bracket.

	* build-aux/cmake/modules/CPackInfo.cmake: Here.

Signed-off-by: Nicolas Despres <abdeb541ca46f1651c9cc594d44e707056e73d5d@gostai.com>

--- build-aux/cmake/modules/CPackInfo.cmake
+++ build-aux/cmake/modules/CPackInfo.cmake
@@ -47,7 +47,7 @@
 #  set(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
 #  set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
   set(CPACK_NSIS_DISPLAY_NAME
-    "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${CPACK_PACKAGE_DESCRIPTION_SUMMARY")
+    "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
   set(CPACK_NSIS_HELP_LINK ${PROJECT_HELP_LINK})
   set(CPACK_NSIS_URL_INFO_ABOUT ${PROJECT_HOMEPAGE})
   set(CPACK_NSIS_CONTACT ${PROJECT_SUPPORT})


DynLibDep cannot work when cross-compiling.

	* build-aux/cmake/modules/DynLibDep.cmake: Do that.

--- build-aux/cmake/modules/DynLibDep.cmake
+++ build-aux/cmake/modules/DynLibDep.cmake
@@ -242,6 +242,11 @@
   # NOTE: _binary_ might be a target name.
   function(dldep_install binary)

+    if(CMAKE_CROSSCOMPILING)
+      echo("Cannot list dependent dynamic libraries when cross-compiling.")
+      return()
+    endif(CMAKE_CROSSCOMPILING)
+
     include(Dirs)
     if(TARGET ${binary})
       get_target_property(binary_loc ${binary} LOCATION_${CMAKE_BUILD_TYPE})


[CMake] [darwin] [builtins] Add INSTALL_DIR to darwin_lipo_libs

The darwin and macho_embedded libraries get installed to different locations, so we need to feed through an INSTALL_PATH.

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@249199 91177308-0d34-0410-b5e6-96231b3b80d8

--- cmake/Modules/CompilerRTDarwinUtils.cmake
+++ cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -183,7 +183,7 @@
 function(darwin_lipo_libs name)
   cmake_parse_arguments(LIB
     ""
-    "PARENT_TARGET;OUTPUT_DIR"
+    "PARENT_TARGET;OUTPUT_DIR;INSTALL_DIR"
     "LIPO_FLAGS;DEPENDS"
     ${ARGN})
   add_custom_command(OUTPUT ${LIB_OUTPUT_DIR}/lib${name}.a
@@ -197,7 +197,8 @@
     DEPENDS ${LIB_OUTPUT_DIR}/lib${name}.a)
   add_dependencies(${LIB_PARENT_TARGET} ${name})
   install(FILES ${LIB_OUTPUT_DIR}/lib${name}.a
-    DESTINATION ${COMPILER_RT_INSTALL_PATH})
+    DESTINATION ${LIB_INSTALL_DIR})
+  message("LIB_INSTALL_DIR: ${LIB_INSTALL_DIR}")
 endfunction()

 # Filter out generic versions of routines that are re-implemented in
@@ -297,7 +298,8 @@
                       PARENT_TARGET builtins
                       LIPO_FLAGS ${${os}_cc_kext_lipo_flags}
                       DEPENDS ${${os}_cc_kext_libs}
-                      OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+                      OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
+                      INSTALL_DIR ${COMPILER_RT_LIBRARY_INSTALL_DIR})
     endif()
   endforeach()

@@ -308,7 +310,8 @@
                         PARENT_TARGET builtins
                         LIPO_FLAGS ${${os}_builtins_lipo_flags} ${${os}sim_builtins_lipo_flags}
                         DEPENDS ${${os}_builtins_libs} ${${os}sim_builtins_libs}
-                        OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+                        OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
+                        INSTALL_DIR ${COMPILER_RT_LIBRARY_INSTALL_DIR})
     endif()
   endforeach()
   darwin_add_embedded_builtin_libraries()
@@ -339,6 +342,8 @@

   set(DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR
     ${COMPILER_RT_OUTPUT_DIR}/lib/macho_embedded)
+  set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR
+    ${COMPILER_RT_INSTALL_PATH}/lib/macho_embedded)

   set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi")
   set(CFLAGS_armv7em "-target thumbv7-apple-darwin-eabi")
@@ -400,7 +405,8 @@
                     PARENT_TARGET builtins
                     LIPO_FLAGS ${macho_embedded_${lib_suffix}_lipo_flags}
                     DEPENDS ${macho_embedded_${lib_suffix}_libs}
-                    OUTPUT_DIR ${DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR})
+                    OUTPUT_DIR ${DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR}
+                    INSTALL_DIR ${DARWIN_macho_embedded_LIBRARY_INSTALL_DIR})
     endforeach()
   endforeach()
 endfunction()


[CMake] Remove `--test` option from normal gyb invocation in CMake

--- cmake/modules/SwiftHandleGybSources.cmake
+++ cmake/modules/SwiftHandleGybSources.cmake
@@ -38,8 +38,6 @@
       "${options}" "${single_value_args}" "${multi_value_args}" ${ARGN})

   set(gyb_flags
-      "--test" # Run gyb's self-tests whenever we use it.  They're cheap
-               # enough and it keeps us honest.
       ${SWIFT_GYB_FLAGS}
       ${GYB_SINGLE_FLAGS})


Add Arch Linux to the list of supported platforms

--- GNUModules.cmake
+++ GNUModules.cmake
@@ -112,6 +112,8 @@
   set(MODULE_PLATFORM "ubuntu${LSB_RELEASE}-${CMAKE_SYSTEM_PROCESSOR}")
 elseif(LSB_DISTRIBUTOR_ID MATCHES "Scientific")
   set(MODULE_PLATFORM "scientific${LSB_RELEASE}-${CMAKE_SYSTEM_PROCESSOR}")
+elseif(LSB_DISTRIBUTOR_ID MATCHES "Arch")
+  set(MODULE_PLATFORM "arch-${CMAKE_SYSTEM_PROCESSOR}")
 elseif(APPLE)
   set(MODULE_PLATFORM "darwin${CMAKE_SYSTEM_VERSION}-${CMAKE_SYSTEM_PROCESSOR}")
 else()


BUG: Update Meshlib in superbuild

BUG: Update Meshlib in superbuild

git shortlog --no-merges 477e4baf0..9eb4d15ce1e

Jared Vicory (1):
      Fix Windows build errors

--- SuperBuild/External_MeshLib.cmake
+++ SuperBuild/External_MeshLib.cmake
@@ -59,7 +59,7 @@
     )
   ### --- End Project specific additions
   set(${proj}_REPOSITORY "${git_protocol}://github.com/NIRALUser/MeshLib.git")
-  set(${proj}_GIT_TAG 477e4baf00e0b5d285f5d8f43eec77c3da22e8e7)
+  set(${proj}_GIT_TAG 9eb4d15ce1e8f982ba6dd7661abbeb678fe5634a)
   ExternalProject_Add(${proj}
     GIT_REPOSITORY ${${proj}_REPOSITORY}
     GIT_TAG ${${proj}_GIT_TAG}


STYLE: Nightly Date Stamp

STYLE: Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -7,4 +7,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 03)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   09)
+SET(KWSYS_DATE_STAMP_DAY   10)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 10)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   08)
+SET(KWSYS_DATE_STAMP_DAY   09)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 05)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   14)
+SET(KWSYS_DATE_STAMP_DAY   15)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 06)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   22)
+SET(KWSYS_DATE_STAMP_DAY   23)


STYLE: Nightly Date Stamp

STYLE: Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -7,4 +7,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 05)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   09)
+SET(KWSYS_DATE_STAMP_DAY   10)


STYLE: Nightly Date Stamp

STYLE: Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -7,4 +7,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 11)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   29)
+SET(KWSYS_DATE_STAMP_DAY   30)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 03)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   02)
+SET(KWSYS_DATE_STAMP_DAY   03)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -7,4 +7,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 08)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   14)
+SET(KWSYS_DATE_STAMP_DAY   15)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 02)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   16)
+SET(KWSYS_DATE_STAMP_DAY   17)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 03)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   09)
+SET(KWSYS_DATE_STAMP_DAY   10)


STYLE: Nightly Date Stamp

STYLE: Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -7,4 +7,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 03)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   07)
+SET(KWSYS_DATE_STAMP_DAY   08)


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/kwsys/kwsysDateStamp.cmake
+++ Utilities/kwsys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 11)

 # KWSys version date day component.  Format is DD.
-SET(KWSYS_DATE_STAMP_DAY   15)
+SET(KWSYS_DATE_STAMP_DAY   16)


Update tensorflow to v1.3.0

Update tensorflow to v1.3.0

--- tensorflow_cc/cmake/TensorflowBase.cmake
+++ tensorflow_cc/cmake/TensorflowBase.cmake
@@ -3,7 +3,7 @@
 ExternalProject_Add(
   tensorflow_base
   GIT_REPOSITORY http://github.com/tensorflow/tensorflow.git
-  GIT_TAG v1.2.1
+  GIT_TAG v1.3.0
   TMP_DIR "/tmp"
   STAMP_DIR "tensorflow-stamp"
   DOWNLOAD_DIR "tensorflow"


Update hunter gate (0.3.2)

Update hunter gate (0.3.2)

--- HunterGate.cmake
+++ HunterGate.cmake
@@ -14,8 +14,8 @@

 cmake_minimum_required(VERSION 2.8.10)

-set(HUNTER_MINIMUM_VERSION "0.3.1")
-set(HUNTER_MINIMUM_VERSION_HASH da6ec33da5b96e6e74a0e097b3a37f72614049f7)
+set(HUNTER_MINIMUM_VERSION "0.3.2")
+set(HUNTER_MINIMUM_VERSION_HASH 969f2e912be035b4fd1e9cebc26b241737ff85a8)

 # Set HUNTER_ROOT cmake variable to suitable value.
 # Info about variable can be found in HUNTER_ROOT_INFO.


haskell-cmake-improvements: fix rebase issue

--- cmake/Modules/LibAddHaskellPlugin.cmake
+++ cmake/Modules/LibAddHaskellPlugin.cmake
@@ -310,59 +310,6 @@
 		endif (PLUGINPROCESS_FOUND)
 	endif (DEPENDENCY_PHASE)

-	set (SANDBOX_PACKAGEDB "${HASKELL_SHARED_SANDBOX}/${GHC_TARGET_PLATFORM}-ghc-${GHC_VERSION}-packages.conf.d/")
-	set (PLUGIN_LD_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib:${CMAKE_CURRENT_BINARY_DIR}/haskell")
-	set (PLUGIN_ARGS "")
-	if (ARG_TEST_README)
-		list (APPEND PLUGIN_ARGS "TEST_README")
-		list (APPEND PLUGIN_ARGS "TEST_ENVIRONMENT")
-		list (APPEND PLUGIN_ARGS "SANDBOX_PACKAGEDB=${SANDBOX_PACKAGEDB}")
-		list (APPEND PLUGIN_ARGS "LD_LIBRARY_PATH=${PLUGIN_LD_LIBRARY_PATH}")
-		if (ARG_TEST_ENVIRONMENT)
-			list (APPEND PLUGIN_ARGS "${ARG_TEST_ENVIRONMENT}")
-		endif (ARG_TEST_ENVIRONMENT)
-
-		if (ARG_TEST_REQUIRED_PLUGINS)
-			list (APPEND PLUGIN_ARGS "TEST_REQUIRED_PLUGINS")
-			list (APPEND PLUGIN_ARGS "${ARG_TEST_REQUIRED_PLUGINS}")
-		endif (ARG_TEST_REQUIRED_PLUGINS)
-
-	endif (ARG_TEST_README)
-
-	# compile our c wrapper which takes care of invoking the haskell runtime
-	# the actual haskell plugin gets linked in dynamically as a library
-	add_plugin (${target}
-		    SOURCES ${CMAKE_CURRENT_BINARY_DIR}/haskell.h
-			    ${CMAKE_CURRENT_BINARY_DIR}/haskell.c
-		    INCLUDE_DIRECTORIES ${GHC_INCLUDE_DIRS}
-		    LINK_LIBRARIES ${GHC_LIBS}
-		    LINK_ELEKTRA elektra-pluginprocess
-				 "${PLUGIN_ARGS}"
-		    DEPENDS ${target}
-			    c2hs_haskell)
-
-	if (DEPENDENCY_PHASE AND TARGET elektra-${target})
-		set_target_properties (
-			elektra-${target} PROPERTIES INSTALL_RPATH "${HASKELL_RPATH}" SANDBOX_PACKAGEDB "${SANDBOX_PACKAGEDB}")
-	endif (DEPENDENCY_PHASE AND TARGET elektra-${target})
-
-	set (PLUGINTEST_ARGS "")
-	if (ARG_INSTALL_TEST_DATA)
-		list (APPEND PLUGINTEST_ARGS "INSTALL_TEST_DATA")
-	endif (ARG_INSTALL_TEST_DATA)
-
-	if (ADDTESTING_PHASE AND TARGET elektra-${target})
-		add_plugintest (${target} MEMLEAK "${PLUGINTEST_ARGS}")
-		get_target_property (HASKELL_RPATH elektra-${target} INSTALL_RPATH)
-		get_target_property (SANDBOX_PACKAGEDB elektra-${target} SANDBOX_PACKAGEDB)
-
-		# this is required so that it finds the type checker plugin and all the libraries
-		set_target_properties (testmod_${target} PROPERTIES INSTALL_RPATH "${HASKELL_RPATH}")
-		set_property (TEST testmod_${target}
-			      PROPERTY ENVIRONMENT
-				       "SANDBOX_PACKAGEDB=${SANDBOX_PACKAGEDB};LD_LIBRARY_PATH=${PLUGIN_LD_LIBRARY_PATH}")
-	endif (ADDTESTING_PHASE AND TARGET elektra-${target})
-
 	mark_as_advanced (GHC_FFI_LIB GHC_RTS_LIB GHC_BASE_LIB GHC_GMP_LIB GHC_PRIM_LIB)
 endmacro (add_haskell_plugin)


Version: Update development date

Version: Update development date

--- src/Version.cmake
+++ src/Version.cmake
@@ -1,7 +1,7 @@
 # CastXML version number components.
 set(CastXML_VERSION_MAJOR 0)
 set(CastXML_VERSION_MINOR 4)
-set(CastXML_VERSION_PATCH 20210322)
+set(CastXML_VERSION_PATCH 20210504)
 set(CastXML_VERSION_RC 0)
 set(CastXML_VERSION_IS_DIRTY 0)


ENH: Several improvements with the way things are handled. Also, support multiple submited files

--- Utilities/kwsys/CTestConfig.cmake
+++ Utilities/kwsys/CTestConfig.cmake
@@ -1,2 +1,3 @@
 SET (CTEST_PROJECT_NAME "kwsys")
 SET (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
+SET (CTEST_DART_SERVER_VERSION "2")


Squashed 'cmake/yacma/' changes from ec1c5e8..b2f0ede

b2f0ede Remove the visibility bits from yacma.
fc45ce3 Merge commit '60f32ce08fc7c168e9203a9e5049c87bf8ccdaf5' into pr/hcc
266f248 yacma: detect hcc and disable a problematic compiler flag when using it.
37800d4 Merge commit 'f56ff8b35561ea8e8c6fd5b736a0f07399084423' into pr/yacma_iter
4613a9d Merge commit '8e8c01bc394421c65b117974d117b0ae05ddb927' into pr/small_bits
79373f8 Merge commit '28bfc37d274df5787a762d4a56f2a93a6230e1db' into pr/build_fixes
44b975a Various doc fixes involving metas.

git-subtree-dir: cmake/yacma
git-subtree-split: b2f0edeafdde4c35bd249e15241cacdcd6a345cb

--- YACMACompilerLinkerSettings.cmake
+++ YACMACompilerLinkerSettings.cmake
@@ -25,6 +25,11 @@

 if(CMAKE_COMPILER_IS_GNUCXX)
     set(YACMA_COMPILER_IS_GNUCXX TRUE)
+endif()
+
+# Detect the hcc compiler.
+if(YACMA_COMPILER_IS_CLANGXX AND "${CMAKE_CXX_COMPILER}" MATCHES "hcc")
+    set(YACMA_COMPILER_IS_HCC TRUE)
 endif()

 # This is an OS X specific setting that is suggested to be enabled. See:
@@ -113,11 +118,13 @@
         # _YACMA_CHECK_ENABLE_CXX_FLAG(-Wzero-as-null-pointer-constant)
         _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-pedantic-errors)
         _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wdisabled-optimization)
-        _YACMA_CHECK_ENABLE_CXX_FLAG(-fvisibility-inlines-hidden)
-        _YACMA_CHECK_ENABLE_CXX_FLAG(-fvisibility=hidden)
         # This is useful when the compiler decides the template backtrace is too verbose.
         _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-ftemplate-backtrace-limit=0)
-        _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-fstack-protector-all)
+        if(YACMA_COMPILER_IS_HCC)
+            message(STATUS "hcc compiler detected, the '-fstack-protector-all' flag will not be enabled.")
+        else()
+            _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-fstack-protector-all)
+        endif()
         # A few suggestion flags.
         _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wsuggest-attribute=pure)
         _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wsuggest-attribute=const)
@@ -134,7 +141,7 @@
         _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wduplicated-cond)
         _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wnull-dereference)
         # From GCC 7.
-        _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wduplicated-branches)
+        #_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wduplicated-branches)
         _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wrestrict)
         _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Waligned-new)
         # From GCC 8.


fix last commit to achieve buildable state


make the testsuite works on windows with nmake

--- test/testsuite.cmake
+++ test/testsuite.cmake
@@ -82,11 +82,7 @@
 endif(NOT EIGEN_SITE)

 if(NOT EIGEN_CMAKE_DIR)
-  if(WIN32)
-    SET(EIGEN_CMAKE_DIR "C:/Program Files/CMake/bin/")
-  else(WIN32)
-    SET(EIGEN_CMAKE_DIR "")
-  endif(WIN32)
+  SET(EIGEN_CMAKE_DIR "")
 endif(NOT EIGEN_CMAKE_DIR)

 if(NOT EIGEN_BUILD_STRING)
@@ -163,6 +159,8 @@
 # this is the initial cache to use for the binary tree, be careful to escape
 # any quotes inside of this string if you use it
 if(WIN32)
+  #message(SEND_ERROR "win32")
+  set(CTEST_CMAKE_COMMAND "${CTEST_CMAKE_COMMAND} -G \"NMake Makefiles\" -DCMAKE_MAKE_PROGRAM=nmake")
   SET (CTEST_INITIAL_CACHE "
     MAKECOMMAND:STRING=nmake -i
     CMAKE_MAKE_PROGRAM:FILEPATH=nmake


Fix error with Android

Fix error with Android

--- scripts/FindLIEF.cmake
+++ scripts/FindLIEF.cmake
@@ -91,6 +91,8 @@
   find_path(LIEF_INCLUDE_DIR
     NAMES LIEF/LIEF.hpp
     PATH ${${search}}
+    REQUIRED
+    CMAKE_FIND_ROOT_PATH_BOTH
     PATH_SUFFIXES include)
 endforeach()

@@ -100,6 +102,8 @@
     find_library(_LIEF_LIBRARY
       NAMES ${LIEF_NAMES}
       PATHS ${${search}}
+      REQUIRED
+      CMAKE_FIND_ROOT_PATH_BOTH
       PATH_SUFFIXES lib lib64)
   endforeach()


Suppress abi-breaking.h on cygming, for now.

FIXME: Implement checks without weak for them.

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

--- include/llvm/Config/abi-breaking.h.cmake
+++ include/llvm/Config/abi-breaking.h.cmake
@@ -24,6 +24,8 @@
 #pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS))
 #undef LLVM_XSTR
 #undef LLVM_STR
+#elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch
+// FIXME: Implement checks without weak.
 #elif defined(__cplusplus)
 namespace llvm {
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS


Download test data from github vc-testdata repo

Signed-off-by: Matthias Kretz <372ea4eca737a13cd010ee806d4ce7b98ee71550@kde.org>

--- tests/download.cmake
+++ tests/download.cmake
@@ -1 +1 @@
-file(DOWNLOAD "http://web-docs.gsi.de/~mkretz/Vc-testdata/${filename}" "./${filename}")
+file(DOWNLOAD "https://github.com/VcDevel/vc-testdata/raw/master/${filename}" "./${filename}")


Pass MITK_DOXYGEN_BUILD_ALWAYS and BLUEBERRY_DOC_TOOLS_DIR to MITK-Configure

--- SuperBuild.cmake
+++ SuperBuild.cmake
@@ -375,6 +375,18 @@
 if(DOXYGEN_EXECUTABLE)
   list(APPEND mitk_optional_cache_args
        -DDOXYGEN_EXECUTABLE:FILEPATH=${DOXYGEN_EXECUTABLE}
+  )
+endif()
+
+if(MITK_DOXYGEN_BUILD_ALWAYS)
+  list(APPEND mitk_optional_cache_args
+    -DMITK_DOXYGEN_BUILD_ALWAYS:BOOL=${MITK_DOXYGEN_BUILD_ALWAYS}
+  )
+endif()
+
+if(BLUEBERRY_DOC_TOOLS_DIR)
+  list(APPEND mitk_optional_cache_args
+    "-DBLUEBERRY_DOC_TOOLS_DIR:PATH=${BLUEBERRY_DOC_TOOLS_DIR}"
   )
 endif()


ENH: CMake error message if trying to build without Slicer on Mac or Windows because fails at run time

--- SuperBuild.cmake
+++ SuperBuild.cmake
@@ -83,7 +83,13 @@
   endif()

 else( DTIAtlasBuilder_BUILD_SLICER_EXTENSION )
+
+  if(APPLE OR WIN32) # If not Slicer ext, not compile because will fail at run time
+    message(FATAL_ERROR "DTIAtlasBuilder has known issues and will not run on Mac or Windows")
+  endif()
+
   set(INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
+
 endif( DTIAtlasBuilder_BUILD_SLICER_EXTENSION )

 set( COMPILE_PACKAGE ON CACHE BOOL "Compiles all the external projects and tools" )


Creates sirfrc

Creates sirfrc

it creates sirfrc to set all the environment variables.
Adds a message to the user rather than appending sirfrc to bashrc.

--- SuperBuild.cmake
+++ SuperBuild.cmake
@@ -102,9 +102,10 @@
   # create .sirfrc
   configure_file(env_ccppetmr.sh.in $ENV{HOME}/.sirfrc)
   # append .sirfrc to .bashrc
-  file(APPEND $ENV{HOME}/.bashrc "#Environment variables for SIRF
-source ~/.sirfrc")
+#  file(APPEND $ENV{HOME}/.bashrc "#Environment variables for SIRF
+#source ~/.sirfrc")
 endif()
+message("To set up all the environmental variables for SIRF, just type: source ~/.sirfrc")

 configure_file(env_ccppetmr.csh.in ${CCPPETMR_INSTALL}/bin/env_ccppetmr.csh)


Android CMake toolchain is updated for NDK r8b

--- android/android.toolchain.cmake
+++ android/android.toolchain.cmake
@@ -180,6 +180,8 @@
 #   - modified May 2012
 #     [+] updated for NDK r8
 #     [+] added mips architecture support
+#   - modified August 2012
+#     [+] updated for NDK r8b
 # ------------------------------------------------------------------------------

 cmake_minimum_required( VERSION 2.6.3 )
@@ -199,7 +201,7 @@
 #this one not so much
 set( CMAKE_SYSTEM_VERSION 1 )

-set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
+set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -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 )
@@ -473,11 +475,11 @@
  foreach( __toolchain ${__availableToolchains} )
   __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
   if( __machine )
-   string( REGEX MATCH "[0-9]+.[0-9]+.[0-9]+$" __version "${__toolchain}" )
+   string( REGEX MATCH "[0-9]+[.][0-9]+[.]*[0-9]*$" __version "${__toolchain}" )
    string( REGEX MATCH "^[^-]+" __arch "${__toolchain}" )
-   list( APPEND __availableToolchainMachines ${__machine} )
-   list( APPEND __availableToolchainArchs ${__arch} )
-   list( APPEND __availableToolchainCompilerVersions ${__version} )
+   list( APPEND __availableToolchainMachines "${__machine}" )
+   list( APPEND __availableToolchainArchs "${__arch}" )
+   list( APPEND __availableToolchainCompilerVersions "${__version}" )
   else()
    list( REMOVE_ITEM __availableToolchains "${__toolchain}" )
   endif()
@@ -669,8 +671,13 @@
   set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/stlport/stlport" )
   set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/stlport/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}" )
+  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()
 endif()


Update Android CMake toolchain for NDK r8c

--- android/android.toolchain.cmake
+++ android/android.toolchain.cmake
@@ -1,7 +1,37 @@
+# Copyright (c) 2010-2011, Ethan Rublee
+# Copyright (c) 2011-2012, Andrey Kamaev
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1.  Redistributions of source code must retain the above copyright notice,
+#     this list of conditions and the following disclaimer.
+#
+# 2.  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.
+#
+# 3.  The name of the copyright holders 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.
+
 # ------------------------------------------------------------------------------
 #  Android CMake toolchain file, for use with the Android NDK r5-r8
 #  Requires cmake 2.6.3 or newer (2.8.5 or newer is recommended).
-#  See home page: http://code.google.com/p/android-cmake/
+#  See home page: https://github.com/taka-no-me/android-cmake
 #
 #  The file is mantained by the OpenCV project. The latest version can be get at
 #  http://code.opencv.org/projects/opencv/repository/revisions/master/changes/android/android.toolchain.cmake
@@ -63,6 +93,20 @@
 #
 #    ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for.
 #      Option is read-only when standalone toolchain is used.
+#
+#    ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.6 - the name of compiler
+#      toolchain to be used. The list of possible values depends on the NDK
+#      version. For NDK r8c the possible values are:
+#
+#        * arm-linux-androideabi-4.4.3
+#        * arm-linux-androideabi-4.6
+#        * arm-linux-androideabi-clang3.1
+#        * mipsel-linux-android-4.4.3
+#        * mipsel-linux-android-4.6
+#        * mipsel-linux-android-clang3.1
+#        * x86-4.4.3
+#        * x86-4.6
+#        * x86-clang3.1
 #
 #    ANDROID_FORCE_ARM_BUILD=OFF - set ON to generate 32-bit ARM instructions
 #      instead of Thumb. Is not available for "x86" (inapplicable) and
@@ -147,13 +191,9 @@
 #    under the ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}
 #    (depending on the target ABI). This is convenient for Android packaging.
 #
-#  Authors:
-#    Ethan Rublee ethan.ruble@gmail.com
-#    Andrey Kamaev andrey.kamaev@itseez.com
-#
 #  Change Log:
 #   - initial version December 2010
-#   - modified April 2011
+#   - April 2011
 #     [+] added possibility to build with NDK (without standalone toolchain)
 #     [+] support cross-compilation on Windows (native, no cygwin support)
 #     [+] added compiler option to force "char" type to be signed
@@ -164,13 +204,13 @@
 #     [+] EXECUTABLE_OUTPUT_PATH is set by toolchain (required on Windows)
 #     [~] Fixed bug with ANDROID_API_LEVEL variable
 #     [~] turn off SWIG search if it is not found first time
-#   - modified May 2011
+#   - May 2011
 #     [~] ANDROID_LEVEL is renamed to ANDROID_API_LEVEL
 #     [+] ANDROID_API_LEVEL is detected by toolchain if not specified
 #     [~] added guard to prevent changing of output directories on the first
 #         cmake pass
 #     [~] toolchain exits with error if ARM_TARGET is not recognized
-#   - modified June 2011
+#   - June 2011
 #     [~] default NDK path is updated for version r5c
 #     [+] variable CMAKE_SYSTEM_PROCESSOR is set based on ARM_TARGET
 #     [~] toolchain install directory is added to linker paths
@@ -178,13 +218,13 @@
 #     [+] added macro find_host_package, find_host_program to search
 #         packages/programs on the host system
 #     [~] fixed path to STL library
-#   - modified July 2011
+#   - July 2011
 #     [~] fixed options caching
 #     [~] search for all supported NDK versions
 #     [~] allowed spaces in NDK path
-#   - modified September 2011
+#   - September 2011
 #     [~] updated for NDK r6b
-#   - modified November 2011
+#   - November 2011
 #     [*] rewritten for NDK r7
 #     [+] x86 toolchain support (experimental)
 #     [+] added "armeabi-v6 with VFP" ABI for ARMv6 processors.
@@ -197,37 +237,37 @@
 #     [~] ARM_TARGET is renamed to ANDROID_ABI
 #     [~] ARMEABI_NDK_NAME is renamed to ANDROID_NDK_ABI_NAME
 #     [~] ANDROID_API_LEVEL is renamed to ANDROID_NATIVE_API_LEVEL
-#   - modified January 2012
+#   - January 2012
 #     [+] added stlport_static support (experimental)
 #     [+] added special check for cygwin
 #     [+] filtered out hidden files (starting with .) while globbing inside NDK
 #     [+] automatically applied GLESv2 linkage fix for NDK revisions 5-6
 #     [+] added ANDROID_GET_ABI_RAWNAME to get NDK ABI names by CMake flags
-#   - modified February 2012
+#   - February 2012
 #     [+] updated for NDK r7b
 #     [~] fixed cmake try_compile() command
 #     [~] Fix for missing install_name_tool on OS X
-#   - modified March 2012
+#   - March 2012
 #     [~] fixed incorrect C compiler flags
 #     [~] fixed CMAKE_SYSTEM_PROCESSOR change on ANDROID_ABI change
 #     [+] improved toolchain loading speed
 #     [+] added assembler language support (.S)
 #     [+] allowed preset search paths and extra search suffixes
-#   - modified April 2012
+#   - April 2012
 #     [+] updated for NDK r7c
 #     [~] fixed most of problems with compiler/linker flags and caching
 #     [+] added option ANDROID_FUNCTION_LEVEL_LINKING
-#   - modified May 2012
+#   - May 2012
 #     [+] updated for NDK r8
 #     [+] added mips architecture support
-#   - modified August 2012
+#   - August 2012
 #     [+] updated for NDK r8b
 #     [~] all intermediate files generated by toolchain are moved to CMakeFiles
 #     [~] libstdc++ and libsupc are removed from explicit link libraries
 #     [+] added CCache support (via NDK_CCACHE environment or cmake variable)
 #     [+] added gold linker support for NDK r8b
 #     [~] fixed mips linker flags for NDK r8b
-#   - modified September 2012
+#   - September 2012
 #     [+] added NDK release name detection (see ANDROID_NDK_RELEASE)
 #     [+] added support for all C++ runtimes from NDK
 #         (system, gabi++, stlport, gnustl)
@@ -235,8 +275,11 @@
 #     [~] use gold linker as default if available (NDK r8b)
 #     [~] globally turned off rpath
 #     [~] compiler options are aligned with NDK r8b
-#   - modified October 2012
+#   - October 2012
 #     [~] fixed C++ linking: explicitly link with math library (OpenCV #2426)
+#   - November 2012
+#     [+] updated for NDK r8c
+#     [+] added support for clang compiler
 # ------------------------------------------------------------------------------

 cmake_minimum_required( VERSION 2.6.3 )
@@ -259,7 +302,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} -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
+set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -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 )
@@ -367,8 +410,8 @@

 macro( __DETECT_TOOLCHAIN_MACHINE_NAME _var _root )
  if( EXISTS "${_root}" )
-  file( GLOB __gccExePath "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" )
-  __LIST_FILTER( __gccExePath "bin/[.].*-gcc${TOOL_OS_SUFFIX}$" )
+  file( GLOB __gccExePath RELATIVE "${_root}/bin/" "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" )
+  __LIST_FILTER( __gccExePath "^[.].*" )
   list( LENGTH __gccExePath __gccExePathsCount )
   if( NOT __gccExePathsCount EQUAL 1  AND NOT _CMAKE_IN_TRY_COMPILE )
    message( WARNING "Could not determine machine name for compiler from ${_root}" )
@@ -506,55 +549,73 @@
  elseif( __availableToolchainMachines MATCHES mipsel )
   set( __availableToolchainArchs "mipsel" )
  endif()
- if( ANDROID_COMPILER_VERSION )
-  # do not run gcc every time because it is relatevely expencive
-  set( __availableToolchainCompilerVersions "${ANDROID_COMPILER_VERSION}" )
- else()
-  execute_process( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" --version
-   OUTPUT_VARIABLE __availableToolchainCompilerVersions OUTPUT_STRIP_TRAILING_WHITESPACE )
-  string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?" __availableToolchainCompilerVersions "${__availableToolchainCompilerVersions}" )
- endif()
-endif()
+ execute_process( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" -dumpversion
+                  OUTPUT_VARIABLE __availableToolchainCompilerVersions OUTPUT_STRIP_TRAILING_WHITESPACE )
+ string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?" __availableToolchainCompilerVersions "${__availableToolchainCompilerVersions}" )
+ if( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/bin/clang${TOOL_OS_SUFFIX}" )
+  list( APPEND __availableToolchains "standalone-clang" )
+  list( APPEND __availableToolchainMachines ${__availableToolchainMachines} )
+  list( APPEND __availableToolchainArchs ${__availableToolchainArchs} )
+  list( APPEND __availableToolchainCompilerVersions ${__availableToolchainCompilerVersions} )
+ endif()
+endif()
+
+macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar )
+ foreach( __toolchain ${${__availableToolchainsVar}} )
+  if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/" )
+   string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" )
+  else()
+   set( __gcc_toolchain "${__toolchain}" )
+  endif()
+  __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__gcc_toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
+  if( __machine )
+   string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?$" __version "${__gcc_toolchain}" )
+   string( REGEX MATCH "^[^-]+" __arch "${__gcc_toolchain}" )
+   list( APPEND __availableToolchainMachines "${__machine}" )
+   list( APPEND __availableToolchainArchs "${__arch}" )
+   list( APPEND __availableToolchainCompilerVersions "${__version}" )
+  else()
+   list( REMOVE_ITEM ${__availableToolchainsVar} "${__toolchain}" )
+  endif()
+  unset( __gcc_toolchain )
+ endforeach()
+endmacro()

 # get all the details about NDK
 if( BUILD_WITH_ANDROID_NDK )
  file( GLOB ANDROID_SUPPORTED_NATIVE_API_LEVELS RELATIVE "${ANDROID_NDK}/platforms" "${ANDROID_NDK}/platforms/android-*" )
  string( REPLACE "android-" "" ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_SUPPORTED_NATIVE_API_LEVELS}" )
- file( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" )
- __LIST_FILTER( __availableToolchains "^[.]" )
+ set( __availableToolchains "" )
  set( __availableToolchainMachines "" )
  set( __availableToolchainArchs "" )
  set( __availableToolchainCompilerVersions "" )
- foreach( __toolchain ${__availableToolchains} )
-  __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
-  if( __machine )
-   string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?$" __version "${__toolchain}" )
-   string( REGEX MATCH "^[^-]+" __arch "${__toolchain}" )
-   list( APPEND __availableToolchainMachines "${__machine}" )
-   list( APPEND __availableToolchainArchs "${__arch}" )
-   list( APPEND __availableToolchainCompilerVersions "${__version}" )
-  else()
-   list( REMOVE_ITEM __availableToolchains "${__toolchain}" )
-  endif()
- endforeach()
+ if( ANDROID_TOOLCHAIN_NAME AND EXISTS "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/" )
+  # do not go through all toolchains if we know the name
+  set( __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" )
+  __GLOB_NDK_TOOLCHAINS( __availableToolchains )
+ endif()
  if( NOT __availableToolchains )
-  message( FATAL_ERROR "Could not any working toolchain in the NDK. Probably your Android NDK is broken." )
+  file( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" )
+  __LIST_FILTER( __availableToolchains "^[.]" )
+  __LIST_FILTER( __availableToolchains "llvm" )
+  __GLOB_NDK_TOOLCHAINS( __availableToolchains )
+ endif()
+ if( NOT __availableToolchains )
+  message( FATAL_ERROR "Could not find any working toolchain in the NDK. Probably your Android NDK is broken." )
  endif()
 endif()

 # build list of available ABIs
+set( ANDROID_SUPPORTED_ABIS "" )
+set( __uniqToolchainArchNames ${__availableToolchainArchs} )
+list( REMOVE_DUPLICATES __uniqToolchainArchNames )
+list( SORT __uniqToolchainArchNames )
+foreach( __arch ${__uniqToolchainArchNames} )
+list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} )
+endforeach()
+unset( __uniqToolchainArchNames )
 if( NOT ANDROID_SUPPORTED_ABIS )
- set( ANDROID_SUPPORTED_ABIS "" )
- set( __uniqToolchainArchNames ${__availableToolchainArchs} )
- list( REMOVE_DUPLICATES __uniqToolchainArchNames )
- list( SORT __uniqToolchainArchNames )
- foreach( __arch ${__uniqToolchainArchNames} )
-  list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} )
- endforeach()
- unset( __uniqToolchainArchNames )
- if( NOT ANDROID_SUPPORTED_ABIS )
-  message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." )
- endif()
+message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." )
 endif()

 # choose target ABI
@@ -569,33 +630,34 @@
 endif()
 unset( __androidAbiIdx )

-# remember target ABI
-set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE )
-
 # set target ABI options
 if( ANDROID_ABI STREQUAL "x86" )
  set( X86 true )
  set( ANDROID_NDK_ABI_NAME "x86" )
  set( ANDROID_ARCH_NAME "x86" )
  set( ANDROID_ARCH_FULLNAME "x86" )
+ set( ANDROID_LLVM_TRIPLE "i686-none-linux-android" )
  set( CMAKE_SYSTEM_PROCESSOR "i686" )
 elseif( ANDROID_ABI STREQUAL "mips" )
  set( MIPS true )
  set( ANDROID_NDK_ABI_NAME "mips" )
  set( ANDROID_ARCH_NAME "mips" )
  set( ANDROID_ARCH_FULLNAME "mipsel" )
+ set( ANDROID_LLVM_TRIPLE "mipsel-none-linux-android" )
  set( CMAKE_SYSTEM_PROCESSOR "mips" )
 elseif( ANDROID_ABI STREQUAL "armeabi" )
  set( ARMEABI true )
  set( ANDROID_NDK_ABI_NAME "armeabi" )
  set( ANDROID_ARCH_NAME "arm" )
  set( ANDROID_ARCH_FULLNAME "arm" )
+ set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" )
  set( CMAKE_SYSTEM_PROCESSOR "armv5te" )
 elseif( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" )
  set( ARMEABI_V6 true )
  set( ANDROID_NDK_ABI_NAME "armeabi" )
  set( ANDROID_ARCH_NAME "arm" )
  set( ANDROID_ARCH_FULLNAME "arm" )
+ set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" )
  set( CMAKE_SYSTEM_PROCESSOR "armv6" )
  # need always fallback to older platform
  set( ARMEABI true )
@@ -604,12 +666,14 @@
  set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
  set( ANDROID_ARCH_NAME "arm" )
  set( ANDROID_ARCH_FULLNAME "arm" )
+ set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
  set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
 elseif( ANDROID_ABI STREQUAL "armeabi-v7a with VFPV3" )
  set( ARMEABI_V7A true )
  set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
  set( ANDROID_ARCH_NAME "arm" )
  set( ANDROID_ARCH_FULLNAME "arm" )
+ set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
  set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
  set( VFPV3 true )
 elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" )
@@ -617,6 +681,7 @@
  set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
  set( ANDROID_ARCH_NAME "arm" )
  set( ANDROID_ARCH_FULLNAME "arm" )
+ set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
  set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
  set( VFPV3 true )
  set( NEON true )
@@ -628,12 +693,6 @@
  # really dirty hack
  # it is not possible to change CMAKE_SYSTEM_PROCESSOR after the first run...
  file( APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" "SET(CMAKE_SYSTEM_PROCESSOR \"${CMAKE_SYSTEM_PROCESSOR}\")\n" )
-endif()
-
-set( ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} CACHE INTERNAL "ANDROID_ABI can be changed only to one of these ABIs. Changing to any other ABI requires to reset cmake cache." FORCE )
-if( CMAKE_VERSION VERSION_GREATER "2.8" )
- list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME} )
- set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} )
 endif()

 if( ANDROID_ARCH_NAME STREQUAL "arm" AND NOT ARMEABI_V6 )
@@ -648,11 +707,15 @@
 if( ANDROID_TOOLCHAIN_NAME )
  list( FIND __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" __toolchainIdx )
  if( __toolchainIdx EQUAL -1 )
-  message( FATAL_ERROR "Previously selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is missing. You need to remove CMakeCache.txt and rerun cmake manually to change the toolchain" )
+  list( SORT __availableToolchains )
+  string( REPLACE ";" "\n  * " toolchains_list "${__availableToolchains}" )
+  set( toolchains_list "  * ${toolchains_list}")
+  message( FATAL_ERROR "Specified toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is missing in your NDK or broken. Please verify that your NDK is working or select another compiler toolchain.
+To configure the toolchain set CMake variable ANDROID_TOOLCHAIN_NAME to one of the following values:\n${toolchains_list}\n" )
  endif()
  list( GET __availableToolchainArchs ${__toolchainIdx} __toolchainArch )
  if( NOT __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
-  message( SEND_ERROR "Previously selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." )
+  message( SEND_ERROR "Selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." )
  endif()
 else()
  set( __toolchainIdx -1 )
@@ -681,8 +744,7 @@
 list( GET __availableToolchains ${__toolchainIdx} ANDROID_TOOLCHAIN_NAME )
 list( GET __availableToolchainMachines ${__toolchainIdx} ANDROID_TOOLCHAIN_MACHINE_NAME )
 list( GET __availableToolchainCompilerVersions ${__toolchainIdx} ANDROID_COMPILER_VERSION )
-set( ANDROID_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" CACHE INTERNAL "Name of toolchain used" FORCE )
-set( ANDROID_COMPILER_VERSION "${ANDROID_COMPILER_VERSION}" CACHE INTERNAL "compiler version from selected toolchain" FORCE )
+
 unset( __toolchainIdx )
 unset( __availableToolchains )
 unset( __availableToolchainMachines )
@@ -692,37 +754,35 @@
 # choose native API level
 __INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL )
 string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
+# TODO: filter out unsupported levels
 # validate
 list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx )
 if( __levelIdx EQUAL -1 )
  message( SEND_ERROR "Specified Android native API level (${ANDROID_NATIVE_API_LEVEL}) is not supported by your NDK/toolchain." )
+else()
+ if( BUILD_WITH_ANDROID_NDK )
+  __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
+  if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL )
+   message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
+  endif()
+  unset( __realApiLevel )
+ endif()
+ set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE )
+ if( CMAKE_VERSION VERSION_GREATER "2.8" )
+  list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS )
+  set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
+ endif()
 endif()
 unset( __levelIdx )
-if( BUILD_WITH_ANDROID_NDK )
- __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
- if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL )
-  message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
- endif()
- unset( __realApiLevel )
-endif()
-set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE )
+
+
+# remember target ABI
+set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE )
 if( CMAKE_VERSION VERSION_GREATER "2.8" )
- list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS )
- set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
-endif()
-
-# setup output directories
-set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" )
-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()
+ list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME} )
+ set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} )
+endif()
+

 # runtime choice (STL, rtti, exceptions)
 if( NOT ANDROID_STL )
@@ -800,9 +860,84 @@
 " )
 endif()

+
+# setup paths and STL for standalone toolchain
+if( BUILD_WITH_STANDALONE_TOOLCHAIN )
+ set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" )
+ set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" )
+ 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}" )
+  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" )
+   list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" )
+  else()
+   list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" )
+  endif()
+  # always search static GNU STL to get the location of libsupc++.a
+  if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" )
+   set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb" )
+  elseif( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" )
+   set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}" )
+  elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libstdc++.a" )
+   set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb" )
+  elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libstdc++.a" )
+   set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" )
+  endif()
+  if( __libstl )
+   set( __libsupcxx "${__libstl}/libsupc++.a" )
+   set( __libstl    "${__libstl}/libstdc++.a" )
+  endif()
+  if( NOT EXISTS "${__libsupcxx}" )
+   message( FATAL_ERROR "The required libstdsupc++.a is missing in your standalone toolchain.
+ Usually it happens because of bug in make-standalone-toolchain.sh script from NDK r7, r7b and r7c.
+ You need to either upgrade to newer NDK or manually copy
+     $ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a
+ to
+     ${__libsupcxx}
+   " )
+  endif()
+  if( ANDROID_STL STREQUAL "gnustl_shared" )
+   if( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" )
+    set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" )
+   elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" )
+    set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" )
+   elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" )
+    set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" )
+   endif()
+  endif()
+ endif()
+endif()
+
+# clang
+if( "${ANDROID_TOOLCHAIN_NAME}" STREQUAL "standalone-clang" )
+ set( ANDROID_COMPILER_IS_CLANG 1 )
+ execute_process( COMMAND "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/clang${TOOL_OS_SUFFIX}" --version OUTPUT_VARIABLE ANDROID_CLANG_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE )
+ string( REGEX MATCH "[0-9]+[.][0-9]+" ANDROID_CLANG_VERSION "${ANDROID_CLANG_VERSION}")
+elseif( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" )
+ string( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}")
+ string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-4.6" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
+ if( NOT EXISTS "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}/bin/clang${TOOL_OS_SUFFIX}" )
+  message( FATAL_ERROR "Could not find the " )
+ endif()
+ set( ANDROID_COMPILER_IS_CLANG 1 )
+ set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
+else()
+ set( ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
+ unset( ANDROID_COMPILER_IS_CLANG CACHE )
+endif()
+
+string( REPLACE "." "" _clang_name "clang${ANDROID_CLANG_VERSION}" )
+if( NOT EXISTS "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" )
+ set( _clang_name "clang" )
+endif()
+
+
 # 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_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_GCC_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" )
@@ -874,54 +1009,6 @@
  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" )
-
- if( NOT ANDROID_STL STREQUAL "none" )
-  set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" )
-  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" )
-   list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" )
-  else()
-   list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" )
-  endif()
-  # always search static GNU STL to get the location of libsupc++.a
-  if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" )
-   set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb" )
-  elseif( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" )
-   set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}" )
-  elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libstdc++.a" )
-   set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb" )
-  elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libstdc++.a" )
-   set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" )
-  endif()
-  if( __libstl )
-   set( __libsupcxx "${__libstl}/libsupc++.a" )
-   set( __libstl    "${__libstl}/libstdc++.a" )
-  endif()
-  if( NOT EXISTS "${__libsupcxx}" )
-   message( FATAL_ERROR "The required libstdsupc++.a is missing in your standalone toolchain.
- Usually it happens because of bug in make-standalone-toolchain.sh script from NDK r7, r7b and r7c.
- You need to either upgrade to newer NDK or manually copy
-     $ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a
- to
-     ${__libsupcxx}
-   " )
-  endif()
-  if( ANDROID_STL STREQUAL "gnustl_shared" )
-   if( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" )
-    set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" )
-   elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" )
-    set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" )
-   elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" )
-    set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" )
-   endif()
-  endif()
- endif()
-endif()

 # case of shared STL linkage
 if( ANDROID_STL MATCHES "shared" AND DEFINED __libstl )
@@ -937,6 +1024,7 @@
  endif()
 endif()

+
 # ccache support
 __INIT_VARIABLE( _ndk_ccache NDK_CCACHE ENV_NDK_CCACHE )
 if( _ndk_ccache )
@@ -946,16 +1034,27 @@
 endif()
 unset( _ndk_ccache )

+
 # setup the cross-compiler
 if( NOT CMAKE_C_COMPILER )
  if( NDK_CCACHE )
   set( CMAKE_C_COMPILER   "${NDK_CCACHE}" CACHE PATH "ccache as C compiler" )
   set( CMAKE_CXX_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C++ compiler" )
-  set( CMAKE_C_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}"   CACHE PATH "gcc")
-  set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "g++")
+  if( ANDROID_COMPILER_IS_CLANG )
+   set( CMAKE_C_COMPILER_ARG1   "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}"   CACHE PATH "C compiler")
+   set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler")
+  else()
+   set( CMAKE_C_COMPILER_ARG1   "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "C compiler")
+   set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler")
+  endif()
  else()
-  set( CMAKE_C_COMPILER   "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}"    CACHE PATH "gcc" )
-  set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}"    CACHE PATH "g++" )
+  if( ANDROID_COMPILER_IS_CLANG )
+   set( CMAKE_C_COMPILER   "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}"   CACHE PATH "C compiler")
+   set( CMAKE_CXX_COMPILER "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler")
+  else()
+   set( CMAKE_C_COMPILER   "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}"    CACHE PATH "C compiler" )
+   set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}"    CACHE PATH "C++ compiler" )
+  endif()
  endif()
  set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}"     CACHE PATH "assembler" )
  set( CMAKE_STRIP        "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}"   CACHE PATH "strip" )
@@ -982,15 +1081,22 @@
 # Force set compilers because standard identification works badly for us
 include( CMakeForceCompiler )
 CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
+if( ANDROID_COMPILER_IS_CLANG )
+ set( CMAKE_C_COMPILER_ID Clang)
+endif()
 set( CMAKE_C_PLATFORM_ID Linux )
 set( CMAKE_C_SIZEOF_DATA_PTR 4 )
 set( CMAKE_C_HAS_ISYSROOT 1 )
 set( CMAKE_C_COMPILER_ABI ELF )
 CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU )
+if( ANDROID_COMPILER_IS_CLANG )
+ set( CMAKE_CXX_COMPILER_ID Clang)
+endif()
 set( CMAKE_CXX_PLATFORM_ID Linux )
 set( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
 set( CMAKE_CXX_HAS_ISYSROOT 1 )
 set( CMAKE_CXX_COMPILER_ABI ELF )
+set( CMAKE_CXX_SOURCE_FILE_EXTENSIONS cc cp cxx cpp CPP c++ C )
 # force ASM compiler (required for CMake < 2.8.5)
 set( CMAKE_ASM_COMPILER_ID_RUN TRUE )
 set( CMAKE_ASM_COMPILER_ID GNU )
@@ -1056,10 +1162,10 @@
  elseif( VFPV3 )
   set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3" )
  else()
-  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfp" )
+  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3-d16" )
  endif()
 elseif( ARMEABI_V6 )
- set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" ) # vfp == vfpv2
 elseif( ARMEABI )
  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" )
 endif()
@@ -1148,22 +1254,46 @@
  set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--gc-sections" )
 endif()

-if( ANDROID_GOLD_LINKER AND CMAKE_HOST_UNIX AND (ARMEABI OR ARMEABI_V7A OR X86) AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" )
- set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" )
-elseif( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" AND NOT _CMAKE_IN_TRY_COMPILE )
- message( WARNING "The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342
+if( ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" )
+ if( ANDROID_GOLD_LINKER AND (CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE STRGREATER "r8b") AND (ARMEABI OR ARMEABI_V7A OR X86) )
+  set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" )
+ elseif( ANDROID_NDK_RELEASE STREQUAL "r8c")
+  set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=bfd" )
+ elseif( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND NOT _CMAKE_IN_TRY_COMPILE )
+  message( WARNING "The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342
   On Linux and OS X host platform you can workaround this problem using gold linker (default).
-  Rerun cmake with -DANDROID_GOLD_LINKER=ON option.
+  Rerun cmake with -DANDROID_GOLD_LINKER=ON option in case of problems.
 " )
-endif()
+ endif()
+endif() # version 4.6

 if( ANDROID_NOEXECSTACK )
- set( ANDROID_CXX_FLAGS    "${ANDROID_CXX_FLAGS} -Wa,--noexecstack" )
+ if( ANDROID_COMPILER_IS_CLANG )
+  set( ANDROID_CXX_FLAGS    "${ANDROID_CXX_FLAGS} -Xclang -mnoexecstack" )
+ else()
+  set( ANDROID_CXX_FLAGS    "${ANDROID_CXX_FLAGS} -Wa,--noexecstack" )
+ endif()
  set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,noexecstack" )
 endif()

 if( ANDROID_RELRO )
  set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,relro -Wl,-z,now" )
+endif()
+
+if( ANDROID_COMPILER_IS_CLANG )
+ set( ANDROID_CXX_FLAGS "-Qunused-arguments ${ANDROID_CXX_FLAGS}" )
+ if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD )
+  set( ANDROID_CXX_FLAGS_RELEASE "-target thumbv7-none-linux-androideabi ${ANDROID_CXX_FLAGS_RELEASE}" )
+  set( ANDROID_CXX_FLAGS_DEBUG   "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS_DEBUG}" )
+ else()
+  set( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS}" )
+ endif()
+ if( BUILD_WITH_ANDROID_NDK )
+  if(ANDROID_ARCH_NAME STREQUAL "arm" )
+   set( ANDROID_CXX_FLAGS "-isystem ${ANDROID_CLANG_TOOLCHAIN_ROOT}/lib/clang/${ANDROID_CLANG_VERSION}/include ${ANDROID_CXX_FLAGS}" )
+  endif()
+  set( ANDROID_CXX_FLAGS "-gcc-toolchain ${ANDROID_TOOLCHAIN_ROOT} ${ANDROID_CXX_FLAGS}" )
+ endif()
 endif()

 # cache flags
@@ -1189,9 +1319,9 @@
 set( CMAKE_EXE_LINKER_FLAGS    "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )

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

 # configure rtti
@@ -1217,6 +1347,19 @@
 # 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}" )
+
+# 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()

 # set these global flags for cmake client scripts to change behavior
 set( ANDROID True )
@@ -1335,7 +1478,7 @@
 # Variables controlling behavior or set by cmake toolchain:
 #   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_STL : gnustl_static/gnustl_shared/stlport_static/stlport_shared/gabi++_static/gabi++_shared/system_re/system/none
 #   ANDROID_FORBID_SYGWIN : ON/OFF
 #   ANDROID_NO_UNDEFINED : ON/OFF
 #   ANDROID_SO_UNDEFINED : OFF/ON  (default depends on NDK version)
@@ -1343,16 +1486,15 @@
 #   ANDROID_GOLD_LINKER : ON/OFF
 #   ANDROID_NOEXECSTACK : ON/OFF
 #   ANDROID_RELRO : ON/OFF
-# 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>
+#   ANDROID_SET_OBSOLETE_VARIABLES : ON/OFF
 # Can be set only at the first run:
 #   ANDROID_NDK
 #   ANDROID_STANDALONE_TOOLCHAIN
-#   ANDROID_TOOLCHAIN_NAME : "arm-linux-androideabi-4.4.3" or "arm-linux-androideabi-4.6" or "mipsel-linux-android-4.4.3" or "mipsel-linux-android-4.6" or "x86-4.4.3" or "x86-4.6"
+#   ANDROID_TOOLCHAIN_NAME : the NDK name of compiler toolchain
+#   LIBRARY_OUTPUT_PATH_ROOT : <any valid path>
+#   NDK_CCACHE : <path to your ccache executable>
 # Obsolete:
 #   ANDROID_API_LEVEL : superseded by ANDROID_NATIVE_API_LEVEL
 #   ARM_TARGET : superseded by ANDROID_ABI
@@ -1375,10 +1517,11 @@
 #   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; set only for NDK
+#   ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c; 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
+#   ANDROID_COMPILER_IS_CLANG : TRUE if clang compiler is used
 # Obsolete:
 #   ARMEABI_NDK_NAME : superseded by ANDROID_NDK_ABI_NAME
 #
@@ -1388,10 +1531,13 @@
 #   ANDROID_SUPPORTED_ABIS : list of currently allowed values for ANDROID_ABI
 #   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_CLANG_TOOLCHAIN_ROOT : path to clang tools
 #   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
+#   ANDROID_GCC_TOOLCHAIN_NAME : read-only, differs from ANDROID_TOOLCHAIN_NAME only if clang is used
+#   ANDROID_CLANG_VERSION : version of clang compiler if clang is used
 #
 # Defaults:
 #   ANDROID_DEFAULT_NDK_API_LEVEL


Rename `gostai_add_test' to `gostai_add_run_test'.

	* build-aux/cmake/modules/Gostai.cmake: Here.

--- build-aux/cmake/modules/Gostai.cmake
+++ build-aux/cmake/modules/Gostai.cmake
@@ -576,7 +576,7 @@
 endfunction(gostai_add_library name)

-# Add a Gostai test executable target named test-_name_.
+# Add a Gostai test executable target named test-_name_ intended to be run.
 # Arguments:
 #  SOURCES	- the list of sources of the executable
 #  MOCS		- the list of sources of the executable that need to be moc'ed
@@ -585,13 +585,13 @@
 #  INCLUDE_DIRS - the list of include directories to search in.
 #  LIBRARIES	- the list of libraries to link with.
 #  RESOURCES	- the list of resources files.
-macro(gostai_add_test name)
+macro(gostai_add_run_test name)

   gostai_add_executable(test-${name} ${ARGN}
     NO_INSTALL)
   add_test(${name} test-${name})

-endmacro(gostai_add_test)
+endmacro(gostai_add_run_test)

 # Add translation to the target named _name_. It is intended to be called by
 # gostai_add_executable and gostai_add_library.


Disable NNPACK build on unsupported CPU architectures

Summary:
Few people complained in NNPACK repo about broken build on PPC64, as it specifically whitelists supported architecture in its CMakeLists.txt, and refuses to build on unsupported platforms. This commit explicitly disables NNPACK build (as part of Caffe2 build) on unsupported architectures.
Closes https://github.com/caffe2/caffe2/pull/1439

Differential Revision: D6288999

Pulled By: Maratyszcza

fbshipit-source-id: 76c40e9ce882356944b63968df8fd853f21ecd35


Added profiling flags.

Added profiling flags.

git-svn-id: e31799a7ad59d6ea355ca047c69e0aee8a59fcd3@2782 53f5c7ee-bee3-0310-bbc5-ea0e15fffd5e

--- cmake/OpenSyncTesting.cmake
+++ cmake/OpenSyncTesting.cmake
@@ -1,5 +1,11 @@
 ENABLE_TESTING()
 INCLUDE( CTest )
+
+SET( CMAKE_BUILD_TYPE PROFILING )
+SET( CMAKE_C_FLAGS_PROFILING "-g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wwrite-strings -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Compiler Flags" )
+SET( CMAKE_SHARED_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags" )
+SET( CMAKE_MODULE_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags" )
+SET( CMAKE_EXEC_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags" )

 MACRO( OPENSYNC_ADD_TEST _testName _testSource )


build: fix fallback call for requesting C/C++ standard

--- cmake/RequireStandard.cmake
+++ cmake/RequireStandard.cmake
@@ -25,6 +25,6 @@
     endif ()
   else ()
     # TODO: make this portable
-    set_property (TARGET COMPILE_FLAGS APPEND_STRING "-std=${standard}")
+    set_property (TARGET ${target} APPEND_STRING PROPERTY COMPILE_FLAGS "-std=${standard}")
   endif ()
 endfunction ()


correct python macro in cmake files (#977)

--- cmake/catkin_download.cmake
+++ cmake/catkin_download.cmake
@@ -56,7 +56,7 @@
   # this is because we want to check the md5 sum if it's given, and redownload
   # the target if the md5 sum does not match.
   add_custom_target(${target}
-    COMMAND ${PYTHON} ${catkin_EXTRAS_DIR}/test/download_checkmd5.py ${url} ${output} ${ARG_MD5} ${required}
+    COMMAND ${PYTHON_EXECUTABLE} ${catkin_EXTRAS_DIR}/test/download_checkmd5.py ${url} ${output} ${ARG_MD5} ${required}
     VERBATIM)

   if(ARG_EXCLUDE_FROM_ALL)


Revert generator per target to not pollute visual studio ui. One downside is that ALL_GENERATE will build all things generated even these that do not need the tool that triggered a rebuild.

--- cmake/fips_generators.cmake
+++ cmake/fips_generators.cmake
@@ -107,3 +107,17 @@
     endif()
 endmacro()

+macro(fips_handle_generators target)
+    if (CurProjectHasCodeGen)
+        if (NOT TARGET ALL_GENERATE)
+            add_custom_target(ALL_GENERATE
+                COMMAND ${PYTHON} ${FIPS_PROJECT_DIR}/.fips-gen.py ${CMAKE_BINARY_DIR}/fips_codegen.yml
+                WORKING_DIRECTORY ${FIPS_PROJECT_DIR})
+
+             if (CurTargetDependencies)
+                add_dependencies(ALL_GENERATE ${CurTargetDependencies})
+            endif()
+        endif()
+        add_dependencies(${target} ALL_GENERATE)
+    endif()
+endmacro()


Fixing a mis-use of the CMake install command.

The CMake install command is defined as:

install(TARGETS targets... [EXPORT <export-name>]
        [[ARCHIVE|LIBRARY|RUNTIME|FRAMEWORK|BUNDLE|
          PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE]
         [DESTINATION <dir>]
         [INCLUDES DESTINATION [<dir> ...]]
         [PERMISSIONS permissions...]
         [CONFIGURATIONS [Debug|Release|...]]
         [COMPONENT <component>]
         [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP]
        ] [...])

This means it can only take one parameter from the set of RUNTIME, LIBRARY, or ARCHIVE. If you set more than one of these it seems to gobble up the extra arguments and ignore the COMPONENT argument.

This adds a check to only set LIBRARY or ARCHIVE based on whether or not the library being built is shared.

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

--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -407,6 +407,11 @@
 endfunction()

 macro(add_llvm_library name)
+  cmake_parse_arguments(ARG
+    "SHARED"
+    ""
+    ""
+    ${ARGN})
   if( BUILD_SHARED_LIBS )
     llvm_add_library(${name} SHARED ${ARGN})
   else()
@@ -418,12 +423,17 @@
     set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
   else()
     if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LTO")
-      install(TARGETS ${name}
-        EXPORT LLVMExports
-        RUNTIME DESTINATION bin
-        LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-        ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-        COMPONENT ${name})
+      if(ARG_SHARED OR BUILD_SHARED_LIBS)
+        install(TARGETS ${name}
+          EXPORT LLVMExports
+          LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+          COMPONENT ${name})
+      else()
+        install(TARGETS ${name}
+          EXPORT LLVMExports
+          ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+          COMPONENT ${name})
+      endif()

       if (NOT CMAKE_CONFIGURATION_TYPES)
         add_custom_target(install-${name}