Backup.

Backup.

--- sheaves/component_definitions.cmake
+++ sheaves/component_definitions.cmake
@@ -65,8 +65,10 @@
 #
 # Set the cumulative Java binding library var for this component.
 #
-set(${COMPONENT}_JAVA_BINDING_LIBS ${${COMPONENT}_JAVA_BINDING_LIB}
-    CACHE STRING " Cumulative Java binding libraries for ${PROJECT_NAME}" FORCE)
+set(${COMPONENT}_JAVA_BINDING_LIBS
+    ${${COMPONENT}_JAVA_BINDING_LIB}
+    CACHE STRING " Cumulative Java binding libraries for ${PROJECT_NAME}"
+    FORCE)

 #
 # Set the cumulative Java binding jar variable for this component.
@@ -77,14 +79,18 @@
 #
 # Set the cumulative Python binding library var for this component.
 #
-set(${COMPONENT}_PYTHON_BINDING_LIBS ${${COMPONENT}_PYTHON_BINDING_LIB}
-    CACHE STRING " Cumulative Python binding libraries for ${PROJECT_NAME}" FORCE)
+set(${COMPONENT}_PYTHON_BINDING_LIBS
+    ${${COMPONENT}_PYTHON_BINDING_LIB}
+    CACHE STRING " Cumulative Python binding libraries for ${PROJECT_NAME}"
+    FORCE)

 #
 # Set the cumulative include path for this component.
 #
-set(${COMPONENT}_IPATHS ${${COMPONENT}_IPATH} ${CMAKE_BINARY_DIR}/include
-    CACHE STRING " Cumulative include paths for ${PROJECT_NAME}" FORCE)
+set(${COMPONENT}_IPATHS ${${COMPONENT}_IPATH}
+    ${CMAKE_BINARY_DIR}/include
+    CACHE STRING " Cumulative include paths for ${PROJECT_NAME}"
+    FORCE)

 include_directories(${${COMPONENT}_IPATHS})

@@ -111,9 +117,12 @@
         link_directories(${${COMPONENT}_OUTPUT_DIR})

         # Create the DLL.
-        add_library(${${COMPONENT}_DYNAMIC_LIB} SHARED ${${COMPONENT}_SRCS})
-        target_link_libraries(${${COMPONENT}_DYNAMIC_LIB} LINK_PRIVATE hdf5_cpp )
-        set_target_properties(${${COMPONENT}_DYNAMIC_LIB} PROPERTIES FOLDER "Library Targets")
+        add_library(${${COMPONENT}_DYNAMIC_LIB}
+            SHARED ${${COMPONENT}_SRCS})
+        target_link_libraries(${${COMPONENT}_DYNAMIC_LIB}
+            LINK_PRIVATE hdf5_cpp )
+        set_target_properties(${${COMPONENT}_DYNAMIC_LIB} PROPERTIES
+            FOLDER "Library Targets")

         # Override cmake's placing of "${${COMPONENT}_DYNAMIC_LIB}_EXPORTS
         # into the preproc symbol table.
@@ -123,30 +132,41 @@
     else()

         # Static library
-        add_library(${${COMPONENT}_STATIC_LIB} STATIC ${${COMPONENT}_SRCS})
-        set_target_properties(${${COMPONENT}_STATIC_LIB} PROPERTIES OUTPUT_NAME
+        add_library(${${COMPONENT}_STATIC_LIB}
+            STATIC ${${COMPONENT}_SRCS})
+        set_target_properties(${${COMPONENT}_STATIC_LIB}
+            PROPERTIES OUTPUT_NAME
             ${PROJECT_NAME} LINKER_LANGUAGE CXX)
         target_link_libraries(${${COMPONENT}_STATIC_LIB} hdf5_cpp )

         # Shared library
-        add_library(${${COMPONENT}_SHARED_LIB} SHARED ${${COMPONENT}_SRCS})
-        set_target_properties(${${COMPONENT}_SHARED_LIB} PROPERTIES OUTPUT_NAME
+        add_library(${${COMPONENT}_SHARED_LIB}
+            SHARED ${${COMPONENT}_SRCS})
+        set_target_properties(${${COMPONENT}_SHARED_LIB}
+            PROPERTIES OUTPUT_NAME
             ${PROJECT_NAME} LINKER_LANGUAGE CXX)
-        set_target_properties(${${COMPONENT}_SHARED_LIB} PROPERTIES
+        set_target_properties(${${COMPONENT}_SHARED_LIB}
+            PROPERTIES
             LINK_INTERFACE_LIBRARIES "")
-        target_link_libraries(${${COMPONENT}_SHARED_LIB} -Wl,-Bstatic hdf5_cpp -Wl,-Bdynamic)
-
-        # Override cmake's placing of "${COMPONENT_LIB}_EXPORTS into the preproc symbol table.
-        # CMake apparently detects the presence of cdecl_dllspec in the source and places
-        # -D<LIBRARY>_EXPORTS into the preproc symbol table no matter the platform.
-        set_target_properties(${${COMPONENT}_SHARED_LIB} PROPERTIES DEFINE_SYMBOL "")
+        target_link_libraries(${${COMPONENT}_SHARED_LIB}
+            -Wl,-Bstatic hdf5_cpp -Wl,-Bdynamic)
+
+        # Override cmake's placing of "${COMPONENT_LIB}_EXPORTS into the preproc
+        # symbol table. CMake apparently detects the presence of cdecl_dllspec in
+        # the source and places -D<LIBRARY>_EXPORTS into the preproc symbol
+        # table no matter the platform.
+        set_target_properties(${${COMPONENT}_SHARED_LIB}
+            PROPERTIES DEFINE_SYMBOL "")

         # Define the library version.
-        set_target_properties(${${COMPONENT}_SHARED_LIB} PROPERTIES VERSION ${LIB_VERSION})
+        set_target_properties(${${COMPONENT}_SHARED_LIB}
+            PROPERTIES VERSION ${LIB_VERSION})

         # Library alias definitions
-        add_dependencies(${PROJECT_NAME}-shared-lib ${${COMPONENT}_SHARED_LIB})
-        add_dependencies(${PROJECT_NAME}-static-lib ${${COMPONENT}_STATIC_LIB})
+        add_dependencies(${PROJECT_NAME}-shared-lib
+            ${${COMPONENT}_SHARED_LIB})
+        add_dependencies(${PROJECT_NAME}-static-lib
+            ${${COMPONENT}_STATIC_LIB})

     endif()

@@ -162,7 +182,7 @@
     include(${SWIG_USE_FILE})

     #
-    # Java ################################################################
+    # Java #################################################
     #

     set(SWIG_CXX_EXTENSION "cxx" CACHE STRING "Swig source file extension")
@@ -172,7 +192,8 @@
     include_directories(${${COMPONENT}_JAVA_BINDING_SRC_DIR})
     include_directories(${${COMPONENT}_COMMON_BINDING_SRC_DIR})

-    set_source_files_properties(${${COMPONENT}_JAVA_BINDING_SRC_DIR}/${${COMPONENT}_SWIG_JAVA_INTERFACE}
+    set_source_files_properties(
+        ${${COMPONENT}_JAVA_BINDING_SRC_DIR}/${${COMPONENT}_SWIG_JAVA_INTERFACE}
         PROPERTIES CPLUSPLUS ON)

     # Add the java binding library target
@@ -180,7 +201,8 @@
         ${${COMPONENT}_JAVA_BINDING_SRC_DIR}/${${COMPONENT}_SWIG_JAVA_INTERFACE})

     # Establish CXX as the linker language for this library
-    set_target_properties(${${COMPONENT}_JAVA_BINDING_LIB} PROPERTIES LINKER_LANGUAGE CXX)
+    set_target_properties(${${COMPONENT}_JAVA_BINDING_LIB} PROPERTIES
+        LINKER_LANGUAGE CXX)

     if(WIN64INTEL OR WIN64MSVC)
         swig_link_libraries(${${COMPONENT}_JAVA_BINDING_LIB} ${JDK_LIBS}
@@ -188,7 +210,8 @@
         set_target_properties(${${COMPONENT}_JAVA_BINDING_LIB} PROPERTIES
             FOLDER "Binding Targets - Java")
     else()
-        add_dependencies(${${COMPONENT}_JAVA_BINDING_LIB} ${${COMPONENT}_SHARED_LIB}
+        add_dependencies(${${COMPONENT}_JAVA_BINDING_LIB}
+            ${${COMPONENT}_SHARED_LIB}
             ${${COMPONENT}_SWIG_COMMON_INCLUDES_INTERFACE}
             ${${COMPONENT}_SWIG_COMMON_INTERFACE})
         target_link_libraries(${${COMPONENT}_JAVA_BINDING_LIB} ${JDK_LIBS}
@@ -201,8 +224,8 @@
         VERSION ${LIB_VERSION})

     # Create the bindings jar file
-    # Output path in windows differs slightly from Linux. Cmake wont allow a conditional inside add_custom_target
-    # So we have to do it outside.
+    # Output path in windows differs slightly from Linux. Cmake wont allow a
+    # conditional inside add_custom_target, so we have to do it outside.
     if(WIN64INTEL OR WIN64MSVC)
         # Set the cumulative classpath variable for this component
         set(${COMPONENT}_CLASSPATH
@@ -210,26 +233,36 @@
             CACHE STRING "Cumulative classpath for ${PROJECT_NAME}" FORCE)
         add_custom_target(${PROJECT_NAME}_java_binding.jar ALL
                DEPENDS ${${COMPONENT}_JAVA_BINDING_LIB}
-               set_target_properties(${PROJECT_NAME}_java_binding.jar PROPERTIES FOLDER "Component Binding Jars")
-        	   COMMAND ${CMAKE_COMMAND} -E copy ${${COMPONENT}_JAVA_BINDING_SRC_DIR}/base_client.java ${CMAKE_CURRENT_BINARY_DIR}
-               COMMAND ${CMAKE_COMMAND} -E copy ${${COMPONENT}_JAVA_BINDING_SRC_DIR}/base_server.java ${CMAKE_CURRENT_BINARY_DIR}
+               set_target_properties(${PROJECT_NAME}_java_binding.jar PROPERTIES
+                   FOLDER "Component Binding Jars")
+        	   COMMAND ${CMAKE_COMMAND} -E copy
+        	       ${${COMPONENT}_JAVA_BINDING_SRC_DIR}/base_client.java
+        	       ${CMAKE_CURRENT_BINARY_DIR}
+               COMMAND ${CMAKE_COMMAND} -E copy
+                   ${${COMPONENT}_JAVA_BINDING_SRC_DIR}/base_server.java
+                   ${CMAKE_CURRENT_BINARY_DIR}
                COMMAND ${CMAKE_COMMAND} -E echo "Compiling Java files..."
                COMMAND ${Java_JAVAC_EXECUTABLE} -classpath . -d . *.java
                COMMAND ${CMAKE_COMMAND} -E echo "Creating jar file..."
-               COMMAND ${Java_JAR_EXECUTABLE} cvf ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${${COMPONENT}_JAVA_BINDING_JAR}  bindings/java/*.class
+               COMMAND ${Java_JAR_EXECUTABLE} cvf
+                   ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${${COMPONENT}_JAVA_BINDING_JAR}
+                   bindings/java/*.class
                )

         # Java documentation
         if(DOC_TARGETS)
             add_custom_target(${PROJECT_NAME}-java-docs ALL
-                    COMMAND ${JDK_BIN_DIR}/javadoc -windowtitle "${PROJECT_NAME} documentation" -classpath "${${COMPONENT}_CLASSPATH}"
-                    -d  ${CMAKE_BINARY_DIR}/documentation/java/${PROJECT_NAME}
-                    *.java WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-                    DEPENDS ${${COMPONENT}_JAVA_BINDING_JAR}
+                    COMMAND ${JDK_BIN_DIR}/javadoc -windowtitle "${PROJECT_NAME}
+                        documentation" -classpath "${${COMPONENT}_CLASSPATH}"
+                        -d  ${CMAKE_BINARY_DIR}/documentation/java/${PROJECT_NAME}
+                        *.java WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+                        DEPENDS ${${COMPONENT}_JAVA_BINDING_JAR}
                     )
-            set_target_properties(${PROJECT_NAME}-java-docs PROPERTIES FOLDER "Documentation Targets")
+            set_target_properties(${PROJECT_NAME}-java-docs PROPERTIES
+                FOLDER "Documentation Targets")
         endif()
-    set_target_properties(${PROJECT_NAME}_java_binding.jar PROPERTIES FOLDER "Library Jars")
+    set_target_properties(${PROJECT_NAME}_java_binding.jar PROPERTIES
+        FOLDER "Library Jars")
     else()
         # Set the cumulative classpath variable for this component
         set(${COMPONENT}_CLASSPATH
@@ -237,21 +270,28 @@
             CACHE STRING "Cumulative classpath for ${PROJECT_NAME}" FORCE)
         add_custom_target(${PROJECT_NAME}_java_binding.jar ALL
                DEPENDS ${${COMPONENT}_JAVA_BINDING_LIB}
-        	   COMMAND ${CMAKE_COMMAND} -E copy_if_different ${${COMPONENT}_JAVA_BINDING_SRC_DIR}/base_client.java ${CMAKE_CURRENT_BINARY_DIR}
-               COMMAND ${CMAKE_COMMAND} -E copy_if_different ${${COMPONENT}_JAVA_BINDING_SRC_DIR}/base_server.java ${CMAKE_CURRENT_BINARY_DIR}
+        	   COMMAND ${CMAKE_COMMAND} -E copy_if_different
+        	       ${${COMPONENT}_JAVA_BINDING_SRC_DIR}/base_client.java
+        	       ${CMAKE_CURRENT_BINARY_DIR}
+               COMMAND ${CMAKE_COMMAND} -E copy_if_different
+                   ${${COMPONENT}_JAVA_BINDING_SRC_DIR}/base_server.java
+                   ${CMAKE_CURRENT_BINARY_DIR}
                COMMAND ${CMAKE_COMMAND} -E echo "Compiling Java files..."
                COMMAND ${JAVAC_EXECUTABLE} -classpath . -d . *.java
                COMMAND ${CMAKE_COMMAND} -E echo "Creating jar file..."
-               COMMAND ${JAR_EXECUTABLE} cvf ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${${COMPONENT}_JAVA_BINDING_JAR}  bindings/java/*.class
+               COMMAND ${JAR_EXECUTABLE} cvf
+                   ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${${COMPONENT}_JAVA_BINDING_JAR}
+                   bindings/java/*.class
                )

         # Java documentation
         if(DOC_TARGETS)
             add_custom_target(${PROJECT_NAME}-java-docs ALL
-                    COMMAND ${JDK_BIN_DIR}/javadoc -windowtitle "${PROJECT_NAME} documentation" -classpath "${${COMPONENT}_CLASSPATH}"
-                    -d  ${CMAKE_BINARY_DIR}/documentation/java/${PROJECT_NAME}
-                    *.java WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-                    DEPENDS ${${COMPONENT}_JAVA_BINDING_JAR}
+                    COMMAND ${JDK_BIN_DIR}/javadoc -windowtitle "${PROJECT_NAME}
+                        documentation" -classpath "${${COMPONENT}_CLASSPATH}"
+                        -d  ${CMAKE_BINARY_DIR}/documentation/java/${PROJECT_NAME}
+                        *.java WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+                        DEPENDS ${${COMPONENT}_JAVA_BINDING_JAR}
                    )
         endif()
     endif()
@@ -259,7 +299,7 @@
     mark_as_advanced(FORCE ${COMPONENT}_CLASSPATH)

     #
-    # CSharp ##############################################################
+    # CSharp ###############################################
     #

     set(CMAKE_SWIG_FLAGS -c++ -namespace sheaf)


Fixed order or Kaldi libraries returned by FindKaldi.cmake script.


Update cmake/toolchain.cmake

Update cmake/toolchain.cmake

Co-authored-by: Hugues Kamba <402748a27f75fbc914c63b0503c6fbcb2aac22b4@users.noreply.github.com>


Fix qemu parameter error to work with latest qemu source build.

--- platform/x86_64/pc/flags.cmake
+++ platform/x86_64/pc/flags.cmake
@@ -34,6 +34,6 @@
     COMMAND qemu-img create -f raw disk.img 128M)

 add_custom_target(run
-    COMMAND qemu-system-x86_64 --enable-kvm -m 1G -machine q35, -cpu host -smp 3 -d int,cpu_reset,guest_errors -drive id=disk,file=disk.img,if=none -device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0 -net nic,model=virtio, -net dump,file=../dump.pcap -net bridge,br=virbr0 -device ich9-intel-hda -device hda-output -device ich9-usb-uhci3 -cdrom "ISO/os.iso" -boot d -device virtio-vga,virgl=on -display gtk,gl=on
+    COMMAND qemu-system-x86_64 --enable-kvm -m 1G -machine q35, -cpu host -smp 3 -d int,cpu_reset,guest_errors -drive id=disk,file=disk.img,if=none -device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0 -net nic,model=virtio -net bridge,br=virbr0 -device ich9-intel-hda -device hda-output -device ich9-usb-uhci3 -cdrom "ISO/os.iso" -boot d -device virtio-vga,virgl=on -display gtk,gl=on
     DEPENDS image
     DEPENDS disk.img)


expose macro result

expose macro result

--- cmake/FileSystemUtils.cmake
+++ cmake/FileSystemUtils.cmake
@@ -22,10 +22,12 @@
     if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" STREQUAL "2.8"
         AND ${CMAKE_PATCH_VERSION} LESS 12)

-        get_filename_component(result ${curpath} PATH)
+        get_filename_component(result_tmp ${curpath} PATH)
     else()
-        get_filename_component(result ${curpath} DIRECTORY)
+        get_filename_component(result_tmp ${curpath} DIRECTORY)
     endif()
+
+    set(${result} ${result_tmp})
     MESSAGE(STATUS "result=${result}")
 ENDMACRO()


Add SSE4.2 check for mac

Add SSE4.2 check for mac

--- cmake/Modules/FindSSE.cmake
+++ cmake/Modules/FindSSE.cmake
@@ -84,6 +84,14 @@
     else(SSE41_TRUE)
       set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host")
     endif(SSE41_TRUE)
+
+    string(REGEX REPLACE "^.*(SSE4.2).*$" "\\1" SSE_THERE ${CPUINFO})
+    string(COMPARE EQUAL "SSE4.2" "${SSE_THERE}" SSE42_TRUE)
+    if(SSE42_TRUE)
+      set(SSE4_2_FOUND true CACHE BOOL "SSE4.2 available on host")
+    else(SSE42_TRUE)
+      set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host")
+    endif(SSE42_TRUE)
   elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
      # TODO
     set(SSE2_FOUND   true  CACHE BOOL "SSE2 available on host")


Support Solaris unused sections' gc link syntax.

It is not clear if this would work or not with LLVM_NO_DEAD_STRIP
binaries, so be conservative for now.

Patch by Xan López.

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

--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -186,6 +186,9 @@
         # ld64's implementation of -dead_strip breaks tools that use plugins.
         set_property(TARGET ${target_name} APPEND_STRING PROPERTY
                      LINK_FLAGS " -Wl,-dead_strip")
+      elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+        set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+                     LINK_FLAGS " -Wl,-z -Wl,discard-unused=sections")
       elseif(NOT WIN32 AND NOT LLVM_LINKER_IS_GOLD)
         # Object files are compiled with -ffunction-data-sections.
         # Versions of bfd ld < 2.23.1 have a bug in --gc-sections that breaks


ffmpeg: remove compatibility glue code

ffmpeg: remove compatibility glue code

--- 3rdparty/ffmpeg/ffmpeg.cmake
+++ 3rdparty/ffmpeg/ffmpeg.cmake
@@ -23,16 +23,3 @@
              DESTINATION_DIR ${CMAKE_CURRENT_LIST_DIR})

 include(${CMAKE_CURRENT_LIST_DIR}/ffmpeg_version.cmake)
-
-# Compatibility glue code
-set(FFMPEG_libavcodec_FOUND 1)
-set(FFMPEG_libavformat_FOUND 1)
-set(FFMPEG_libavutil_FOUND 1)
-set(FFMPEG_libswscale_FOUND 1)
-set(FFMPEG_libavresample_FOUND 1)
-
-set(FFMPEG_libavcodec_VERSION ${ALIASOF_libavcodec_VERSION})
-set(FFMPEG_libavformat_VERSION ${ALIASOF_libavformat_VERSION})
-set(FFMPEG_libavutil_VERSION ${ALIASOF_libavutil_VERSION})
-set(FFMPEG_libswscale_VERSION ${ALIASOF_libswscale_VERSION})
-set(FFMPEG_libavresample_VERSION ${ALIASOF_libavresample_VERSION})


Fix export of CTKTesting in CTKConfig

Fix export of CTKTesting in CTKConfig

This commit finalizes the re-factoring initiated in 613b820

--- CMake/LastConfigureStep/CTKGenerateCTKConfig.cmake
+++ CMake/LastConfigureStep/CTKGenerateCTKConfig.cmake
@@ -37,7 +37,6 @@
 # Generate the CTKConfig.cmake file in the build tree. Also configure
 # one for installation.  The file tells external projects how to use CTK.
 #
-

 message(STATUS "Including CMake built-in module CMakePackageConfigHelpers")
 include(CMakePackageConfigHelpers OPTIONAL)
@@ -145,7 +144,7 @@
 set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}set(CTK_QTDESIGNERPLUGINS_DIR \"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}\")\n")
 set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}# CTK library include dirctories\n")
 set(_include_dirs)
-foreach(lib ${CTK_LIBRARIES})
+foreach(lib ${CTK_LIBRARIES} CTKTesting)
   set(${lib}_INCLUDE_DIRS ${${lib}_SOURCE_DIR} ${${lib}_BINARY_DIR})
   ctkFunctionGetIncludeDirs(${lib}_INCLUDE_DIRS ${lib})
   list(APPEND _include_dirs ${${lib}_INCLUDE_DIRS})
@@ -153,7 +152,6 @@
 endforeach()
 list(REMOVE_DUPLICATES _include_dirs)
 set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}set(CTK_INCLUDE_DIRS \"${_include_dirs}\")\n")
-set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}list(APPEND CTK_INCLUDE_DIRS \"${CTKTesting_INCLUDE_DIRS}\")\n")
 set(CTK_CONFIG_CODE "${CTK_CONFIG_CODE}# CTK library directories that could be used for linking\n")
 foreach(lib ${CTK_LIBRARIES})
   set(${lib}_LIBRARY_DIRS "")


Simplify external protobuf script

Simplify external protobuf script

--- tensorflow_cc/cmake/ProtobufExternal.cmake
+++ tensorflow_cc/cmake/ProtobufExternal.cmake
@@ -18,17 +18,14 @@
   protobuf-external
   PREFIX protobuf
   URL "${PROTOBUF_ARCHIVE}"
-  BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/protobuf"
   CMAKE_CACHE_ARGS
     "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
     "-Dprotobuf_BUILD_TESTS:BOOL=OFF"
     "-Dprotobuf_BUILD_EXAMPLES:BOOL=OFF"
     "-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}"
   SOURCE_SUBDIR cmake
-  BUILD_ALWAYS 1
-  STEP_TARGETS build
   INSTALL_COMMAND ""
 )

-install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/protobuf/cmake_install.cmake")
+install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/protobuf/src/protobuf-external-build/cmake_install.cmake")


BUG: ITKFixedPointInverseDisplacementField wrapping test config update

Adds:

 matt.mccormick@kitware.com (1):
        STYLE: Move Python test to wrapping/test/CMakeLists.txt

This will improve the nightly Doxygen builds.

--- Modules/Remote/FixedPointInverseDisplacementField.remote.cmake
+++ Modules/Remote/FixedPointInverseDisplacementField.remote.cmake
@@ -1,5 +1,5 @@
 itk_fetch_module(FixedPointInverseDisplacementField
   "Computes the inverse of a displacement field."
   GIT_REPOSITORY ${git_protocol}://github.com/InsightSoftwareConsortium/ITKFixedPointInverseDisplacementField.git
-  GIT_TAG 66f94a4ff6a8fbe5ac8501983f4492bf2c228bd6
+  GIT_TAG 0906a379e360381d8babc05d851aabd0b3ea8b16
   )


x11_egl: search for glesv1_cm, toggle DEQP_SUPPORT_GLES1 on if found

Some tests require GLES1 support and report test failure if support
has not been built. Patch changes build time configure to check GLES1
via pkg-config. If it is found, we turn on GLES1 support so that tests
will run and pass.

Change-Id: I586464c5fb7bffc40355caf57b30438f37ce1f6c
Signed-off-by: Tapani Pälli <cdcb67a5e49297de94340ca09f25994bd5e7f762@intel.com>

--- targets/x11_egl/x11_egl.cmake
+++ targets/x11_egl/x11_egl.cmake
@@ -30,5 +30,26 @@
 	message(FATAL_ERROR "X11 development package not found")
 endif ()

+# Support GLES1, we use pkg-config because some distributions do not ship
+# GLES1 libraries and headers, this way user can override search path by
+# using PKG_CONFIG_PATH environment variable
+FIND_PACKAGE(PkgConfig)
+PKG_CHECK_MODULES(GLES1 glesv1_cm)
+if (GLES1_LIBRARIES)
+	set(DEQP_SUPPORT_GLES1	ON)
+	set(DEQP_GLES1_LIBRARIES ${GLES1_LIBRARIES})
+	set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} -L${GLES1_LIBRARY_DIRS})
+	if ("${PKG_GLES1_INCLUDE_DIRS}" STREQUAL "")
+		# PKG_GLES1_INCLUDE_DIRS empty, see if matching include
+		# path (GLES/gl.h) exists beside library directory
+		set(GLES1_INCLUDE "${GLES1_LIBDIR}/../include")
+		if (EXISTS ${GLES1_INCLUDE}/GLES/gl.h)
+			include_directories(${GLES1_INCLUDE})
+		else()
+			message(FATAL_ERROR "Could not find include path for GLES1 headers")
+		endif (EXISTS ${GLES1_INCLUDE}/GLES/gl.h)
+	endif ("${PKG_GLES1_INCLUDE_DIRS}" STREQUAL "")
+endif (GLES1_LIBRARIES)
+
 set(DEQP_PLATFORM_LIBRARIES ${X11_LIBRARIES})
 include_directories(${X11_INCLUDE_DIR})


Fix header install

Fix header install

--- CMake/Utilities.cmake
+++ CMake/Utilities.cmake
@@ -108,7 +108,7 @@
 endif(ENABLE_SHARED_LIBRARIES)

 INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-    DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ATK/${${PREFIX}_FOLDER}
+    DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ATK/
     FILES_MATCHING PATTERN *.h
 )


The HAL version is read from package.xml

--- cmake/FindHAL.cmake
+++ cmake/FindHAL.cmake
@@ -243,7 +243,25 @@
         set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}")
         message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_HAL_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}")
     endif()
-
+
+    #Checking HAL patch or release version
+    unset(VERSION_INFO)
+    find_file(PACKAGE_FILE NAMES package.xml PATHS ${STM32_CUBE_${FAMILY}_PATH})
+    if(PACKAGE_FILE)
+        file(READ ${PACKAGE_FILE} PACKAGE_FILE_CONTENT)
+        string(REGEX MATCH "PackDescription Release=\"FW.${FAMILY}.([0-9.])+\"( Patch=\"FW.${FAMILY}.([0-9.]+)\")?" VERSION_INFO ${PACKAGE_FILE_CONTENT})
+        if(CMAKE_MATCH_3) # This is the "Patch" revision
+            set(HAL_${COMP}_VERSION ${CMAKE_MATCH_3})
+            set(HAL_VERSION ${CMAKE_MATCH_3})
+        else(CMAKE_MATCH_1) #This is the "Release" version
+            set(HAL_${COMP}_VERSION ${CMAKE_MATCH_1})
+            set(HAL_VERSION ${CMAKE_MATCH_1})
+        endif()
+    endif()
+    if(NOT VERSION_INFO)
+        message(STATUS "Could not read the HAL version from package.xml for ${COMP}")
+    endif()
+
     find_path(HAL_${FAMILY}_PATH
         NAMES Inc/stm32${FAMILY_L}xx_hal.h
         PATHS "${STM32_HAL_${FAMILY}_PATH}" "${STM32_CUBE_${FAMILY}_PATH}/Drivers/STM32${FAMILY}xx_HAL_Driver"


winBuild: update cmake find nix_library

winBuild: update cmake find nix_library

--- cmake/FindNIX.cmake
+++ cmake/FindNIX.cmake
@@ -12,6 +12,7 @@
   PATH_SUFFIXES nix)

 find_library(NIX_LIBRARY NAMES nix libnix
+  HINTS $ENV{NIX_BUILD_DIR}
   HINTS ${NIX_INCLUDE_DIR}/../lib
   HINTS ${NIX_INCLUDE_DIR}/../build
   /usr/local/lib


Provide libgcc and libiconv with which FFmpeg has been built

--- cmake/Install.cmake
+++ cmake/Install.cmake
@@ -22,6 +22,14 @@
             COMPONENT binaries)
 endif()

+if (WINDOWS)
+    install(FILES
+            "${CMAKE_SOURCE_DIR}/deps/Windows-i386/libgcc_s_dw2-1.dll"
+            "${CMAKE_SOURCE_DIR}/deps/Windows-i386/libiconv-2.dll"
+            DESTINATION bin
+            COMPONENT binaries)
+endif()
+
 install(FILES "${CMAKE_SOURCE_DIR}/License.txt" "${CMAKE_SOURCE_DIR}/ReadMe.txt" "${CMAKE_SOURCE_DIR}/Authors.txt"
         DESTINATION ${INSTALL_MISC_DIR}
         COMPONENT resources)


Added menu shortcuts to windows installer

--- cmake/Package.cmake
+++ cmake/Package.cmake
@@ -10,19 +10,40 @@
 set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
 set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
 set(CPACK_PACKAGE_FILE_NAME "fast")
-set(CPACK_COMPONENT_FAST_REQUIRED ON)

 if(WIN32 AND NOT UNIX)
     ## Windows
     set(CPACK_GENERATOR "NSIS")
+    set(CPACK_MONOLITHIC_INSTALL ON)
     set(CPACK_PACKAGE_FILE_NAME "fast_windows_${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
     set(CPACK_PACKAGE_INSTALL_DIRECTORY "FAST")
     set(CPACK_NSIS_MUI_ICON ${PROJECT_SOURCE_DIR}/doc/images/fast_icon.ico)
     set(CPACK_NSIS_MUI_UNICON ${PROJECT_SOURCE_DIR}/doc/images/fast_icon.ico)
     set(CPACK_NSIS_MODIFY_PATH ON)
-    set(CPACK_COMPONENTS_ALL fast)
-    set(CPACK_COMPONENT_FAST_DISPLAY_NAME "FAST")
-    set(CPACK_COMPONENT_FAST_DESCRIPTION "FAST framework: executables, examples, libraries and headers.")
+    # Start menu items
+    set(CPACK_NSIS_MENU_LINKS
+        "fast\\\\bin\\\\UFFviewer"
+        "Ultrasound File Format Viewer"
+        "fast\\\\bin\\\\runPipeline"
+        "Run pipelines"
+        "fast\\\\bin\\\\OpenIGTLinkServer"
+        "OpenIGTLink Server"
+        "fast\\\\bin\\\\downloadTestData"
+        "Download test data (~2GB)"
+        "http://fast.eriksmistad.no"
+        "FAST Webpage"
+        "Uninstall.exe"
+        "Uninstall"
+    )
+    # Some more shortcuts
+    set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
+        CreateShortCut \\\"$SMPROGRAMS\\\\FAST\\\\Examples.lnk\\\" \\\"$INSTDIR\\\\fast\\\\bin\\\"
+        CreateShortCut \\\"$SMPROGRAMS\\\\FAST\\\\Data Folder.lnk\\\" \\\"C:\\\\ProgramData\\\\FAST\\\"
+    ")
+    set(CPACK_NSIS_DELETE_ICONS_EXTRA "
+        Delete \\\"$SMPROGRAMS\\\\FAST\\\\Examples.lnk\\\"
+        Delete \\\"$SMPROGRAMS\\\\FAST\\\\Data Folder.lnk\\\"
+    ")
     include(CPack) # Must be before cpack_ macros
 else()
     ## UNIX


Force duk_console to depend on duktape.

Force duk_console to depend on duktape.

--- cmake/duktape.cmake
+++ cmake/duktape.cmake
@@ -65,4 +65,5 @@
         ${CMAKE_SOURCE_DIR}/duktape-2.3.0/extras/console/duk_console.c
         ${CMAKE_SOURCE_DIR}/duktape-2.3.0/extras/console/duk_console.h)
     target_include_directories(duk_console PRIVATE ${DUKTAPE_INCLUDE_DIR})
+    target_link_libraries(duk_console PRIVATE ${DUKTAPE_LIBRARY})
 endfunction()


CTest: Do not try to manipulate xml submission files with sed

Due to this sed magic we might end up with two identical keys in
Configure.xml. Unfortunately, this terribly confuses CDash.

--- tests/run_testsuite.cmake
+++ tests/run_testsuite.cmake
@@ -523,27 +523,6 @@
     )
 ENDIF()

-IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
-  #
-  # Only use the following sed command on GNU userlands:
-  #
-  # TODO: Come up with a more robust way to inject this that also works on
-  # BSD and Mac
-  #
-  FILE(GLOB _xml_files ${_path}/*.xml)
-  EXECUTE_PROCESS(COMMAND sed -i -e
-    s/CompilerName=\\"\\"/CompilerName=\\"${_compiler_name}\\"\\n\\tCompilerVersion=\\"${_compiler_version}\\"/g
-    ${_xml_files}
-    OUTPUT_QUIET RESULT_VARIABLE  _res
-    )
-  IF(NOT "${_res}" STREQUAL "0")
-    MESSAGE(FATAL_ERROR "
-  \"sed\" failed. Bailing out.
-  "
-      )
-  ENDIF()
-ENDIF()
-
 FILE(WRITE ${_path}/Update.xml
 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
 <Update mode=\"Client\" Generator=\"ctest-${CTEST_VERSION}\">


these are gcc-specific flags - add a guard

--- source/suppress-warnings.cmake
+++ source/suppress-warnings.cmake
@@ -14,6 +14,8 @@

 message("suppressing warnings from mbed-hal-st-stm32cubef4")

-set_target_properties(mbed-hal-st-stm32cubef4
-    PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-variable -Wno-unused-parameter"
-)
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+    set_target_properties(mbed-hal-st-stm32cubef4
+        PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-variable -Wno-unused-parameter"
+    )
+endif()


ENH: remove the .sh extension for quick application launchers

--- CMake/OTBWrapperMacros.cmake
+++ CMake/OTBWrapperMacros.cmake
@@ -41,16 +41,16 @@

      if (NOT WIN32)
        configure_file( ${CMAKE_SOURCE_DIR}/CMake/otbcli.sh.in
-                       ${CMAKE_CURRENT_BINARY_DIR}/otbcli_${APPLICATION_NAME}.sh
+                       ${CMAKE_CURRENT_BINARY_DIR}/otbcli_${APPLICATION_NAME}
                        @ONLY )
-       install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/otbcli_${APPLICATION_NAME}.sh
+       install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/otbcli_${APPLICATION_NAME}
                DESTINATION ${OTB_INSTALL_BIN_DIR_CM24})

        if (WRAP_QT)
            configure_file( ${CMAKE_SOURCE_DIR}/CMake/otbgui.sh.in
-                           ${CMAKE_CURRENT_BINARY_DIR}/otbgui_${APPLICATION_NAME}.sh
+                           ${CMAKE_CURRENT_BINARY_DIR}/otbgui_${APPLICATION_NAME}
                            @ONLY )
-           install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/otbgui_${APPLICATION_NAME}.sh
+           install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/otbgui_${APPLICATION_NAME}
                    DESTINATION ${OTB_INSTALL_BIN_DIR_CM24})
        endif(WRAP_QT)
      endif(NOT WIN32)


Adding macro vtk_tests_python() and add_test_python()

This macro avoids a lot of boiler plate cmake code to add python tests. However
some tests may not fit the pattern and wouldnt be able to use this macro.

Change-Id: Ie17ecb417c6c5060f0a9cd21b71662830845291e

--- CMake/vtkTestingMacros.cmake
+++ CMake/vtkTestingMacros.cmake
@@ -130,10 +130,63 @@
 endmacro()

 # -----------------------------------------------------------------------------
+# vtk_tests_python() macro takes a list of python files and makes them into
+# proper python tests.
+macro(vtk_tests_python)
+  if(VTK_PYTHON_EXE)
+    foreach(test ${ARGV})
+      get_filename_component(TName ${test} NAME_WE)
+      if(VTK_DATA_ROOT)
+        string (REPLACE "vtk" "" _baselinedname ${vtk-module})
+        add_test(NAME ${vtk-module}Python-${TName}
+          COMMAND ${VTK_PYTHON_EXE}
+          ${CMAKE_CURRENT_SOURCE_DIR}/${test}
+          -D ${VTK_DATA_ROOT}
+          -B ${VTK_DATA_ROOT}/Baseline/${_baselinedname})
+      else()
+        add_test(NAME ${vtk-module}Python-${TName}
+          COMMAND ${VTK_PYTHON_EXE}
+          ${CMAKE_CURRENT_SOURCE_DIR}/${test}
+          ${${TName}_ARGS})
+      endif()
+    endforeach()
+  else()
+    messge(FATAL "VTK_PYTHON_EXE not set")
+  endif()
+
+endmacro(vtk_tests_python)
+
+# -----------------------------------------------------------------------------
+# add_test_python() macro takes a python file and an optional base directory where the
+# corresponding test image is found and list of python files and makes them into
+# proper python tests.
+macro(add_test_python)
+  if(VTK_PYTHON_EXE)
+    # Parse Command line args
+    get_filename_component(TName ${ARGV0} NAME_WE)
+    string (REPLACE "vtk" "" _baselinedname ${vtk-module})
+    # Check if data root and second parameter is present
+    if(VTK_DATA_ROOT AND NOT ARGV1)
+      add_test(NAME ${vtk-module}Python-${TName}
+        COMMAND ${VTK_PYTHON_EXE}
+        ${CMAKE_CURRENT_SOURCE_DIR}/${TName}.py
+        -D ${VTK_DATA_ROOT}
+        -B ${VTK_DATA_ROOT}/Baseline/${ARGV1})
+    else()
+      add_test(NAME ${vtk-module}Python-${TName}
+        COMMAND ${VTK_PYTHON_EXE}
+        ${CMAKE_CURRENT_SOURCE_DIR}/${TName}.py
+        ${${TName}_ARGS})
+    endif()
+  else()
+    messge(FATAL "VTK_PYTHON_EXE not set")
+  endif()
+endmacro(add_test_python)
+
+# -----------------------------------------------------------------------------
 # add_test_tcl() macro takes a tcl file and an optional base directory where the
 # corresponding test image is found and list of tcl files and makes them into
 # proper tcl tests.
-
 macro(add_test_tcl)
   if(VTK_TCL_EXE)
     # Parse Command line args


[Fix] for a depency bug "[#3] XMLRPC_REQUEST not defined?" for linux build.

git-svn-id: 65dd0ccd495961f396d5302e5521154b071f0302@1106 5b2332b8-efa3-11de-8684-7d64432d61a3

--- CMakeModules/XmlRpcEpi.cmake
+++ CMakeModules/XmlRpcEpi.cmake
@@ -18,6 +18,7 @@
 elseif (UNIX)
   set(XMLRPCEPI_PREFIX_GUESSES
       /opt/xmlrpc-epi
+      /usr/include
       /usr/local
       /usr/lib/xmlrpc-epi
       /usr/local/xmlrpc-epi
@@ -43,7 +44,7 @@
   set(XMLRPCEPI_INCLUDE_DIR "${XMLRPC-EPI_INCLUDE_DIRS}")
 else ()
   message(STATUS "try to find xmlrpc-epi from guessed paths")
-  find_path(XMLRPCEPI_INCLUDE_DIR xmlrpc.h HINTS ${XMLRPCEPI_INC_SEARCH_PATH} ${XMLRPCEPI_PKGC_INCLUDE_DIRS})
+  find_path(XMLRPCEPI_INCLUDE_DIR xmlrpc.h HINTS ${XMLRPCEPI_INC_SEARCH_PATH} ${XMLRPCEPI_PKGC_INCLUDE_DIRS} ${XMLRPCEPI_PREFIX_PATH})
   if (MSVC)
     find_path(XMLRPCEPI_LIBRARY_DIR xmlrpcepi.lib HINTS ${XMLRPCEPI_LIB_SEARCH_PATH})
   else ()


android: updated toolchain file

android: updated toolchain file

* support for ndk version r8d+
* improved x86_64 host machine support
* support non-release NDK layouts

--- cmake/AndroidToolchain.cmake
+++ cmake/AndroidToolchain.cmake
@@ -1,5 +1,5 @@
 # Copyright (c) 2010-2011, Ethan Rublee
-# Copyright (c) 2011-2012, Andrey Kamaev
+# Copyright (c) 2011-2013, Andrey Kamaev
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -35,7 +35,6 @@
 #
 #  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
-#  Git commit: 084b1c796900b0825fc4e0593ab3143da3f3a90e
 #
 #  Usage Linux:
 #   $ export ANDROID_NDK=/absolute/path/to/the/android-ndk
@@ -282,8 +281,19 @@
 #     [+] updated for NDK r8c
 #     [+] added support for clang compiler
 #   - December 2012
+#     [+] suppress warning about unused CMAKE_TOOLCHAIN_FILE variable
+#     [+] adjust API level to closest compatible as NDK does
 #     [~] fixed ccache full path search
 #     [+] updated for NDK r8d
+#     [~] compiler options are aligned with NDK r8d
+#   - March 2013
+#     [+] updated for NDK r8e (x86 version)
+#     [+] support x86_64 version of NDK
+#   - April 2013
+#     [+] support non-release NDK layouts (from Linaro git and Android git)
+#     [~] automatically detect if explicit link to crtbegin_*.o is needed
+#   - June 2013
+#     [~] fixed stl include path for standalone toolchain made by NDK >= r8c
 # ------------------------------------------------------------------------------

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

 get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
@@ -312,7 +326,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} -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
+set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
 if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS)
  if( CMAKE_HOST_WIN32 )
   file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS )
@@ -456,17 +470,30 @@
  endif()
 endif()

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

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

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

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

 # choose target ABI
@@ -752,6 +825,7 @@
   list( GET __availableToolchainArchs ${__idx} __toolchainArch )
   if( __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
    list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion )
+   string( REPLACE "x" "99" __toolchainVersion "${__toolchainVersion}")
    if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion )
     set( __toolchainMaxVersion "${__toolchainVersion}" )
     set( __toolchainIdx ${__idx} )
@@ -779,11 +853,22 @@
 # choose native API level
 __INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL )
 string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
-# TODO: filter out unsupported levels
+# adjust API level
+set( __real_api_level ${ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME}} )
+foreach( __level ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
+ if( NOT __level GREATER ANDROID_NATIVE_API_LEVEL AND NOT __level LESS __real_api_level )
+  set( __real_api_level ${__level} )
+ endif()
+endforeach()
+if( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL EQUAL __real_api_level )
+ message( STATUS "Adjusting Android API level 'android-${ANDROID_NATIVE_API_LEVEL}' to 'android-${__real_api_level}'")
+ set( ANDROID_NATIVE_API_LEVEL ${__real_api_level} )
+endif()
+unset(__real_api_level)
 # validate
 list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx )
 if( __levelIdx EQUAL -1 )
- message( SEND_ERROR "Specified Android native API level (${ANDROID_NATIVE_API_LEVEL}) is not supported by your NDK/toolchain." )
+ message( SEND_ERROR "Specified Android native API level 'android-${ANDROID_NATIVE_API_LEVEL}' is not supported by your NDK/toolchain." )
 else()
  if( BUILD_WITH_ANDROID_NDK )
   __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
@@ -893,7 +978,11 @@
  set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" )

  if( NOT ANDROID_STL STREQUAL "none" )
-  set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" )
+  set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/include/c++/${ANDROID_COMPILER_VERSION}" )
+  if( NOT EXISTS "${ANDROID_STL_INCLUDE_DIRS}" )
+   # old location ( pre r8c )
+   set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" )
+  endif()
   if( ARMEABI_V7A AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" )
    list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" )
   elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" )
@@ -944,11 +1033,11 @@
 elseif( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" )
  string( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}")
  string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-4.6" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
- if( NOT EXISTS "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}/bin/clang${TOOL_OS_SUFFIX}" )
-  message( FATAL_ERROR "Could not find the " )
+ if( NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}/bin/clang${TOOL_OS_SUFFIX}" )
+  message( FATAL_ERROR "Could not find the Clang compiler driver" )
  endif()
  set( ANDROID_COMPILER_IS_CLANG 1 )
- set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
+ set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
 else()
  set( ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
  unset( ANDROID_COMPILER_IS_CLANG CACHE )
@@ -962,7 +1051,7 @@

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

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

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

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

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

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

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

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

@@ -1280,7 +1396,14 @@
 endif()

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

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

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

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

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

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


fix up re-adding of PDB for cmake-based builds

--- cmake/LLDBDependencies.cmake
+++ cmake/LLDBDependencies.cmake
@@ -15,8 +15,7 @@
   # Plugins
   lldbPluginDisassemblerLLVM
   lldbPluginSymbolFileDWARF
-  # TODO add this back in once LLVM catches up to SymbolFilePDB requirements
-  # lldbPluginSymbolFilePDB
+  lldbPluginSymbolFilePDB
   lldbPluginSymbolFileSymtab
   lldbPluginDynamicLoaderStatic
   lldbPluginDynamicLoaderPosixDYLD


CMake: chekc if installed formatting hook is up-to-date

--- cmake/clang-cpp-checks.cmake
+++ cmake/clang-cpp-checks.cmake
@@ -2,8 +2,15 @@

 # Check if the git pre-commit hook for formatting is installed:
 IF(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
-    IF(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit-clang-format")
+    SET(HOOK_SRC "${CMAKE_SOURCE_DIR}/etc/git-hooks/pre-commit-clang-format-hook")
+    SET(HOOK_DST "${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit-clang-format")
+    IF(NOT EXISTS ${HOOK_DST})
         MESSAGE(WARNING "Git hooks are not installed - consider installing them via ${CMAKE_SOURCE_DIR}/etc/git-hooks/install-hooks.sh")
+    ELSE()
+        EXECUTE_PROCESS(COMMAND "cmake" "-E" "compare_files" ${HOOK_SRC} ${HOOK_DST} RESULT_VARIABLE HOOKS_DIFFER)
+        IF(${HOOKS_DIFFER})
+            MESSAGE(WARNING "Git hooks are outdated - consider updating them via ${CMAKE_SOURCE_DIR}/etc/git-hooks/install-hooks.sh")
+        ENDIF()
     ENDIF()
 ENDIF()


OpenSSL MinGW: Link to crypt32.lib

OpenSSL MinGW: Link to crypt32.lib

--- cmake/find/FindOpenSSL.cmake
+++ cmake/find/FindOpenSSL.cmake
@@ -363,8 +363,14 @@
     set_target_properties(OpenSSL::Crypto PROPERTIES
       INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
     find_package(Threads REQUIRED)
+    if(MINGW)
+      # https://github.com/openssl/openssl/issues/1061
+      set(_openssl_mingw_crypt "crypt32")
+    else()
+      set(_openssl_mingw_crypt "")
+    endif()
     set_target_properties(OpenSSL::Crypto PROPERTIES
-        INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS};Threads::Threads")
+        INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS};Threads::Threads;${_openssl_mingw_crypt}")
     if(EXISTS "${OPENSSL_CRYPTO_LIBRARY}")
       set_target_properties(OpenSSL::Crypto PROPERTIES
         IMPORTED_LINK_INTERFACE_LANGUAGES "C"


[CMake] Update for changes to LLVM CMake API (LLVM r248911).

This (mostly coincidentally) only affects Xcode users.

Swift SVN r32853

--- cmake/modules/AddSwift.cmake
+++ cmake/modules/AddSwift.cmake
@@ -851,8 +851,8 @@
   llvm_update_compile_flags(${target})

   set_output_directory(${target}
-      ${SWIFT_RUNTIME_OUTPUT_INTDIR}
-      ${SWIFT_LIBRARY_OUTPUT_INTDIR})
+      BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}
+      LIBRARY_DIR ${SWIFT_LIBRARY_OUTPUT_INTDIR})

   if(MODULE)
     set_target_properties("${target}" PROPERTIES
@@ -911,7 +911,8 @@
         ${SWIFT_SOURCE_DIR}/cmake/dummy.c)

     set_output_directory(${target_static}
-        ${SWIFT_RUNTIME_OUTPUT_INTDIR} ${SWIFT_LIBRARY_OUTPUT_INTDIR})
+        BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}
+        LIBRARY_DIR ${SWIFT_LIBRARY_OUTPUT_INTDIR})

     foreach(config ${CMAKE_CONFIGURATION_TYPES})
       string(TOUPPER ${config} config_upper)
@@ -1682,7 +1683,9 @@
   set_property(TARGET ${name} APPEND_STRING PROPERTY
       LINK_FLAGS " ${link_flags}")

-  set_output_directory(${name} ${SWIFT_RUNTIME_OUTPUT_INTDIR} ${SWIFT_LIBRARY_OUTPUT_INTDIR})
+  set_output_directory(${name}
+      BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}
+      LIBRARY_DIR ${SWIFT_LIBRARY_OUTPUT_INTDIR})

   # Add Swift source files to the project.
   source_group("Swift Sources" FILES ${SWIFTEXE_SINGLE_EXTERNAL_SOURCES})


fix typo in FindMaps.cmake

fix typo in FindMaps.cmake

--- cmake/modules/FindMaps.cmake
+++ cmake/modules/FindMaps.cmake
@@ -32,4 +32,4 @@
 endmacro()

-pkg_config_find_module(MAPS maps MapManager.h maps maps)
+pkg_config_find_module(MAPS maps MapManager.hpp maps maps)


return support for old INDI version 0.9

return support for old INDI version 0.9

--- cmake_modules/FindINDI.cmake
+++ cmake_modules/FindINDI.cmake
@@ -27,6 +27,16 @@
   set(INDI_VERSION_RELEASE "${CMAKE_MATCH_1}")

   set(INDI_VERSION ${INDI_VERSION_MAJOR}.${INDI_VERSION_MINOR}.${INDI_VERSION_RELEASE})
+
+  if(${INDI_VERSION} STREQUAL "..")
+    # we may have an old version
+    string(REGEX MATCH "#define INDI_LIBV[ \t]+([0-9]+).([0-9]+)" _INDI_version_major_match _INDI_version_minor_match "${_INDI_version_header}")
+    set(INDI_VERSION_MAJOR "${CMAKE_MATCH_1}")
+    set(INDI_VERSION_MINOR "${CMAKE_MATCH_2}")
+    set(INDI_VERSION ${INDI_VERSION_MAJOR}.${INDI_VERSION_MINOR})
+    message(STATUS "Old INDI version ${INDI_VERSION} found in ${INDI_INCLUDE_DIR}, please consider upgrading")
+  endif(${INDI_VERSION} STREQUAL "..")
+
   if(${INDI_VERSION} VERSION_LESS ${INDI_FIND_VERSION})
     set(INDI_VERSION_OK FALSE)
   else(${INDI_VERSION} VERSION_LESS ${INDI_FIND_VERSION})


disable W4127 for msvc again (qt issue)

disable W4127 for msvc again (qt issue)

--- cmake/CompileOptions.cmake
+++ cmake/CompileOptions.cmake
@@ -73,8 +73,7 @@

         /wd4251       # -> disable warning: 'identifier': class 'type' needs to have dll-interface to be used by clients of class 'type2'
         /wd4592       # -> disable warning: 'identifier': symbol will be dynamically initialized (implementation limitation)
-        # /wd4201     # -> disable warning: nonstandard extension used: nameless struct/union (caused by GLM)
-        # /wd4127     # -> disable warning: conditional expression is constant (caused by Qt)
+        /wd4127       # -> disable warning: conditional expression is constant (caused by Qt)

         $<$<CONFIG:Debug>:
         /RTCc         # -> value is assigned to a smaller data type and results in a data loss


move images download link to https

move images download link to https

now the source is https

--- cmake/DownloadImages.cmake
+++ cmake/DownloadImages.cmake
@@ -12,7 +12,7 @@
 message(STATUS "######################################################")

 #download support constants
-set(SOURCE_URL "http://downloads.myriadrf.org/project/limesuite/${VERSION_MAJOR}.${VERSION_MINOR}")
+set(SOURCE_URL "https://downloads.myriadrf.org/project/limesuite/${VERSION_MAJOR}.${VERSION_MINOR}")
 set(TEMP_DEST "${CMAKE_CURRENT_BINARY_DIR}/images/${VERSION_MAJOR}.${VERSION_MINOR}")
 set(INSTALL_DEST "share/LimeSuite/images/${VERSION_MAJOR}.${VERSION_MINOR}")
 set(HREF_MATCHER "href=\\\"/project/limesuite/${VERSION_MAJOR}.${VERSION_MINOR}/([\\._A-Za-z_0-9-]+(.rpd|.rbf|.img))\\\"")


CPU: Update Eigen (#662)

CPU: Update Eigen (#662)

* CPU: Update Eigen

* CPU: Move patched Eigen master branch to NervanaSystems

--- cmake/external_eigen.cmake
+++ cmake/external_eigen.cmake
@@ -17,8 +17,8 @@
 # Enable ExternalProject CMake module
 include(ExternalProject)

-set(EIGEN_GIT_TAG d608d9f3f577118981acbdd40da9dcf6b514668a)
-set(EIGEN_GIT_URL https://github.com/jmenon/eigen)
+set(EIGEN_GIT_TAG patched)
+set(EIGEN_GIT_URL https://github.com/NervanaSystems/eigen)

 #----------------------------------------------------------------------------------------------------------
 # Download and install Eigen


Update Findgloox.cmake

Update Findgloox.cmake

--- cmake/find/Findgloox.cmake
+++ cmake/find/Findgloox.cmake
@@ -14,13 +14,14 @@
 if(GLOOX_LIBRARIES AND GLOOX_INCLUDE_DIR)
 	message(STATUS "Found gloox: ${GLOOX_LIBRARIES}")
 	set(GLOOX_FOUND 1)
-  if (NOT TARGET "gloox::gloox")
-    add_library("gloox::gloox" UNKNOWN IMPORTED)
-    set_target_properties("gloox::gloox"
-      PROPERTIES
-      INTERFACE_INCLUDE_DIRECTORIES "${GLOOX_INCLUDE_DIRS}"
-      IMPORTED_LOCATION "${GLOOX_LIBRARY}"
-    )
+  	if(NOT TARGET "gloox::gloox")
+  		add_library("gloox::gloox" UNKNOWN IMPORTED)
+    		set_target_properties("gloox::gloox"
+      			PROPERTIES
+      			INTERFACE_INCLUDE_DIRECTORIES "${GLOOX_INCLUDE_DIRS}"
+      			IMPORTED_LOCATION "${GLOOX_LIBRARY}"
+    		)
+	endif()
 else(GLOOX_LIBRARIES AND GLOOX_INCLUDE_DIR)
 	message( STATUS "Could NOT find gloox" )
 endif( GLOOX_LIBRARIES AND GLOOX_INCLUDE_DIR )


fix docs: nosetest target names use periods

--- cmake/test/nosetests.cmake
+++ cmake/test/nosetests.cmake
@@ -8,7 +8,7 @@
 # .. note:: The test can be executed by calling ``nosetests``
 #   directly or using:
 #   `` make run_tests_${PROJECT_NAME}_nosetests_${dir}``
-#   (where slashes in the ``dir`` are replaced with underscores)
+#   (where slashes in the ``dir`` are replaced with periods)
 #
 # :param path: a relative or absolute directory to search for
 #   nosetests in or a relative or absolute file containing tests


KWSys Nightly Date Stamp

KWSys Nightly Date Stamp

--- Utilities/KWSys/vtksys/kwsysDateStamp.cmake
+++ Utilities/KWSys/vtksys/kwsysDateStamp.cmake
@@ -18,4 +18,4 @@
 SET(KWSYS_DATE_STAMP_MONTH 04)

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


cmake toolchain enable double fpu for cortex-m7

--- cmake/toolchains/Toolchain-arm-none-eabi.cmake
+++ cmake/toolchains/Toolchain-arm-none-eabi.cmake
@@ -74,7 +74,7 @@

 set(cpu_flags)
 if (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m7")
-	set(cpu_flags "-mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard")
+	set(cpu_flags "-mcpu=cortex-m7 -mthumb -march=armv7e-m -mfpu=fpv5-d16 -mfloat-abi=hard")
 elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m4")
 	set(cpu_flags "-mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard")
 elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m3")


removed parenthesis

removed parenthesis

--- version_config.cmake
+++ version_config.cmake
@@ -225,7 +225,7 @@
   ISMRMRD_URL ISMRMRD_TAG
   pet_rd_tools_URL pet_rd_tools_TAG
   glog_URL glog_TAG
-  NIFTYREG_URL NIFTYREG_TAG)
+  NIFTYREG_URL NIFTYREG_TAG
   CCPi-Framework_URL CCPi-Framework_TAG
   CCPi-FrameworkPlugins_URL CCPi-FrameworkPlugins_TAG
   CCPi-RGL_URL CCPi-RGL_TAG


updated SIRF version

updated SIRF version

--- version_config.cmake
+++ version_config.cmake
@@ -139,7 +139,7 @@
   set(DEFAULT_ACE_TAG origin/master)

 else()
-  set(DEFAULT_SIRF_TAG v2.0.0-rc.2)
+  set(DEFAULT_SIRF_TAG v2.0.0-rc.3)

   ## STIR
   set(DEFAULT_STIR_URL https://github.com/UCL/STIR )


Update FW: fix for 4-point warp with normalized = false

--- cmake/Depthai/DepthaiDeviceSideConfig.cmake
+++ cmake/Depthai/DepthaiDeviceSideConfig.cmake
@@ -2,7 +2,7 @@
 set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")

 # "full commit hash of device side binary"
-set(DEPTHAI_DEVICE_SIDE_COMMIT "0f8760df31f4d37efcd8d6fc210f1a4215221de3")
+set(DEPTHAI_DEVICE_SIDE_COMMIT "d49ac887074adf18024c21e33ce071ea48b0c014")

 # "version if applicable"
 set(DEPTHAI_DEVICE_SIDE_VERSION "")


Fail to configure if fail-on-missing=ON and LZMA is not found

--- cmake/modules/SearchInstalledSoftware.cmake
+++ cmake/modules/SearchInstalledSoftware.cmake
@@ -163,12 +163,17 @@
 #---Check for LZMA-------------------------------------------------------------------
 if(NOT builtin_lzma)
   message(STATUS "Looking for LZMA")
-  find_package(LZMA)
-  if(NOT LZMA_FOUND)
-    message(STATUS "LZMA not found. Switching on builtin_lzma option")
-    set(builtin_lzma ON CACHE BOOL "Enabled because LZMA not found (${builtin_lzma_description})" FORCE)
-  endif()
-endif()
+  if(fail-on-missing)
+    find_package(LZMA REQUIRED)
+  else()
+    find_package(LZMA)
+    if(NOT LZMA_FOUND)
+      message(STATUS "LZMA not found. Switching on builtin_lzma option")
+      set(builtin_lzma ON CACHE BOOL "Enabled because LZMA not found (${builtin_lzma_description})" FORCE)
+    endif()
+  endif()
+endif()
+
 if(builtin_lzma)
   set(lzma_version 5.2.4)
   set(LZMA_TARGET LZMA)


Disable GCC6's -Wignored-attributes

Disable GCC6's -Wignored-attributes

See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69884

--- cmake/modules/VisionarayHandleOptions.cmake
+++ cmake/modules/VisionarayHandleOptions.cmake
@@ -4,21 +4,35 @@

 if(MSVC)

-else()
+else() # GNU, Clang, etc.

+    #------------------------------------------------------
+    # Enable warnings
+    #
+
     add_definitions(-Wmissing-braces)
     add_definitions(-Wsign-compare)
     add_definitions(-Wwrite-strings)
     add_definitions(-Woverloaded-virtual)

     if(VSNRAY_ENABLE_WARNINGS)
-
         add_definitions(-Wall -Wextra)

         if(VSNRAY_ENABLE_PEDANTIC)
             add_definitions(-pedantic)
         endif()
+    endif()

+
+    #------------------------------------------------------
+    # Selectively disable warnings
+    #
+
+    if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+        if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0)
+            # Disable warnings like:
+            # warning: ignoring attributes on template argument ‘__m128i
+            add_definitions(-Wno-ignored-attributes)
+        endif()
     endif()
 endif()
-


Remove Boost version "1_45" baked into library names. On Windows, LLPrimitive.cmake named four Boost libraries with names ending in the string 1_45. Now that we're trying to upgrade Boost to 1.52, those suffixes are inappropriate. Fortunately the libraries in our current Boost package do not have version-stamped names, so we hope this fix can survive for several Boost upgrades to come.

--- indra/cmake/LLPrimitive.cmake
+++ indra/cmake/LLPrimitive.cmake
@@ -15,10 +15,10 @@
         optimized llprimitive
         debug libcollada14dom22-d
         optimized libcollada14dom22
-        debug libboost_filesystem-vc100-mt-gd-1_45
-        optimized libboost_filesystem-vc100-mt-1_45
-        debug libboost_system-vc100-mt-gd-1_45
-        optimized libboost_system-vc100-mt-1_45
+        debug libboost_filesystem-mt-gd
+        optimized libboost_filesystem-mt
+        debug libboost_system-mt-gd
+        optimized libboost_system-mt
         )
 else (WINDOWS)
     set(LLPRIMITIVE_LIBRARIES


Only force the assignment if `CMAKE_OSX_ARCHITECTURES` is empty

--- standard/StandardProject.cmake
+++ standard/StandardProject.cmake
@@ -37,7 +37,7 @@
 function(standard_project_preinit)
   # Pre-initialization steps - these variables must be set before the first call to
   # project()
-  if(APPLE)
+  if(APPLE AND CMAKE_OSX_ARCHITECTURES STREQUAL "")
     if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm")
       set(CMAKE_OSX_ARCHITECTURES "arm" CACHE STRING "Mac OS X build architectures" FORCE)
     else()


[cmake] warnings are now opt-in

[cmake] warnings are now opt-in

--- cmake/iDynTreeOptions.cmake
+++ cmake/iDynTreeOptions.cmake
@@ -46,7 +46,6 @@

 #########################################################################
 # Enable/disable dependencies
-
 option(IDYNTREE_ENABLE_SYMORO_PAR "Enable support for SyMoRo par format" TRUE)
 option(IDYNTREE_USES_KDL "Compile iDynTree with KDL dependency" TRUE)
 option(IDYNTREE_USES_YARP "Compile iDynTree with YARP dependency" TRUE)
@@ -61,6 +60,12 @@
     add_definitions(-DURDF_USE_PLAIN_POINTERS)
     add_definitions(-DIDYNTREE_USE_INTERNAL_URDFDOM)
 endif()
+
+##########################################################################
+# Enable/disable warnings
+option(IDYNTREE_ENABLE_WARNINGS "Enable compilation warnings when compiling iDynTree." FALSE)
+option(IDYNTREE_ENABLE_DOCUMENTATION_WARNINGS "Enable documentation warnings when compiling iDynTree." FALSE)
+

 if(MSVC)
     set(CMAKE_DEBUG_POSTFIX "d")
@@ -89,26 +94,25 @@
 # sanitizers. Imported from http://api.kde.org/ecm/module/ECMEnableSanitizers.html
 include(ECMEnableSanitizers)

-# Enable warnings on Debug builds
-if(MSVC)
-    ###
-else()
-    ##Other systems
-    if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
-        SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Weverything -pedantic -Wnon-virtual-dtor -Woverloaded-virtual")
-        #disable padding alignment warnings. Cast align is more subtle. On X86 it should not create any problem but for different architecture we should handle this warning better.
-        SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-padded -Wno-cast-align")
-        if (CODYCO_TRAVIS_CI)
-            #disable documentation warnings and sign comparison. This is for Travis-CI
-            MESSAGE(STATUS "Disabling some warning for Travis-CI")
-            SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-documentation -Wno-documentation-unknown-command -Wno-sign-conversion")
-        endif()
-        MESSAGE(STATUS "Clang compiler - Debug configuration flags: -Weverything -pedantic -Wnon-virtual-dtor -Woverloaded-virtual")
-    elseif(${CMAKE_COMPILER_IS_GNUCC})
-        SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra")
-        if (NOT CODYCO_TRAVIS_CI)
-            MESSAGE(STATUS "Gcc compiler - Debug configuration flags: -Wall -Wextra -pedantic -Weffc++ -Woverloaded-virtual")
-            SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pedantic -Weffc++ -Woverloaded-virtual")
+# Enable warnings if requested
+if(${IDYNTREE_ENABLE_WARNINGS})
+    if(MSVC)
+         ###
+    else()
+        ##Other systems
+        if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
+            SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Weverything -pedantic -Wnon-virtual-dtor -Woverloaded-virtual")
+            #disable padding alignment warnings. Cast align is more subtle. On X86 it should not create any problem but for different architecture we should handle this warning better.
+            SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-padded -Wno-cast-align")
+            if (NOT ${IDYNTREE_ENABLE_DOCUMENTATION_WARNINGS})
+                #disable documentation warnings and sign comparison. This is for Travis-CI
+                SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-documentation -Wno-documentation-unknown-command -Wno-sign-conversion")
+            endif()
+        elseif(${CMAKE_COMPILER_IS_GNUCC})
+            SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra")
+            if (NOT ${IDYNTREE_ENABLE_DOCUMENTATION_WARNINGS})
+                SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pedantic -Weffc++ -Woverloaded-virtual")
+            endif()
         endif()
     endif()
 endif()


Mac: cmake cosmetics

Mac: cmake cosmetics

--- src/Mac/projectDef.cmake
+++ src/Mac/projectDef.cmake
@@ -1,4 +1,4 @@
-#/**********************************************************\
+#/**********************************************************\
 # Auto-generated Mac project definition file for the
 # WebChimera Plugin project
 #\**********************************************************/
@@ -6,9 +6,9 @@
 # Mac template platform definition CMake file
 # Included from ../CMakeLists.txt

+set( QTDIR ${_qt5Core_install_prefix} )
+
 add_subdirectory( ${DEPS_DIR}/QuickLayer "${DEPS_BINARY_DIR}/QuickLayer" )
-
-include_directories( ${DEPS_DIR}/libvlc-sdk/include )

 # remember that the current source dir is the project root; this file is in Mac/
 file( GLOB PLATFORM RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
@@ -16,7 +16,7 @@
     Mac/[^.]*.mm
     Mac/[^.]*.h
     Mac/[^.]*.cmake
-)
+    )

 set( VLC_PATH "${DEPS_DIR}/VLC-${VLC_VERSION}.app/Contents/MacOS" )

@@ -27,55 +27,61 @@
 file( GLOB LIBVLC_LUA_PLAYLIST ${VLC_PATH}/share/lua/playlist/[^.]*.luac )

 set( LIBVLC
-     ${LIBVLC_LIB} ${LIBVLC_PLUGINS}
-     ${LIBVLC_LUA_EXTENSIONS} ${LIBVLC_LUA_MODULES} ${LIBVLC_LUA_PLAYLIST}
-)
+    ${LIBVLC_LIB}
+    ${LIBVLC_PLUGINS}
+    ${LIBVLC_LUA_EXTENSIONS}
+    ${LIBVLC_LUA_MODULES}
+    ${LIBVLC_LUA_PLAYLIST}
+    )
+
+source_group( Libvlc FILES ${LIBVLC} )

 set_source_files_properties(
     ${LIBVLC_LIB}
     PROPERTIES
     MACOSX_PACKAGE_LOCATION MacOS/lib
-)
+    )

 set_source_files_properties(
     ${LIBVLC_PLUGINS}
     PROPERTIES
     MACOSX_PACKAGE_LOCATION MacOS/plugins
-)
+    )

 set_source_files_properties(
     ${LIBVLC_LUA_EXTENSIONS}
     PROPERTIES
     MACOSX_PACKAGE_LOCATION MacOS/share/lua/extensions/
-)
+    )

 set_source_files_properties(
     ${LIBVLC_LUA_MODULES}
     PROPERTIES
     MACOSX_PACKAGE_LOCATION MacOS/share/lua/modules/
-)
+    )

 set_source_files_properties(
     ${LIBVLC_LUA_PLAYLIST}
     PROPERTIES
     MACOSX_PACKAGE_LOCATION MacOS/share/lua/playlist/
-)
+    )

-include_directories( ${VLC_PATH}/include )
-
-include_directories( ${_qt5Core_install_prefix}/include )
-# use this to add preprocessor definitions
-add_definitions(
-)
-
-source_group( Libvlc FILES ${LIBVLC} )
 source_group( Mac FILES ${PLATFORM} )

-set (SOURCES
+set( SOURCES
     ${SOURCES}
     ${PLATFORM}
     ${LIBVLC}
     )
+
+include_directories(
+    ${VLC_PATH}/include
+    ${QTDIR}/include
+    )
+
+# use this to add preprocessor definitions
+add_definitions(
+)

 set( PLIST "Mac/bundle_template/Info.plist" )
 set( STRINGS "Mac/bundle_template/InfoPlist.strings" )
@@ -84,7 +90,7 @@
 add_mac_plugin( ${PROJECT_NAME} ${PLIST} ${STRINGS} ${LOCALIZED} SOURCES )

 # add library dependencies here; leave ${PLUGIN_INTERNAL_DEPS} there unless you know what you're doing!
-target_link_libraries(${PROJECT_NAME}
+target_link_libraries( ${PROJECT_NAME}
     ${PLUGIN_INTERNAL_DEPS}
     ${Qt5Gui_EGL_LIBRARIES}
     ${Qt5Gui_OPENGL_LIBRARIES}


Another OSS build fix

Another OSS build fix

Summary: A recent reshuffle of the Thrift libraries means we depend on one more `.so`.

Reviewed By: nilesr

Differential Revision: D23848012

fbshipit-source-id: 102ade4470aaf1871d74568ca22cd58ab6c07bed

--- bistro/cmake/setup.cmake
+++ bistro/cmake/setup.cmake
@@ -50,6 +50,7 @@
   libprotocol.so
   libthrift-core.so
   libthriftcpp2.so
+  librpcmetadata.so
   libthriftmetadata.so
   libthriftprotocol.so
   libtransport.so


Checking for files during makefile generation does not work.

--- install_java.cmake
+++ install_java.cmake
@@ -1,10 +1,9 @@
 function(install_java_artifact NAME)
-    if (EXISTS "${NAME}/target/${NAME}.jar")
-        install(FILES "${NAME}/target/${NAME}.jar" DESTINATION lib/jars/)
-    endif()
-    if (IS_DIRECTORY "${NAME}/target/dependency")
-        install(DIRECTORY "${NAME}/target/dependency" DESTINATION lib/jars/ FILES_MATCHING PATTERN "*.jar")
-    endif()
+    install(FILES "${NAME}/target/${NAME}.jar" DESTINATION lib/jars/)
+endfunction()
+
+function(install_java_artifact_dependencies NAME)
+    install(DIRECTORY "${NAME}/target/dependency/" DESTINATION lib/jars FILES_MATCHING PATTERN "*.jar")
 endfunction()

 function(install_fat_java_artifact NAME)
@@ -13,8 +12,9 @@

 install_java_artifact(document)
 install_java_artifact(jdisc_jetty)
+install_java_artifact_dependencies(jdisc_jetty)
 install_java_artifact(searchlib)
-install_java_artifact(vespa_jersey2)
+install_java_artifact_dependencies(vespa_jersey2)
 install_java_artifact(vespajlib)

 install_fat_java_artifact(application-preprocessor)
@@ -24,6 +24,7 @@
 install_fat_java_artifact(config-model)
 install_fat_java_artifact(config-provisioning)
 install_fat_java_artifact(configdefinitions)
+install_fat_java_artifact(configserver)
 install_fat_java_artifact(container-disc)
 install_fat_java_artifact(container-jersey2)
 install_fat_java_artifact(container-search-and-docproc)


Update android toolchain to support latest ndk 0.8b

--- CMake/toolchain/android.toolchain.cmake
+++ CMake/toolchain/android.toolchain.cmake
@@ -1,5 +1,5 @@
 # ------------------------------------------------------------------------------
-#  Android CMake toolchain file, for use with the Android NDK r5-r8
+#  Android CMake toolchain file, for use with the Android NDK r5-r8b
 #  Requires cmake 2.6.3 or newer (2.8.3 or newer is recommended).
 #  See home page: http://code.google.com/p/android-cmake/
 #
@@ -180,6 +180,10 @@
 #   - modified May 2012
 #     [+] updated for NDK r8
 #     [+] added mips architecture support
+#   - modified July 2012 by ifreedom.cn@gmail.com
+#     [+] updated for NDK r8b
+#     [+] fixed compiler version get
+#     [+] fixed gnu-stl version choose
 # ------------------------------------------------------------------------------

 cmake_minimum_required( VERSION 2.6.3 )
@@ -199,7 +203,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 -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,7 +477,8 @@
  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 "[0-9]+.[0-9]+(.[0-9]+)?$" __version "${__version}" )
    string( REGEX MATCH "^[^-]+" __arch "${__toolchain}" )
    list( APPEND __availableToolchainMachines ${__machine} )
    list( APPEND __availableToolchainArchs ${__arch} )
@@ -485,6 +490,13 @@
  if( NOT __availableToolchains )
   message( FATAL_ERROR "Could not any working toolchain in the NDK. Probably your Android NDK is broken." )
  endif()
+endif()
+#is ndk r8b?
+list( FIND __availableToolchainCompilerVersions "4.6" __hasGCC46 )
+if( __hasGCC46 EQUAL -1 )
+ set( __hasGCC46 FALSE )
+else()
+ set( __hasGCC46 TRUE )
 endif()

 #build list of available ABIs
@@ -669,8 +681,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(__hasGCC46)
+   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()


Turn off DWARF extension of next versions to avoid tripping up IDEs

--- CMake/toolchain.cmake
+++ CMake/toolchain.cmake
@@ -61,7 +61,7 @@

 # set default compilation flags
-set(_C_FAMILY_FLAGS_INIT "-fno-exceptions -fno-unwind-tables -ffunction-sections -fdata-sections -Wall -Wextra")
+set(_C_FAMILY_FLAGS_INIT "-fno-exceptions -fno-unwind-tables -ffunction-sections -fdata-sections -Wall -Wextra -gstrict-dwarf")
 set(CMAKE_C_FLAGS_INIT   "-std=c99 ${_C_FAMILY_FLAGS_INIT}")
 set(CMAKE_ASM_FLAGS_INIT "-fno-exceptions -fno-unwind-tables -x assembler-with-cpp")
 set(CMAKE_CXX_FLAGS_INIT "--std=gnu++11 ${_C_FAMILY_FLAGS_INIT} -fno-rtti -fno-threadsafe-statics")


fix FindUnitTest++ cmake module

fix FindUnitTest++ cmake module

--- Microsoft.WindowsAzure.Storage/cmake/Modules/FindUnitTest++.cmake
+++ Microsoft.WindowsAzure.Storage/cmake/Modules/FindUnitTest++.cmake
@@ -11,7 +11,7 @@
 include(FindPackageHandleStandardArgs)

 # Use pkg-config to get hints about paths
-pkg_check_modules(UnitTest++_PKGCONF REQUIRED unittest++)
+pkg_check_modules(UnitTest++_PKGCONF QUIET unittest++)

 # Include dir
 find_path(UnitTest++_INCLUDE_DIR
@@ -19,16 +19,21 @@
   PATHS
   	${UnitTest++_PKGCONF_INCLUDE_DIRS}
   	${CMAKE_SOURCE_DIR}/tests/UnitTest++/src
+	/usr/local/include
+  PATH_SUFFIXES
+	unittest++
+	UnitTest++
 )

 # Library
 find_library(UnitTest++_LIBRARY
-  NAMES unittest++
+  NAMES unittest++ UnitTest++
   PATHS
   	${UnitTest++_PKGCONF_LIBRARY_DIRS}
   	${CMAKE_SOURCE_DIR}/tests/UnitTest++
+	/usr/local/lib
 )

 set(UnitTest++_PROCESS_LIBS UnitTest++_LIBRARY)
 set(UnitTest++_PROCESS_INCLUDES UnitTest++_INCLUDE_DIR)
-libfind_process(UnitTest++)+libfind_process(UnitTest++)


Test Compact Binary v2 compat between C# and C++

--- cpp/test/compat/compat.cmake
+++ cpp/test/compat/compat.cmake
@@ -13,18 +13,10 @@
 endif()

 if (CSHARP_COMPAT)
-    set (TEST_CS ${TEST})
-
-    # C# implements reading of Compact Binary v2 but not writing
-    if (${TEST_CS} STREQUAL compact2)
-        set (TEST_CS compact)
-    endif()
-
-    run (${CSHARP_COMPAT} ${TEST} ${COMPAT_DATA}/compat.${TEST}.dat compat.${TEST}.cs.dat ${TEST_CS})
-    run (${BOND_COMPAT} ${TEST_CS} -d compat.${TEST}.cs.dat expected.cs.${TEST} deserialized.cs.${TEST})
+    run (${CSHARP_COMPAT} ${TEST} ${COMPAT_DATA}/compat.${TEST}.dat compat.${TEST}.cs.dat ${TEST})
+    run (${BOND_COMPAT} ${TEST} -d compat.${TEST}.cs.dat expected.cs.${TEST} deserialized.cs.${TEST})

     if (${TEST} STREQUAL schema)
         run (${CSHARP_COMPAT} ${TEST} compat.Compat.json compat.${TEST}.gbc.dat)
     endif()
 endif()
-


ENH: Update BridgeNumPy to most recent version (2017.03.05)

 Matt McCormick (2):
       COMP: Address Python 2.7 Windows hypot bug
       DOC: Add example usage in the README

Change-Id: I24c1b860f877bb4c3564e51c547ef60375ce4148

--- Modules/Remote/BridgeNumPy.remote.cmake
+++ Modules/Remote/BridgeNumPy.remote.cmake
@@ -21,5 +21,5 @@
   See http://insight-journal.org/browse/publication/85
       https://hdl.handle.net/1926/188"
   GIT_REPOSITORY ${git_protocol}://github.com/InsightSoftwareConsortium/ITKBridgeNumPy.git
-  GIT_TAG fed4d06c8c47a35f863f21ac046faecd7de06a7a
+  GIT_TAG cda8ddf091fd75f9c712270c9d2280ef91744e99
   )


Reactivated KinectDeviceTest

Reactivated KinectDeviceTest

--- Modules/ToFHardware/Testing/files.cmake
+++ Modules/ToFHardware/Testing/files.cmake
@@ -25,6 +25,6 @@
   mitkToFNrrdImageWriterTest.cpp
   mitkToFOpenCVImageGrabberTest.cpp
   mitkKinectControllerTest.cpp
-  #mitkKinectDeviceTest.cpp
+  mitkKinectDeviceTest.cpp
 )