modern cmake provides FindHdf5.cmake

modern cmake provides FindHdf5.cmake

--- cmake/FindHdf5.cmake
+++ cmake/FindHdf5.cmake
@@ -1,77 +0,0 @@
-# - Try to find HDF5 libraries
-# Once done this will define
-#  HDF5_FOUND - System has HDF5
-#  HDF5_INCLUDE_DIRS - The HDF5 include directories
-#  HDF5_LIBRARIES - The libraries needed to use HDF5
-#  HDF5_DEFINITIONS - Compiler switches required for using HDF5
-#
-# This implementation assumes a HDF5 install has the following structure
-# VERSION/
-#         include/*.h
-#         lib/*.a
-
-macro(hdf5LibCheck libs isRequired)
-  foreach(lib ${libs})
-    unset(hdf5lib CACHE)
-    find_library(hdf5lib "${lib}" HINTS ${HDF5_LIB_DIR})
-    if(hdf5lib MATCHES "^hdf5lib-NOTFOUND$")
-      if(${isRequired})
-        message(FATAL_ERROR "HDF5 library ${lib} not found in ${HDF5_LIB_DIR}")
-      else()
-        message("HDF5 library ${lib} not found in ${HDF5_LIB_DIR}")
-      endif()
-    else()
-      set("HDF5_${lib}_FOUND" TRUE CACHE INTERNAL "HDF5 library present")
-      set(HDF5_LIBS ${HDF5_LIBS} ${hdf5lib})
-    endif()
-  endforeach()
-endmacro(hdf5LibCheck)
-
-set(HDF5_LIBS "")
-set(HDF5_LIB_NAMES
- hdf5hl_fortran
- hdf5_fortran
- hdf5_hl
- hdf5
- z)
-
-hdf5LibCheck("${HDF5_LIB_NAMES}" TRUE)
-
-find_path(HDF5_INCLUDE_DIR
-  NAMES hdf5.h
-  PATHS ${HDF5_INCLUDE_DIR})
-if(NOT EXISTS "${HDF5_INCLUDE_DIR}")
-  message(FATAL_ERROR "HDF5 include dir not found")
-endif()
-
-set(HDF5_LIBRARIES ${HDF5_LIBS} )
-set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR} )
-
-string(REGEX REPLACE
-  "/include$" ""
-  HDF5_INSTALL_DIR
-  "${HDF5_INCLUDE_DIR}")
-
-include(FindPackageHandleStandardArgs)
-# handle the QUIETLY and REQUIRED arguments and set PARMETIS_FOUND to TRUE
-# if all listed variables are TRUE
-find_package_handle_standard_args(HDF5  DEFAULT_MSG
-                                  HDF5_LIBS HDF5_INCLUDE_DIR)
-
-mark_as_advanced(HDF5_INCLUDE_DIR HDF5_LIBS)
-
-set(HDF5_LINK_LIBS "")
-foreach(lib ${HDF5_LIB_NAMES})
-  set(HDF5_LINK_LIBS "${HDF5_LINK_LIBS} -l${lib}")
-endforeach()
-
-#pkgconfig
-set(prefix "${HDF5_INSTALL_DIR}")
-set(includedir "${HDF5_INCLUDE_DIR}")
-configure_file(
-  "${CMAKE_HOME_DIRECTORY}/cmake/libHdf5.pc.in"
-  "${CMAKE_BINARY_DIR}/libHdf5.pc"
-  @ONLY)
-
-INSTALL(FILES "${CMAKE_BINARY_DIR}/libHdf5.pc" DESTINATION  lib/pkgconfig)
-


Fixed the FindROCS script.

Fixed the FindROCS script.

--- cmake/FindROCS.cmake
+++ cmake/FindROCS.cmake
@@ -31,13 +31,15 @@
 # Sets the following variables:
 # ROCS_FOUND - When false, ROCS could not be found.
 # ROCS_DIR - Path to the directory where ROCS is installed.
+# ROCS_LIBRARY_DIR
+# ROCS_INCLUDE_DIR
 # ------------------------------------------------------------------

 # Check if this script is executed from within ROCS source tree.
 if(NOT INSIDE_ROCS)
 	find_path(ROCS_DIR
-		NAMES include/RCore/global.h
+		NAMES include/rocs/core/error.h
 		PATHS $ENV{ROCS_DIR}
 			/opt/rocs
 			/usr/local/rocs
@@ -50,26 +52,13 @@

 	if(ROCS_DIR)
 		set(ROCS_FOUND "YES")
+		set(ROCS_LIBRARY_DIR ${ROCS_DIR}/lib)
+		set(ROCS_INCLUDE_DIR ${ROCS_DIR}/include)
 	else(ROCS_DIR)
   		message("The ROCS installation directory was not found.")
                 message("Try to set the ROCS_DIR environment variable.")
   		set(ROCS_DIR "" CACHE PATH "Path to the ROCS installation directory." )
 	endif(ROCS_DIR)
-
-	# Replacement for the macro in ROCSMacros.cmake when not built inside ROCS
-	macro(add_rocs_cpp_test_app _NAME_ _SOURCES_VAR_)
-		# Get sources
-		set(_SOURCES_ "")
-		foreach(I ${${_SOURCES_VAR_}})
-			set(_SOURCES_ "${I}" ${_SOURCES_})
-		endforeach(I)
-
-		# Add target
-		add_executable(${_NAME_} ${_SOURCES_})
-
-		# Install
-		install(TARGETS ${_NAME_} RUNTIME DESTINATION .)
-	endmacro(add_rocs_cpp_test_app)
 else(NOT INSIDE_ROCS)
 	set(ROCS_FOUND "YES")
 endif(NOT INSIDE_ROCS)


use the right compiler options for MSVC

use the right compiler options for MSVC

--- cmake/VcMacros.cmake
+++ cmake/VcMacros.cmake
@@ -352,14 +352,23 @@
       endif()
    endforeach()

+   set(_outfile_flag -c -o)
+   if(Vc_COMPILER_IS_MSVC)
+      set(_outfile_flag /c /Fo)
+   endif()
+
    if(_ok)
       get_filename_component(_out "${_vc_compile_src}" NAME_WE)
       get_filename_component(_ext "${_vc_compile_src}" EXT)
-      set(_out "${_out}_${_impl}${_ext}.o")
+      if(Vc_COMPILER_IS_MSVC)
+         set(_out "${_out}_${_impl}${_ext}.obj")
+      else()
+         set(_out "${_out}_${_impl}${_ext}.o")
+      endif()
       add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_out}
          COMMAND ${CMAKE_CXX_COMPILER} ${_flags} ${_extra_flags}
          -DVC_IMPL=${_impl}
-         -c -o ${_out} ${CMAKE_CURRENT_SOURCE_DIR}/${_vc_compile_src}
+         ${_outfile_flag}${_out} ${CMAKE_CURRENT_SOURCE_DIR}/${_vc_compile_src}
          MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${_vc_compile_src}
          IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/${_vc_compile_src}
          COMMENT "Building CXX object ${_out}"


Remove warning for older versions of clang

--- cmake/Warnings.cmake
+++ cmake/Warnings.cmake
@@ -43,7 +43,7 @@
 		#list(APPEND WarningFlags "/wd4365") #signed/unsigned mismatch
 		#list(APPEND WarningFlags "/wd4668") # is not defined as a preprocessor macro, replacing with '0' for
 	  elseif(WCLANG)
-		list(APPEND WarningFlags -Wno-padded -Wno-undef -Wno-reserved-id-macro)
+		list(APPEND WarningFlags -Wno-unknown-warning-option -Wno-padded -Wno-undef -Wno-reserved-id-macro)
 		if(NOT CMAKE_CXX_STANDARD EQUAL 98)
 			list(APPEND WarningFlags -Wno-c++98-compat -Wno-c++98-compat-pedantic)
 		endif()


Handle BUILD_BITNESS for CMake native build types. (#94)

--- cmake/bde_ufid.cmake
+++ cmake/bde_ufid.cmake
@@ -624,6 +624,11 @@
             message(STATUS  "Setting default UFID to 'opt_exc_mt'.")
             set(UFID "opt_exc_mt" CACHE STRING "UFID for the project")
         endif()
+        if(BUILD_BITNESS)
+            if (BUILD_BITNESS EQUAL "64")
+                STRING(APPEND UFID "_64")
+            endif()
+        endif()
     endif()

     bde_parse_ufid(${UFID})


Delete cap-data.cmake

Delete cap-data.cmake

--- cmake/cap-data.cmake
+++ cmake/cap-data.cmake
@@ -1,8 +0,0 @@
-ExternalProject_Add(
-    cap-data
-    GIT_REPOSITORY     https://github.com/dalg24/cap-data.git
-    BUILD_IN_SOURCE    0
-    CONFIGURE_COMMAND  ""
-    BUILD_COMMAND      ""
-    INSTALL_COMMAND    ""
-)


Release v0.3.0

Release v0.3.0

--- cmake/packages.cmake
+++ cmake/packages.cmake
@@ -23,7 +23,7 @@
 endif ()

 set (PACKAGE_NAME        "${CMAKE_PROJECT_NAME}")
-set (PACKAGE_VERSION     "0.2.2.${GIT_CHECKIN_COUNT}")
+set (PACKAGE_VERSION     "0.3.0.${GIT_CHECKIN_COUNT}")
 set (PACKAGE_STRING      "${PACKAGE_NAME} ${PACKAGE_VERSION}")
 set (PACKAGE_TARNAME     "${PACKAGE_NAME}-${PACKAGE_VERSION}")
 set (PACKAGE_BUGREPORT   "https://github.com/Qihoo360/evpp/issues")


Wrappers around package and package_source

--- cmake/MyPackagePack.cmake
+++ cmake/MyPackagePack.cmake
@@ -30,7 +30,11 @@
   #
   SET (CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
   #
-  # Finally, include CPack
+  # Do not get fooled by components out of our control
+  #
+  SET (CPACK_COMPONENTS_ALL ManpageComponent DynamicLibraryComponent StaticLibraryComponent HeaderComponent ApplicationComponent)
+  #
+  # Include CPack - from now on we will have access to CPACK own macros
   #
   INCLUDE (CPack)
   #
@@ -74,4 +78,23 @@
                       GROUP RuntimeGroup
                       INSTALL_TYPES FullType
                       DEPENDS DynamicLibraryComponent)
+  #
+  # Quite subtil, but the "package" target is not visible at this time. There is a old standing bug
+  # in CMake about this.
+  # We use a custom target for package generation.
+  # In addition documentation is generated using the INSTALL(CODE xxx) hack.
+  #
+  ADD_CUSTOM_TARGET(pack_source
+    COMMAND ${CMAKE_MAKE_PROGRAM} package_source
+    COMMENT "Packaging Source files"
+    DEPENDS man
+    VERBATIM
+    )
+  ADD_CUSTOM_TARGET(pack
+    COMMAND ${CMAKE_MAKE_PROGRAM} package
+    COMMENT "Packaging Source files"
+    DEPENDS man
+    VERBATIM
+    )
+
 ENDMACRO()


Make sure components are empty by default

--- cmake/MyPackagePack.cmake
+++ cmake/MyPackagePack.cmake
@@ -29,6 +29,10 @@
     # Get all components in one package
     #
     SET (CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
+    #
+    # Do not get fooled by components out of our control
+    #
+    SET (CPACK_COMPONENTS_ALL)
     #
     # Include CPack - from now on we will have access to CPACK own macros
     #


code-coverage: Removed logging.

code-coverage: Removed logging.

--- cmake/code-coverage.cmake
+++ cmake/code-coverage.cmake
@@ -5,23 +5,23 @@
 # Verify if code coverage is possible

 if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-    message("- Current compiler is ${CMAKE_CXX_COMPILER_ID}. Code-coverage only available for GCC.\n")
+    message("CODE COVERAGE - Current compiler is ${CMAKE_CXX_COMPILER_ID}. Code-coverage only available for GCC.")
     set(SKIP_COVERAGE true)

 elseif(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
-    message("- Code-coverage only available when building for Debug.\n")
+    message("CODE COVERAGE - Code-coverage only available when building for Debug.\n")
     set(SKIP_COVERAGE true)

 elseif(NOT GCOV)
-    message(WARNING "- Gcov not found.")
+    message("CODE COVERAGE - Gcov not found.")
     set(SKIP_COVERAGE true)

 elseif(NOT LCOV)
-    message(WARNING "- Lcov not found.")
+    message("CODE COVERAGE - Lcov not found.")
     set(SKIP_COVERAGE true)

 elseif(NOT GENHTML)
-    message(WARNING "- Genhtml not found.")
+    message("CODE COVERAGE - Genhtml not found.")
     set(SKIP_COVERAGE true)
 endif()

@@ -31,20 +31,12 @@
     add_custom_target( ${COVERAGE_ALL}
         COMMENT "Main target for all code coverage targets."
     )
-
-    message("CODE COVERAGE")
-    message("- Target '${COVERAGE_ALL}' will build all coverage-targets. Run the following to generate reports:\n \
-    \tcmake --build . --target coverage_all\n \
-    \tcmake --build . --target install"
-    )
-
+    message("CODE COVERAGE - To generate reports: `cmake --build . --target coverage_all`")
 endif()

 # Calling to this function will result in no-op if not on GCC or config not Debug
 function(setup_target_for_coverage)
-    message("CODE COVERAGE")
     if(SKIP_COVERAGE)
-        message("- Skipping setting up code coverage...\n")
         return()
     else()
         setup_target_for_coverage_internal( ${ARGV} )
@@ -105,8 +97,5 @@
         OPTIONAL
     )

-    message("- Code coverage analysis setup for target '${args_TARGET}' in:\n
-    \t\"${TARGET_BINARY_DIR}\".\n \
-    \tReport found at: \"${OUTPUT_DIR}\"\n"
-    )
+    message("CODE COVERAGE - Analysis setup for target '${args_TARGET}'")
 endfunction()


whoops.  run that at install time, not cmake time.

--- cmake/enable_python.cmake
+++ cmake/enable_python.cmake
@@ -23,10 +23,8 @@
     configure_file(${catkin_EXTRAS_DIR}/templates/safe_execute_install.cmake.in
       ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/safe_execute_install.cmake)

-    include(${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/safe_execute_install.cmake)
-
     install(CODE "message(COMMAND = ${CMD})")
-    install(CODE "execute_process(COMMAND ${INSTALL_SCRIPT})")
+    install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/safe_execute_install.cmake)

     stamp(${${pkg_name}_SOURCE_DIR}/setup.py)


CMake: Make PACKAGE_TOOL available globally so parent projects may use it.

--- CMake/Modules/UrhoPackaging.cmake
+++ CMake/Modules/UrhoPackaging.cmake
@@ -47,9 +47,9 @@
             CMAKE_COMMAND ${ALTERNATE_COMMAND}
             CMAKE_ARGS -DURHO3D_ENABLE_ALL=OFF -DURHO3D_FEATURES=PACKAGING_TOOL -DMINI_URHO=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/native PackageTool
         )
-        set (PACKAGE_TOOL ${CMAKE_BINARY_DIR}/native/bin/PackageTool)
+        set (PACKAGE_TOOL "${CMAKE_BINARY_DIR}/native/bin/PackageTool" CACHE STRING "" FORCE)
     elseif (TARGET PackageTool)
-        set (PACKAGE_TOOL $<TARGET_FILE:PackageTool>)
+        set (PACKAGE_TOOL "$<TARGET_FILE:PackageTool>" CACHE STRING "" FORCE)
     else ()
         message(FATAL_ERROR "CMake misconfiguration")
     endif ()


modules: Update FindOVR.cmake

modules: Update FindOVR.cmake

Signed-off-by: Squareys <0f6a03d4883e012ba4cb2c581a68f35544703cd6@googlemail.com>

--- modules/FindOVR.cmake
+++ modules/FindOVR.cmake
@@ -18,7 +18,7 @@
 #
 #   Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016
 #             Vladimír Vondruš <mosra@centrum.cz>
-#   Copyright © 2015 Jonathan Hale <squareys@googlemail.com>
+#   Copyright © 2015, 2016 Jonathan Hale <squareys@googlemail.com>
 #
 #   Permission is hereby granted, free of charge, to any person obtaining a
 #   copy of this software and associated documentation files (the "Software"),
@@ -39,28 +39,59 @@
 #   DEALINGS IN THE SOFTWARE.
 #

-set(LIBOVR_ROOT ${CMAKE_INSTALL_PREFIX})
+if(NOT OVR_SDK_ROOT)
+    find_path(OVR_SDK_ROOT OculusSDK)

-if(NOT OVR_SDK_ROOT)
-    message(WARNING "OVR_SDK_ROOT is not set. Will try to find headers and library in ${CMAKE_INSTALL_PREFIX}." )
-else()
-    set(LIBOVR_ROOT ${OVR_SDK_ROOT}/LibOVR)
+    if(OVR_SDK_ROOT)
+        set(OVR_SDK_ROOT "${OVR_SDK_ROOT}/OculusSDK")
+        message(STATUS "Found OculusSDK: ${OVR_SDK_ROOT}")
+    endif()
+
 endif()
+
+set(LIBOVR_ROOT ${OVR_SDK_ROOT}/LibOVR)

 # find include directory
 find_path(OVR_INCLUDE_DIR NAMES OVR_CAPI.h HINTS ${LIBOVR_ROOT}/Include)

 if(WIN32)
     if(MSVC)
-        find_library(OVR_LIBRARY NAMES LibOVR HINTS ${LIBOVR_ROOT}/Lib/Windows)
+        if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+            # compiling for 64 bit
+            set(_OVR_MSVC_ARCH "x64")
+        else()
+            # compiling for 32 bit
+            set(_OVR_MSVC_ARCH "Win32")
+        endif()
+
+        # select the correct library folder matching MSVC version
+        if (MSVC_VERSION GREATER 1800)
+            set(_OVR_MSVC_NAME "VS2015")
+        elseif (MSVC_VERSION GREATER 1700)
+            set(_OVR_MSVC_NAME "VS2013")
+        elseif (MSVC_VERSION GREATER 1600)
+            set(_OVR_MSVC_NAME "VS2012")
+        else()
+            set(_OVR_MSVC_NAME "VS2010")
+        endif()
+
+        find_library(OVR_LIBRARY NAMES LibOVR HINTS "${LIBOVR_ROOT}/Lib/Windows/${_OVR_MSVC_ARCH}/Release/${_OVR_MSVC_NAME}")
+
+        unset(_OVR_MSVC_ARCH)
+        unset(_OVR_MSVC_NAME)
     elseif(MINGW)
-        # linking against the MSVC dll with MinGW does not work directly. Instead, you need to
-        # link against a specific version. This will cause problems with newer oculus runtimes,
-        # though. (FIXME!)
-        # The clean way to link against libOVR, which seems to require the Windows DDK
-        find_library(OVR_LIBRARY NAMES LibOVRRT32_0_8.dll HINTS "C:/Windows/SysWOW64")
-        #find_library(OVR_LIBRARY NAMES LibOVR HINTS ${LIBOVR_ROOT}/Lib/Windows/Win32/Release/VS2012)
+        # we cannot link against the MSVC lib with MinGW. Instead, we link directly to the runtime DLL,
+        # which requires the Oculus runtime to be installed.
+        if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+            # compiling for 64 bit
+            find_library(OVR_LIBRARY NAMES LibOVRRT64_1.dll HINTS "C:/Program Files (x86)/Oculus/Support/oculus-runtime")
+        else()
+            # compiling for 32 bit
+            find_library(OVR_LIBRARY NAMES LibOVRRT32_1.dll HINTS "C:/Program Files (x86)/Oculus/Support/oculus-runtime")
+        endif()
     endif()
+else()
+    error("The Oculus SDK does not support ${CMAKE_SYSTEM_NAME}.")
 endif()

 include(FindPackageHandleStandardArgs)


COMP: more checks before warning

COMP: more checks before warning

--- CMake/FindOssim.cmake
+++ CMake/FindOssim.cmake
@@ -32,13 +32,20 @@
 if(EXISTS "${OSSIM_INCLUDE_DIR}/ossim/imaging/ossimImageRenderer.h")
   file(STRINGS "${OSSIM_INCLUDE_DIR}/ossim/imaging/ossimImageRenderer.h" _ossim_image_renderer_h_CONTENTS REGEX "^// \\$Id: ossimImageRenderer\\.h [0-9.]+ ")
   string(REGEX REPLACE ".*ossimImageRenderer\\.h ([0-9.]+) .*" "\\1" _ossim_svn_revision_hint "${_ossim_image_renderer_h_CONTENTS}")
-  if(NOT "${_ossim_svn_revision_hint}" STREQUAL "23537")
-    message(WARNING "The OSSIM version found doesn't correspond to SVN revision 23537 (the recommended revision for OTB)."
-                      "There are known issues with version 1.8.16 (bugs in Sentinel1 "
-                      "calibration) and with official archive 1.8.20-1 (RpcModel returns "
-                      "nans outside the image extent)")
+
+  if("${_ossim_svn_revision_hint}" LESS "23537")
+    message(WARNING "The OSSIM include directory detected by OTB is: '${OSSIM_INCLUDE_DIR}'."
+      "This version does not have support for SENTINEL-1 products."
+      "Opening an image will result in immediate crash!. "
+      "Please consider updating your ossim to latest stable release.(1.8.20-3)")
+  else()
+    if("${_ossim_svn_revision_hint}" LESS "23664")
+      message(WARNING "The OSSIM include directory detected by OTB is '${OSSIM_INCLUDE_DIR}'."
+        "This version has a critical bug inside ossimRpcModel."
+        "When an input point outside image extent is given the model returns 'NaN'."
+        "Please consider updating your ossim to latest stable release.(1.8.20-3)")
+    endif()
   endif()
-  #message(STATUS "OSSIM SVN rev. hint : ${_ossim_svn_revision_hint}")
 else()
   if(NOT Ossim_FIND_QUIETLY)
     message(WARNING "ossimImageRenderer.h not found !")
@@ -55,5 +62,5 @@

 mark_as_advanced( OSSIM_INCLUDE_DIR OSSIM_LIBRARY )

-set(OSSIM_LIBRARIES ${OSSIM_LIBRARY})
+set(OSSIM_LIBRARIES "${OSSIM_LIBRARY};${OPENTHREADS_LIBRARY}")
 set(OSSIM_INCLUDE_DIRS ${OSSIM_INCLUDE_DIR})


Removed stray colon

Removed stray colon

--- cmake/ChibiOS/18.2/ChibiOS_RTOS.cmake
+++ cmake/ChibiOS/18.2/ChibiOS_RTOS.cmake
@@ -44,7 +44,7 @@
 SET (CHIBIOS_SOURCES_${CHIBIOS_KERNEL}_MEMPOOLS   os/common/oslib/src/chmempools.c)
 SET (CHIBIOS_SOURCES_${CHIBIOS_KERNEL}_FACTORY    os/common/oslib/src/chfactory.c)

-SET (CHIBIOS_SOURCES_rt_TM:         os/rt/src/chtm.c)
+SET (CHIBIOS_SOURCES_rt_TM          os/rt/src/chtm.c)
 SET (CHIBIOS_SOURCES_rt_REGISTRY    os/rt/src/chregistry.c)
 SET (CHIBIOS_SOURCES_rt_SEMAPHORES  os/rt/src/chsem.c)
 SET (CHIBIOS_SOURCES_rt_MUTEXES     os/rt/src/chmtx.c)
@@ -70,7 +70,7 @@
 IF (CHIBIOS_SOURCES_${CHIBIOS_KERNEL}_${STM32_FAMILY})
     LIST(APPEND CHIBIOS_SOURCES_${CHIBIOS_KERNEL} ${CHIBIOS_SOURCES_${CHIBIOS_KERNEL}_${STM32_FAMILY}})
 ENDIF()
-
+
 IF (CHIBIOS_INCLUDES_${CHIBIOS_KERNEL}_${STM32_FAMILY})
     LIST(APPEND CHIBIOS_INCLUDES_${CHIBIOS_KERNEL} ${CHIBIOS_INCLUDES_${CHIBIOS_KERNEL}_${STM32_FAMILY}})
 ENDIF()
@@ -82,7 +82,7 @@
     IF (CHIBIOS_INCLUDES_${CHIBIOS_KERNEL}_${COMP})
         LIST(APPEND CHIBIOS_INCLUDES_${CHIBIOS_KERNEL} ${CHIBIOS_INCLUDES_${CHIBIOS_KERNEL}_${COMP}})
     ENDIF()
-
+
     IF (CHIBIOS_SOURCES_${CHIBIOS_KERNEL}_${COMP}_${STM32_FAMILY})
         LIST(APPEND CHIBIOS_SOURCES_${CHIBIOS_KERNEL} ${CHIBIOS_SOURCES_${CHIBIOS_KERNEL}_${COMP}_${STM32_FAMILY}})
     ENDIF()
@@ -90,5 +90,3 @@
         LIST(APPEND CHIBIOS_INCLUDES_${CHIBIOS_KERNEL} ${CHIBIOS_INCLUDES_${CHIBIOS_KERNEL}_${COMP}_${STM32_FAMILY}})
     ENDIF()
 ENDFOREACH()
-
-


[CMake] Avoid clang dependencies in the runtimes build

Dependencies like clang aren't available in the runtimes build, this
was accidentally omitted in D57992.

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


refs #4871 default to USE_VALGRIND=ON

refs #4871 default to USE_VALGRIND=ON

git-svn-id: b5c078ec0b4d3a50497e9dd3081db18a5b4f16e5@46773 c7de825b-a66e-492c-adef-691d508d4ae1

--- cmake_modules/TokuSetupCompiler.cmake
+++ cmake_modules/TokuSetupCompiler.cmake
@@ -126,6 +126,7 @@
   endif ()
 endif ()

+option(USE_VALGRIND "Do not pass NVALGRIND to the compiler, because valgrind will be run on the generated executables." ON)
 if (NOT USE_VALGRIND)
   set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE NVALGRIND=1)
 endif ()


Fix high bit depth build in cmake.

Fix high bit depth build in cmake.

Fix the mistyped variable name that smashed a source list.

Change-Id: Id654ec06d2a1c479de5f61bb8c48e9e1df51086b

--- aom_dsp/aom_dsp.cmake
+++ aom_dsp/aom_dsp.cmake
@@ -231,7 +231,7 @@
         "${AOM_ROOT}/aom_dsp/x86/highbd_variance_sse4.c")

     set(AOM_DSP_ENCODER_AVX2_INTRIN
-        ${AOM_ENCODER_DSP_AVX2_INTRIN}
+        ${AOM_DSP_ENCODER_AVX2_INTRIN}
         "${AOM_ROOT}/aom_dsp/x86/sad_highbd_avx2.c")
   endif ()


Disable -Werror for release build

Disable -Werror for release build


Fixup for one user's Ada/Mac OS X problems when using the the 4.2 version of
the http://macada.org/ version of the GNAT compiler.

svn path=/trunk/; revision=7420

--- cmake/modules/CMakeAdaInformation.cmake
+++ cmake/modules/CMakeAdaInformation.cmake
@@ -173,8 +173,15 @@
 # constraints, add_executable should work for the Ada language.

 IF(NOT CMAKE_Ada_LINK_EXECUTABLE)
-  SET(CMAKE_Ada_LINK_EXECUTABLE
+  IF(APPLE)
+    # Temporary fixup for one user's Ada/Mac OS X problems when using the
+    # the 4.2 version of the http://macada.org/ version of the GNAT compiler.
+    SET(CMAKE_Ada_LINK_EXECUTABLE
+    "${GNAT_EXECUTABLE_BUILDER} <FLAGS> <CMAKE_Ada_LINK_FLAGS> <LINK_FLAGS> <TARGET_BASE>.adb -largs <LINK_LIBRARIES> -lgcc_s.1")
+  ELSE(APPLE)
+    SET(CMAKE_Ada_LINK_EXECUTABLE
     "${GNAT_EXECUTABLE_BUILDER} <FLAGS> <CMAKE_Ada_LINK_FLAGS> <LINK_FLAGS> <TARGET_BASE>.adb -largs <LINK_LIBRARIES>")
+  ENDIF(APPLE)
 ENDIF(NOT CMAKE_Ada_LINK_EXECUTABLE)

 IF(CMAKE_Ada_STANDARD_LIBRARIES_INIT)


fix uuid on visual studio

fix uuid on visual studio

Change-Id: Id9df9fb1903b35ee4ed5b9ec280fa6bdb038d906
Reviewed-on: http://gerrit.aldebaran.lan:8080/75
Reviewed-by: Dimitri Merejkowsky <1e4b13000fa8777df4cefd2fd8215187e3deb062@aldebaran-robotics.com>
Reviewed-by: Cedric GESTES <ddb78fe00abb42f91254c16a0860e38eb0781789@aldebaran-robotics.com>
Tested-by: Cedric GESTES <ddb78fe00abb42f91254c16a0860e38eb0781789@aldebaran-robotics.com>

--- cmake/qibuild/modules/uuid-config.cmake
+++ cmake/qibuild/modules/uuid-config.cmake
@@ -4,10 +4,21 @@

 clean(UUID)
 fpath(UUID uuid/uuid.h)
-if (NOT APPLE)
-  flib(UUID uuid)
-  export_lib(UUID)
+if(UNIX)
+  if(APPLE)
+    # UUID is header-only on apple
+    export_header(UUID)
+  else()
+    flib(UUID uuid)
+    export_lib(UUID)
+  endif()
 else()
-  # UUID is header-only on apple
-  export_header(UUID)
+  if(MSVC)
+    # UUID is libonly on Visual Studio
+    set(UUID_INCLUDE_DIRS " " CACHE STRING "" FORCE)
+    set(UUID_LIBRARIES "uuid" CACHE STRING "" FORCE)
+    export_lib(UUID)
+  else()
+    # UUID on mingw is yet something else
+  endif()
 endif()


Fix the dumb version of post-CMake command to always exit successfuly. External project may not have install steps defined but the post-CMake fix is still being applied causing build failure previously.

--- CMake/Modules/Urho3D-CMake-common.cmake
+++ CMake/Modules/Urho3D-CMake-common.cmake
@@ -757,25 +757,6 @@
         add_dependencies (${TARGET_NAME} RESOURCE_CHECK_${TARGET_NAME})
     endif ()
 endmacro ()
-
-# Post-CMake fixes for iOS project
-if (IOS)
-    # TODO: can be removed when CMake minimum required has reached 2.8.12
-    if (CMAKE_VERSION VERSION_LESS 2.8.12)
-        # Due to a bug in the CMake/Xcode generator (prior to version 2.8.12) where it has wrongly assumed the IOS bundle structure to be the same as MacOSX bundle structure,
-        # below temporary fix is required in order to solve the auto-linking issue when dependent libraries are changed
-        add_custom_target (FIX_DEPEND_HELPER ALL
-            sed -i '' 's/\/Contents\/MacOS//g' ${CMAKE_BINARY_DIR}/CMakeScripts/XCODE_DEPEND_HELPER.make
-            COMMENT "Fixing CMake/Xcode depend helper scripts")
-    endif ()
-
-    # Due to a bug in the CMake/Xcode generator (still exists in 3.1) that prevents iOS targets (library and bundle) to be installed correctly
-    # (see http://public.kitware.com/Bug/bug_relationship_graph.php?bug_id=12506&graph=dependency),
-    # below temporary fix is required to work around the bug
-    add_custom_target (FIX_INSTALL ALL
-        sed -i '' 's/EFFECTIVE_PLATFORM_NAME//g' ${CMAKE_BINARY_DIR}/CMakeScripts/install_postBuildPhase.make*
-        COMMENT "Fixing CMake/Xcode install scripts")
-endif ()

 # Macro for adjusting target output name by dropping _suffix from the target name
 macro (adjust_target_name)
@@ -1042,3 +1023,21 @@
         endif ()
     endforeach ()
 endmacro ()
+
+# Post-CMake fixes
+if (IOS)
+    # TODO: can be removed when CMake minimum required has reached 2.8.12
+    if (CMAKE_VERSION VERSION_LESS 2.8.12)
+	# Due to a bug in the CMake/Xcode generator (prior to version 2.8.12) where it has wrongly assumed the IOS bundle structure to be the same as MacOSX bundle structure,
+	# below temporary fix is required in order to solve the auto-linking issue when dependent libraries are changed
+	list (APPEND POST_CMAKE_FIXES COMMAND sed -i '' 's/\/Contents\/MacOS//g' ${CMAKE_BINARY_DIR}/CMakeScripts/XCODE_DEPEND_HELPER.make || exit 0)
+    endif ()
+
+    # Due to a bug in the CMake/Xcode generator (still exists in 3.1) that prevents iOS targets (library and bundle) to be installed correctly
+    # (see http://public.kitware.com/Bug/bug_relationship_graph.php?bug_id=12506&graph=dependency),
+    # below temporary fix is required to work around the bug
+    list (APPEND POST_CMAKE_FIXES COMMAND sed -i '' 's/EFFECTIVE_PLATFORM_NAME//g' ${CMAKE_BINARY_DIR}/CMakeScripts/install_postBuildPhase.make* || exit 0)
+endif ()
+if (POST_CMAKE_FIXES)
+    add_custom_target (POST_CMAKE_FIXES ALL ${POST_CMAKE_FIXES} COMMENT "Applying post-cmake fixes")
+endif ()


Android: Disable experimental compilers (NDK 0.8c)

--HG--
branch : v1-9

--- CMake/toolchain/android.toolchain.cmake
+++ CMake/toolchain/android.toolchain.cmake
@@ -471,6 +471,8 @@
  string( REPLACE "android-" "" ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_SUPPORTED_NATIVE_API_LEVELS}" )
  file( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" )
  __LIST_FILTER( __availableToolchains "^[.]" )
+ __LIST_FILTER( __availableToolchains ".*clang.*") # ignore experimental compilers
+ __LIST_FILTER( __availableToolchains ".*llvm.*")
  set( __availableToolchainMachines "" )
  set( __availableToolchainArchs "" )
  set( __availableToolchainCompilerVersions "" )


eliminate patch_ffmpeg override

eliminate patch_ffmpeg override

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

--- projects/ffmpeg.cmake
+++ projects/ffmpeg.cmake
@@ -3,7 +3,7 @@
 set(FFMPEG_MSWVER 2.6.2.1)
 set(FFMPEG_CFGVER 2.6.2)
 ########################################
-function(patch_ffmpeg)
+function(build_ffmpeg)
   set(mswVer ${FFMPEG_MSWVER})
   set(cfgVer ${FFMPEG_CFGVER})
   if(NOT (XP_DEFAULT OR XP_PRO_FFMPEG OR XP_PRO_FFMPEG_${mswVer} OR XP_PRO_FFMPEG_${cfgVer}))
@@ -29,15 +29,6 @@
     if(XP_PRO_FFMPEG_${cfgVer})
       xpListAppendIfDne(FFMPEG_VERSIONS ${cfgVer})
     endif()
-  endif()
-  set(FFMPEG_VERSIONS ${FFMPEG_VERSIONS} PARENT_SCOPE) # make FFMPEG_VERSIONS available to build_ffmpeg
-endfunction()
-########################################
-function(build_ffmpeg)
-  set(mswVer ${FFMPEG_MSWVER})
-  set(cfgVer ${FFMPEG_CFGVER})
-  if(NOT (XP_DEFAULT OR XP_PRO_FFMPEG_${mswVer} OR XP_PRO_FFMPEG_${cfgVer}))
-    return()
   endif()
   if(WIN32)
     set(VER ${mswVer})


VFS-8318 Added conda build dir to nss cmake scripts

--- cmake/FindNSS.cmake
+++ cmake/FindNSS.cmake
@@ -28,6 +28,7 @@
       pk11pub.h
     PATHS
       ${_NSS_INCLUDEDIR}
+      ${CONDA_BUILD_PREFIX}/include
       /usr/include
       /usr/local/include
       /opt/local/include
@@ -43,6 +44,7 @@
       ssl3
     PATHS
       ${_NSS_LIBDIR}
+      ${CONDA_BUILD_PREFIX}/lib
       /usr/lib
       /usr/local/lib
       /opt/local/lib
@@ -54,6 +56,7 @@
       smime3
     PATHS
       ${_NSS_LIBDIR}
+      ${CONDA_BUILD_PREFIX}/lib
       /usr/lib
       /usr/local/lib
       /opt/local/lib
@@ -65,6 +68,7 @@
       nss3
     PATHS
       ${_NSS_LIBDIR}
+      ${CONDA_BUILD_PREFIX}/lib
       /usr/lib
       /usr/local/lib
       /opt/local/lib
@@ -77,6 +81,7 @@
       nssutil3
     PATHS
       ${_NSS_LIBDIR}
+      ${CONDA_BUILD_PREFIX}/lib
       /usr/lib
       /usr/local/lib
       /opt/local/lib
@@ -88,6 +93,7 @@
       nspr4
     PATHS
       ${_NSS_LIBDIR}
+      ${CONDA_BUILD_PREFIX}/lib
       /usr/lib
       /usr/local/lib
       /opt/local/lib


update FindTBB for 4.1

update FindTBB for 4.1

--- cmake/FindTBB.cmake
+++ cmake/FindTBB.cmake
@@ -64,13 +64,13 @@
         ELSE (CMAKE_CL_64)
             SET (TBB_MSVC_LIB "ia32")
         ENDIF (CMAKE_CL_64)
-        IF (MSVC_VERSION GREATER 1599)
+        IF (MSVC_VERSION GREATER 1699)
+            SET (TBB_MSVC_LIB "${TBB_MSVC_LIB}/vc11")
+        ELSEIF (MSVC_VERSION GREATER 1599)
             SET (TBB_MSVC_LIB "${TBB_MSVC_LIB}/vc10")
         ELSEIF (MSVC_VERSION GREATER 1499)
             SET (TBB_MSVC_LIB "${TBB_MSVC_LIB}/vc9")
-        ELSEIF (MSVC_VERSION GREATER 1399)
-            SET (TBB_MSVC_LIB "${TBB_MSVC_LIB}/vc8")
-        ENDIF (MSVC_VERSION GREATER 1599)
+        ENDIF (MSVC_VERSION GREATER 1699)

         IF (TBB_ROOT)
             SET (TBB_LIB_PATH "${TBB_ROOT}/lib/${TBB_MSVC_LIB}")
@@ -238,7 +238,7 @@
         SET (TBB_FOUND TRUE CACHE BOOL "Found TBB")
     ELSE (TBB_TEST_SOURCE_RUNS)
         MESSAGE (STATUS "NOT Found TBB")
-        SET (TBB_FOUND FALSE CACHE BOL "NOT Found TBB")
+        SET (TBB_FOUND FALSE CACHE BOOL "NOT Found TBB")
     ENDIF (TBB_TEST_SOURCE_RUNS)
     SET (CMAKE_REQUIRED_INCLUDES ${SAFE_CMAKE_REQUIRED_INCLUDES})
     SET (CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES})


Delete cmake_install.cmake

Delete cmake_install.cmake

--- cmake_install.cmake
+++ cmake_install.cmake
@@ -1,39 +0,0 @@
-# Install script for directory: /Users/Mike/Developer/SMB_LZ_Tool
-
-# Set the install prefix
-if(NOT DEFINED CMAKE_INSTALL_PREFIX)
-  set(CMAKE_INSTALL_PREFIX "/usr/local")
-endif()
-string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
-
-# Set the install configuration name.
-if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
-  if(BUILD_TYPE)
-    string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
-           CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
-  else()
-    set(CMAKE_INSTALL_CONFIG_NAME "")
-  endif()
-  message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
-endif()
-
-# Set the component getting installed.
-if(NOT CMAKE_INSTALL_COMPONENT)
-  if(COMPONENT)
-    message(STATUS "Install component: \"${COMPONENT}\"")
-    set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
-  else()
-    set(CMAKE_INSTALL_COMPONENT)
-  endif()
-endif()
-
-if(CMAKE_INSTALL_COMPONENT)
-  set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
-else()
-  set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
-endif()
-
-string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
-       "${CMAKE_INSTALL_MANIFEST_FILES}")
-file(WRITE "/Users/Mike/Developer/SMB_LZ_Tool/${CMAKE_INSTALL_MANIFEST}"
-     "${CMAKE_INSTALL_MANIFEST_CONTENT}")


Add override and inline based on warnings

--- build_settings.cmake
+++ build_settings.cmake
@@ -73,7 +73,7 @@
 endif()

 if(EXTRA_INCLUDE_DIRECTORY)
-    include_directories(${EXTRA_INCLUDE_DIRECTORY})
+    include_directories(SYSTEM ${EXTRA_INCLUDE_DIRECTORY})
 endif()
 if(EXTRA_LINK_DIRECTORY)
     link_directories(${EXTRA_LINK_DIRECTORY})


Provide a meaningful diagnostic when LLVM_PATH doesn't point to a directory

git-svn-id: 756ef344af921d95d562d9e9f9389127a89a6314@369312 91177308-0d34-0410-b5e6-96231b3b80d8

--- cmake/Modules/HandleOutOfTreeLLVM.cmake
+++ cmake/Modules/HandleOutOfTreeLLVM.cmake
@@ -9,6 +9,9 @@
     set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree")
     set(LLVM_MAIN_SRC_DIR ${LLVM_PATH})
     set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules")
+    if (NOT IS_DIRECTORY "${LLVM_PATH}")
+      message(FATAL_ERROR "The provided LLVM_PATH (${LLVM_PATH}) is not a valid directory")
+    endif()
   elseif(LLVM_CONFIG_PATH)
     message(STATUS "Found LLVM_CONFIG_PATH as ${LLVM_CONFIG_PATH}")
     set(LIBCXX_USING_INSTALLED_LLVM 1)


haskell-cmake-improvements: serialize whole compilation

--- cmake/Modules/LibAddHaskellPlugin.cmake
+++ cmake/Modules/LibAddHaskellPlugin.cmake
@@ -168,13 +168,30 @@
 												"${CMAKE_CURRENT_BINARY_DIR}/Setup.hs"
 												@ONLY)

-										# as we require the sandbox to exist we can do this during the configuration phase it doesn't compile or install anything
-										execute_process (COMMAND ${CABAL_EXECUTABLE} sandbox init --sandbox "${HASKELL_SHARED_SANDBOX}" -v0 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-			    						foreach (SANDBOX_ADD_SOURCE ${ARG_SANDBOX_ADD_SOURCES})
-			    							# our custom libs are all to be processed by cmake before we can add them, so enforce that, the build is more stable this way
-											add_subdirectory ("${CMAKE_SOURCE_DIR}/${SANDBOX_ADD_SOURCE}" "${CMAKE_BINARY_DIR}/${SANDBOX_ADD_SOURCE}")
-			    							execute_process (COMMAND ${CABAL_EXECUTABLE} sandbox add-source "${CMAKE_BINARY_DIR}/${SANDBOX_ADD_SOURCE}" -v0 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-			    						endforeach ()
+										# as we require the sandbox to exist we can do this during
+										# the configuration phase it doesn't compile or install
+										# anything
+										execute_process (COMMAND ${CABAL_EXECUTABLE} sandbox init
+													 --sandbox
+													 "${HASKELL_SHARED_SANDBOX}" -v0
+												 WORKING_DIRECTORY
+													 ${CMAKE_CURRENT_BINARY_DIR})
+										foreach (SANDBOX_ADD_SOURCE ${ARG_SANDBOX_ADD_SOURCES})
+										# our custom libs are all to be processed by cmake before we
+										# can add them, so enforce that, the build is more stable
+										# this way
+											add_subdirectory (
+												"${CMAKE_SOURCE_DIR}/${SANDBOX_ADD_SOURCE}"
+												"${CMAKE_BINARY_DIR}/${SANDBOX_ADD_SOURCE}")
+											execute_process (
+												COMMAND
+													${CABAL_EXECUTABLE} sandbox
+													add-source
+													"${CMAKE_BINARY_DIR}/${SANDBOX_ADD_SOURCE}"
+													-v0
+												WORKING_DIRECTORY
+													${CMAKE_CURRENT_BINARY_DIR})
+										endforeach ()

 										# Grab potential haskell source files
 										file (GLOB_RECURSE PLUGIN_SOURCE_FILES_UNFILTERED
@@ -201,21 +218,48 @@
 										     "${CMAKE_SOURCE_DIR}/src/plugins/haskell/Setup.hs.in"
 										     "${ARG_ADDITIONAL_SOURCES}")

-										# reconfiguration due to Cabal library version issues on stretch
-										install_sandbox_dependencies (DEPENDS c2hs_haskell)
+										get_property (HASKELL_LAST_PLUGIN
+											      GLOBAL
+											      PROPERTY HASKELL_LAST_PLUGIN)
+										if (NOT HASKELL_LAST_PLUGIN)
+											set (HASKELL_LAST_PLUGIN ${target})
+											add_custom_command (
+												OUTPUT ${PLUGIN_HASKELL_NAME}
+												COMMAND ${CABAL_EXECUTABLE} install
+													${CABAL_OPTS} --only-dependencies
+													--offline -v0 || true
+												WORKING_DIRECTORY
+													${CMAKE_CURRENT_BINARY_DIR}
+												DEPENDS c2hs_haskell)
+										else (NOT HASKELL_LAST_PLUGIN)
+											add_custom_command (
+												OUTPUT ${PLUGIN_HASKELL_NAME}
+												COMMAND ${CABAL_EXECUTABLE} install
+													${CABAL_OPTS} --only-dependencies
+													--offline -v0 || true
+												WORKING_DIRECTORY
+													${CMAKE_CURRENT_BINARY_DIR}
+												DEPENDS ${HASKELL_LAST_PLUGIN})
+										endif (NOT HASKELL_LAST_PLUGIN)
+										set_property (GLOBAL
+											      PROPERTY HASKELL_LAST_PLUGIN
+												       "${target}")
+
+										# reconfiguration due to Cabal library version issues on
+										# stretch
 										add_custom_command (OUTPUT ${PLUGIN_HASKELL_NAME}
-													COMMAND ${CABAL_EXECUTABLE} install ${CABAL_OPTS} --only-dependencies --offline -v0 || true
 												    COMMAND ${CABAL_EXECUTABLE} configure
 													    ${CABAL_OPTS} -v0
 												    COMMAND ${CABAL_EXECUTABLE} build -v0 ||
-													    ${CABAL_EXECUTABLE} configure
+													    ( ${CABAL_EXECUTABLE} configure
 													    ${CABAL_OPTS} -v0 &&
-													    ${CABAL_EXECUTABLE} build -v0
+													    ${CABAL_EXECUTABLE} build -v0 )
 												    WORKING_DIRECTORY
 													    ${CMAKE_CURRENT_BINARY_DIR}
 												    DEPENDS c2hs_haskell
 													    ${PLUGIN_SOURCE_FILES}
-													    ${HASKELL_ADD_SOURCES_TARGET})
+													    ${HASKELL_ADD_SOURCES_TARGET}
+												    APPEND)
 										add_custom_target (${target}
 												   ALL
 												   DEPENDS ${PLUGIN_HASKELL_NAME})
@@ -321,45 +365,3 @@

 	mark_as_advanced (GHC_FFI_LIB GHC_RTS_LIB GHC_BASE_LIB GHC_GMP_LIB GHC_PRIM_LIB)
 endmacro (add_haskell_plugin)
-
-# ~~~
-# Allows installing sandbox dependencies in a serial manner
-# to avoid cabal concurrency issues https://github.com/haskell/cabal/issues/2220.
-#
-# DEPENDS:
-#  additional targets this call should be dependent on
-# ~~~
-macro (install_sandbox_dependencies)
-	cmake_parse_arguments (ARG
-			       "" # optional keywords
-			       "" # one value keywords
-			       "DEPENDS" # multi value keywords
-			       ${ARGN})
-
-	if (BUILD_SHARED OR BUILD_FULL)
-		set (CABAL_OPTS "--enable-shared")
-	endif (BUILD_SHARED OR BUILD_FULL)
-
-	get_property (HASKELL_SANDBOX_DEP_IDX GLOBAL PROPERTY HASKELL_SANDBOX_DEP_IDX)
-	if (NOT HASKELL_SANDBOX_DEP_IDX)
-		set (HASKELL_SANDBOX_DEP_IDX 1)
-		add_custom_command (OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cabal.sandbox.config"
-				    COMMAND ${CABAL_EXECUTABLE} install ${CABAL_OPTS} --only-dependencies --offline -v0 || true
-				    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-				    DEPENDS ${ARG_DEPENDS})
-		set (HASKELL_ADD_SOURCES_TARGET haskell-add-sources-${HASKELL_SANDBOX_DEP_IDX})
-	else (NOT HASKELL_SANDBOX_DEP_IDX)
-		add_custom_command (OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cabal.sandbox.config"
-				    COMMAND ${CABAL_EXECUTABLE} install ${CABAL_OPTS} --only-dependencies --offline -v0 || true
-				    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-				    DEPENDS haskell-add-sources-${HASKELL_SANDBOX_DEP_IDX}
-					    ${ARG_DEPENDS})
-		math (EXPR HASKELL_SANDBOX_DEP_IDX "${HASKELL_SANDBOX_DEP_IDX} + 1")
-		set (HASKELL_ADD_SOURCES_TARGET haskell-add-sources-${HASKELL_SANDBOX_DEP_IDX})
-	endif (NOT HASKELL_SANDBOX_DEP_IDX)
-	add_custom_target (${HASKELL_ADD_SOURCES_TARGET} ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/cabal.sandbox.config")
-
-	set_property (GLOBAL PROPERTY HASKELL_SANDBOX_DEP_IDX "${HASKELL_SANDBOX_DEP_IDX}")
-endmacro (install_sandbox_dependencies)
-
-


Remove gflags (#2813)

Remove gflags (#2813)

Seems like gflags is not needed. This *might* remove writing spurious files into the home directory on the RISE infrastructure.

--- cmake/Modules/ThirdpartyToolchain.cmake
+++ cmake/Modules/ThirdpartyToolchain.cmake
@@ -51,44 +51,6 @@
   add_dependencies(gtest googletest_ep)
   add_dependencies(gtest_main googletest_ep)
   add_dependencies(gmock_main googletest_ep)
-
-  set(GFLAGS_CMAKE_CXX_FLAGS ${EP_CXX_FLAGS})
-
-  set(GFLAGS_URL "https://github.com/gflags/gflags/archive/v${GFLAGS_VERSION}.tar.gz")
-  set(GFLAGS_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gflags_ep-prefix/src/gflags_ep")
-  set(GFLAGS_HOME "${GFLAGS_PREFIX}")
-  set(GFLAGS_INCLUDE_DIR "${GFLAGS_PREFIX}/include")
-  if(MSVC)
-    set(GFLAGS_STATIC_LIB "${GFLAGS_PREFIX}/lib/gflags_static.lib")
-  else()
-    set(GFLAGS_STATIC_LIB "${GFLAGS_PREFIX}/lib/libgflags.a")
-  endif()
-  set(GFLAGS_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-                        -DCMAKE_INSTALL_PREFIX=${GFLAGS_PREFIX}
-                        -DBUILD_SHARED_LIBS=OFF
-                        -DBUILD_STATIC_LIBS=ON
-                        -DBUILD_PACKAGING=OFF
-                        -DBUILD_TESTING=OFF
-                        -BUILD_CONFIG_TESTS=OFF
-                        -DINSTALL_HEADERS=ON
-                        -DCMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}=${EP_CXX_FLAGS}
-                        -DCMAKE_C_FLAGS_${UPPERCASE_BUILD_TYPE}=${EP_C_FLAGS}
-                        -DCMAKE_CXX_FLAGS=${GFLAGS_CMAKE_CXX_FLAGS})
-
-  ExternalProject_Add(gflags_ep
-    URL ${GFLAGS_URL}
-    ${EP_LOG_OPTIONS}
-    BUILD_IN_SOURCE 1
-    BUILD_BYPRODUCTS "${GFLAGS_STATIC_LIB}"
-    CMAKE_ARGS ${GFLAGS_CMAKE_ARGS})
-
-  message(STATUS "GFlags include dir: ${GFLAGS_INCLUDE_DIR}")
-  message(STATUS "GFlags static library: ${GFLAGS_STATIC_LIB}")
-  include_directories(SYSTEM ${GFLAGS_INCLUDE_DIR})
-  ADD_THIRDPARTY_LIB(gflags
-    STATIC_LIB ${GFLAGS_STATIC_LIB})
-
-  add_dependencies(gflags gflags_ep)
 endif()

 set(Boost_USE_STATIC_LIBS ON)


Update android.toolchain.cmake

Update android.toolchain.cmake

--- 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-r7
+#  Android CMake toolchain file, for use with the Android NDK r5-r8
 #  Requires cmake 2.6.3 or newer (2.8.3 or newer is recommended).
 #  See home page: http://code.google.com/p/android-cmake/
 #
@@ -20,7 +20,7 @@
 #
 #  Usage Windows:
 #     You need native port of make to build your project.
-#     Android NDK r7 already has make.exe on board.
+#     Android NDK r7 (or newer) already has make.exe on board.
 #     For older NDK you have to install it separately.
 #     For example, this one: http://gnuwin32.sourceforge.net/packages/make.htm
 #
@@ -107,10 +107,13 @@
 #    under the ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}
 #    (depending on the target ABI). This is convenient for Android packaging.
 #
+#  Authors:
+#    Ethan Rublee ethan.ruble@gmail.com
+#    Andrey Kamaev andrey.kamaev@itseez.com
 #
 #  Change Log:
-#   - initial version December 2010 Ethan Rublee ethan.ruble@gmail.com
-#   - modified April 2011 Andrey Kamaev andrey.kamaev@itseez.com
+#   - initial version December 2010
+#   - modified April 2011
 #     [+] added possibility to build with NDK (without standalone toolchain)
 #     [+] support cross-compilation on Windows (native, no cygwin support)
 #     [+] added compiler option to force "char" type to be signed
@@ -121,13 +124,13 @@
 #     [+] EXECUTABLE_OUTPUT_PATH is set by toolchain (required on Windows)
 #     [~] Fixed bug with ANDROID_API_LEVEL variable
 #     [~] turn off SWIG search if it is not found first time
-#   - modified May 2011 Andrey Kamaev andrey.kamaev@itseez.com
+#   - modified May 2011
 #     [~] ANDROID_LEVEL is renamed to ANDROID_API_LEVEL
 #     [+] ANDROID_API_LEVEL is detected by toolchain if not specified
 #     [~] added guard to prevent changing of output directories on the first
 #         cmake pass
 #     [~] toolchain exits with error if ARM_TARGET is not recognized
-#   - modified June 2011 Andrey Kamaev andrey.kamaev@itseez.com
+#   - modified June 2011
 #     [~] default NDK path is updated for version r5c
 #     [+] variable CMAKE_SYSTEM_PROCESSOR is set based on ARM_TARGET
 #     [~] toolchain install directory is added to linker paths
@@ -135,13 +138,13 @@
 #     [+] added macro find_host_package, find_host_program to search
 #         packages/programs on the host system
 #     [~] fixed path to STL library
-#   - modified July 2011 Andrey Kamaev andrey.kamaev@itseez.com
+#   - modified July 2011
 #     [~] fixed options caching
 #     [~] search for all supported NDK versions
 #     [~] allowed spaces in NDK path
-#   - modified September 2011 Andrey Kamaev andrey.kamaev@itseez.com
+#   - modified September 2011
 #     [~] updated for NDK r6b
-#   - modified November 2011 Andrey Kamaev andrey.kamaev@itseez.com
+#   - modified November 2011
 #     [*] rewritten for NDK r7
 #     [+] x86 toolchain support (experimental)
 #     [+] added "armeabi-v6 with VFP" ABI for ARMv6 processors.
@@ -154,21 +157,40 @@
 #     [~] ARM_TARGET is renamed to ANDROID_ABI
 #     [~] ARMEABI_NDK_NAME is renamed to ANDROID_NDK_ABI_NAME
 #     [~] ANDROID_API_LEVEL is renamed to ANDROID_NATIVE_API_LEVEL
-#   - modified January 2012 Andrey Kamaev andrey.kamaev@itseez.com
+#   - modified January 2012
 #     [+] added stlport_static support (experimental)
 #     [+] added special check for cygwin
 #     [+] filtered out hidden files (starting with .) while globbing inside NDK
 #     [+] automatically applied GLESv2 linkage fix for NDK revisions 5-6
 #     [+] added ANDROID_GET_ABI_RAWNAME to get NDK ABI names by CMake flags
-#   - modified February 2012 Andrey Kamaev andrey.kamaev@itseez.com
+#   - modified February 2012
 #     [+] updated for NDK r7b
 #     [~] fixed cmake try_compile() command
 #     [~] Fix for missing install_name_tool on OS X
+#   - modified March 2012
+#     [~] fixed incorrect C compiler flags
+#     [~] fixed CMAKE_SYSTEM_PROCESSOR change on ANDROID_ABI change
+#     [+] improved toolchain loading speed
+#     [+] added assembler language support (.S)
+#     [+] allowed preset search paths and extra search suffixes
+#   - modified April 2012
+#     [+] updated for NDK r7c
+#     [~] fixed most of problems with compiler/linker flags and caching
+#     [+] added option ANDROID_FUNCTION_LEVEL_LINKING
+#   - modified May 2012
+#     [+] updated for NDK r8
+#     [+] added mips architecture support
 # ------------------------------------------------------------------------------

 cmake_minimum_required( VERSION 2.6.3 )

-if( PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
+if( DEFINED CMAKE_CROSSCOMPILING )
+ #subsequent toolchain loading is not really needed
+ return()
+endif()
+
+get_property(_CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
+if( _CMAKE_IN_TRY_COMPILE )
  include( "${CMAKE_CURRENT_SOURCE_DIR}/../android.toolchain.config.cmake" OPTIONAL )
 endif()

@@ -177,19 +199,27 @@
 #this one not so much
 set( CMAKE_SYSTEM_VERSION 1 )

-set( ANDROID_SUPPORTED_NDK_VERSIONS -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
-if( CMAKE_HOST_WIN32 )
- file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS )
- set( ANDROID_NDK_SEARCH_PATHS "${ANDROID_NDK_SEARCH_PATHS}/android-ndk" "$ENV{SystemDrive}/NVPACK/android-ndk" )
-else()
- set( ANDROID_NDK_SEARCH_PATHS /opt/android-ndk "$ENV{HOME}/NVPACK/android-ndk" )
-endif()
-set( ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH /opt/android-toolchain )
+set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -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 )
+  set( ANDROID_NDK_SEARCH_PATHS "${ANDROID_NDK_SEARCH_PATHS}/android-ndk" "$ENV{SystemDrive}/NVPACK/android-ndk" )
+ else()
+  file( TO_CMAKE_PATH "$ENV{HOME}" ANDROID_NDK_SEARCH_PATHS )
+  set( ANDROID_NDK_SEARCH_PATHS /opt/android-ndk "${ANDROID_NDK_SEARCH_PATHS}/NVPACK/android-ndk" )
+ endif()
+endif()
+if(NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH)
+ set( ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH /opt/android-toolchain )
+endif()
+
 set( ANDROID_SUPPORTED_ABIS_arm "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" )
 set( ANDROID_SUPPORTED_ABIS_x86 "x86" )
+set( ANDROID_SUPPORTED_ABIS_mipsel "mips" )

 set( ANDROID_DEFAULT_NDK_API_LEVEL 8 )
 set( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 )
+set( ANDROID_DEFAULT_NDK_API_LEVEL_mips 9 )

 macro( __LIST_FILTER listvar regex )
@@ -408,6 +438,7 @@
 #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" )
+ set( ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
  set( __availableToolchains "standalone" )
  __DETECT_TOOLCHAIN_MACHINE_NAME( __availableToolchainMachines "${ANDROID_STANDALONE_TOOLCHAIN}" )
  if( NOT __availableToolchainMachines )
@@ -417,6 +448,8 @@
   set( __availableToolchainArchs "x86" )
  elseif( __availableToolchainMachines MATCHES arm )
   set( __availableToolchainArchs "arm" )
+ elseif( __availableToolchainMachines MATCHES mipsel )
+  set( __availableToolchainArchs "mipsel" )
  endif()
  if( ANDROID_COMPILER_VERSION )
   #do not run gcc every time because it is relatevely expencive
@@ -489,16 +522,25 @@
  set( X86 true )
  set( ANDROID_NDK_ABI_NAME "x86" )
  set( ANDROID_ARCH_NAME "x86" )
+ set( ANDROID_ARCH_FULLNAME "x86" )
  set( CMAKE_SYSTEM_PROCESSOR "i686" )
+elseif( ANDROID_ABI STREQUAL "mips" )
+ set( MIPS true )
+ set( ANDROID_NDK_ABI_NAME "mips" )
+ set( ANDROID_ARCH_NAME "mips" )
+ set( ANDROID_ARCH_FULLNAME "mipsel" )
+ set( CMAKE_SYSTEM_PROCESSOR "mips" )
 elseif( ANDROID_ABI STREQUAL "armeabi" )
  set( ARMEABI true )
  set( ANDROID_NDK_ABI_NAME "armeabi" )
  set( ANDROID_ARCH_NAME "arm" )
+ set( ANDROID_ARCH_FULLNAME "arm" )
  set( CMAKE_SYSTEM_PROCESSOR "armv5te" )
 elseif( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" )
  set( ARMEABI_V6 true )
  set( ANDROID_NDK_ABI_NAME "armeabi" )
  set( ANDROID_ARCH_NAME "arm" )
+ set( ANDROID_ARCH_FULLNAME "arm" )
  set( CMAKE_SYSTEM_PROCESSOR "armv6" )
  #need always fallback to older platform
  set( ARMEABI true )
@@ -506,17 +548,20 @@
  set( ARMEABI_V7A true )
  set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
  set( ANDROID_ARCH_NAME "arm" )
+ set( ANDROID_ARCH_FULLNAME "arm" )
  set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
 elseif( ANDROID_ABI STREQUAL "armeabi-v7a with VFPV3" )
  set( ARMEABI_V7A true )
  set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
  set( ANDROID_ARCH_NAME "arm" )
+ set( ANDROID_ARCH_FULLNAME "arm" )
  set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
  set( VFPV3 true )
 elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" )
  set( ARMEABI_V7A true )
  set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
  set( ANDROID_ARCH_NAME "arm" )
+ set( ANDROID_ARCH_FULLNAME "arm" )
  set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
  set( VFPV3 true )
  set( NEON true )
@@ -524,10 +569,16 @@
  message( SEND_ERROR "Unknown ANDROID_ABI=\"${ANDROID_ABI}\" is specified." )
 endif()

-set( ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME}} CACHE INTERNAL "ANDROID_ABI can be changed only to one of these ABIs. Changing to any other ABI requires to reset cmake cache." )
+if( CMAKE_BINARY_DIR AND EXISTS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" )
+ #really dirty hack
+ #it is not possible to change CMAKE_SYSTEM_PROCESSOR after the first run...
+ file( APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" "SET(CMAKE_SYSTEM_PROCESSOR \"${CMAKE_SYSTEM_PROCESSOR}\")\n" )
+endif()
+
+set( ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} CACHE INTERNAL "ANDROID_ABI can be changed only to one of these ABIs. Changing to any other ABI requires to reset cmake cache." )
 if( CMAKE_VERSION VERSION_GREATER "2.8" )
- list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME} )
- set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME}} )
+ list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME} )
+ set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} )
 endif()

 if( ANDROID_ARCH_NAME STREQUAL "arm" AND NOT ARMEABI_V6 )
@@ -545,7 +596,7 @@
   message( FATAL_ERROR "Previously selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is missing. You need to remove CMakeCache.txt and rerun cmake manually to change the toolchain" )
  endif()
  list( GET __availableToolchainArchs ${__toolchainIdx} __toolchainArch )
- if( NOT __toolchainArch STREQUAL ANDROID_ARCH_NAME )
+ if( NOT __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
   message( SEND_ERROR "Previously selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." )
  endif()
 else()
@@ -556,7 +607,7 @@
  math( EXPR __availableToolchainsCount "${__availableToolchainsCount}-1" )
  foreach( __idx RANGE ${__availableToolchainsCount} )
   list( GET __availableToolchainArchs ${__idx} __toolchainArch )
-  if( __toolchainArch STREQUAL ANDROID_ARCH_NAME )
+  if( __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
    list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion )
    if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion )
     set( __toolchainMaxVersion "${__toolchainVersion}" )
@@ -584,7 +635,7 @@
 unset( __availableToolchainCompilerVersions )

 #choose native API level
-__INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_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}" )
 #validate
 list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx )
@@ -626,14 +677,19 @@
 # specify the cross compiler
 set( CMAKE_C_COMPILER   "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}"     CACHE PATH "gcc" )
 set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}"     CACHE PATH "g++" )
+set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}"     CACHE PATH "Assembler" )
+if( CMAKE_VERSION VERSION_LESS 2.8.5 )
+ set( CMAKE_ASM_COMPILER_ARG1 "-c" )
+endif()
+#there may be a way to make cmake deduce these TODO deduce the rest of the tools
 set( CMAKE_STRIP        "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}"   CACHE PATH "strip" )
-#there may be a way to make cmake deduce these TODO deduce the rest of the tools
 set( CMAKE_AR           "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}"      CACHE PATH "archive" )
 set( CMAKE_LINKER       "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ld${TOOL_OS_SUFFIX}"      CACHE PATH "linker" )
 set( CMAKE_NM           "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-nm${TOOL_OS_SUFFIX}"      CACHE PATH "nm" )
 set( CMAKE_OBJCOPY      "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" )
 set( CMAKE_OBJDUMP      "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objdump${TOOL_OS_SUFFIX}" CACHE PATH "objdump" )
 set( CMAKE_RANLIB       "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ranlib${TOOL_OS_SUFFIX}"  CACHE PATH "ranlib" )
+set( _CMAKE_TOOLCHAIN_PREFIX "${ANDROID_TOOLCHAIN_MACHINE_NAME}-" )
 if( APPLE )
  find_program( CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool )
  if( NOT CMAKE_INSTALL_NAME_TOOL )
@@ -649,16 +705,12 @@
 set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" )
 set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" )

-set( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS OFF CACHE BOOL "" )
-if( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS )
- if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" )
-  set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" )
- else()
-  set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" )
- endif()
- set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )
-endif()
-set( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS ON CACHE INTERNAL "" FORCE )
+if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" )
+ set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" )
+else()
+ set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" )
+endif()
+set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )

 #includes
 list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_SYSROOT}/usr/include" )
@@ -695,40 +747,49 @@
 # Force set compilers because standard identification works badly for us
 include( CMakeForceCompiler )
 CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
+set( CMAKE_C_PLATFORM_ID Linux )
+set( CMAKE_C_SIZEOF_DATA_PTR 4 )
+set( CMAKE_C_HAS_ISYSROOT 1 )
+set( CMAKE_C_COMPILER_ABI ELF )
 CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU )
-set( CMAKE_SIZEOF_VOID_P 4 )
-set( CMAKE_C_SIZEOF_DATA_PTR 4 )
+set( CMAKE_CXX_PLATFORM_ID Linux )
 set( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
+set( CMAKE_CXX_HAS_ISYSROOT 1 )
+set( CMAKE_CXX_COMPILER_ABI ELF )
+#force ASM compiler (required for CMake < 2.8.5)
+set( CMAKE_ASM_COMPILER_ID_RUN TRUE )
+set( CMAKE_ASM_COMPILER_ID GNU )
+set( CMAKE_ASM_COMPILER_WORKS TRUE )
+set( CMAKE_ASM_COMPILER_FORCED TRUE )
+set( CMAKE_COMPILER_IS_GNUASM 1)

 # NDK flags
 if( ARMEABI OR ARMEABI_V7A )
  # NDK also defines -ffunction-sections -funwind-tables but they result in worse OpenCV performance
  set( CMAKE_CXX_FLAGS "-fPIC -Wno-psabi" )
  set( CMAKE_C_FLAGS "-fPIC -Wno-psabi" )
- if( ANDROID_USE_STLPORT )
-  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions" )
-  set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions" )
- else()
-  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fexceptions" )
-  set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" )
- endif()
  remove_definitions( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ )
  add_definitions( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ )
  # extra arm-specific flags
  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" )
 elseif( X86 )
- set( CMAKE_CXX_FLAGS "-ffunction-sections -funwind-tables" )
- set( CMAKE_C_FLAGS "-ffunction-sections -funwind-tables" )
- if( ANDROID_USE_STLPORT )
-  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions" )
-  set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions" )
- else()
-  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fexceptions" )
-  set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" )
- endif()
+ set( CMAKE_CXX_FLAGS "-funwind-tables" )
+ set( CMAKE_C_FLAGS "-funwind-tables" )
+elseif( MIPS )
+ set( CMAKE_CXX_FLAGS "-fpic -Wno-psabi -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" )
+ set( CMAKE_CXX_FLAGS "-fpic -Wno-psabi -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" )
 else()
  set( CMAKE_CXX_FLAGS "" )
  set( CMAKE_C_FLAGS "" )
+endif()
+
+if( ANDROID_USE_STLPORT )
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions" )
+ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions" )
+else()
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fexceptions" )
+ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" )
 endif()

 #release and debug flags
@@ -754,6 +815,11 @@
  set( CMAKE_C_FLAGS_RELEASE   "-O3 -fstrict-aliasing" )
  set( CMAKE_CXX_FLAGS_DEBUG "-O0 -finline-limit=300" )
  set( CMAKE_C_FLAGS_DEBUG   "-O0 -finline-limit=300" )
+elseif( MIPS )
+ set( CMAKE_CXX_FLAGS_RELEASE "-O3 -funswitch-loops -finline-limit=300" )
+ set( CMAKE_C_FLAGS_RELEASE   "-O3 -funswitch-loops -finline-limit=300" )
+ set( CMAKE_CXX_FLAGS_DEBUG "-O0 -g" )
+ set( CMAKE_C_FLAGS_DEBUG   "-O0 -g" )
 endif()
 set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -DNDEBUG" )
 set( CMAKE_C_FLAGS_RELEASE   "${CMAKE_C_FLAGS_RELEASE}   -fomit-frame-pointer -DNDEBUG" )
@@ -780,14 +846,14 @@

 #linker flags
 list( APPEND ANDROID_SYSTEM_LIB_DIRS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}" "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )
-set( LINKER_FLAGS "" )
+set( ANDROID_LINKER_FLAGS "" )
 #STL
 if( ANDROID_USE_STLPORT )
  if( EXISTS "${__stlLibPath}/libstlport_static.a" )
   __COPY_IF_DIFFERENT( "${__stlLibPath}/libstlport_static.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstlport_static.a" )
  endif()
  if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstlport_static.a" )
-  set( LINKER_FLAGS "${LINKER_FLAGS} -Wl,--start-group -lstlport_static" )
+  set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--start-group -lstlport_static" )
  endif()
 else( ANDROID_USE_STLPORT )
  if( EXISTS "${__stlLibPath}/libgnustl_static.a" )
@@ -802,7 +868,7 @@
   __COPY_IF_DIFFERENT( "${__stlLibPath}/libstdc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
  endif()
  if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
-  set( LINKER_FLAGS "${LINKER_FLAGS} -lstdc++" )
+  set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -lstdc++" )
  endif()

  #gcc exception & rtti support
@@ -818,7 +884,7 @@
   __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
  endif()
  if( EXISTS "${CMAKE_BINARY_DIR}/systemlibs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
-  set( LINKER_FLAGS "${LINKER_FLAGS} -lsupc++" )
+  set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -lsupc++" )
  endif()
 endif( ANDROID_USE_STLPORT )

@@ -831,7 +897,7 @@
 set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Show all undefined symbols as linker errors" FORCE )
 mark_as_advanced( ANDROID_NO_UNDEFINED )
 if( ANDROID_NO_UNDEFINED )
- set( LINKER_FLAGS "-Wl,--no-undefined ${LINKER_FLAGS}" )
+ set( ANDROID_LINKER_FLAGS "-Wl,--no-undefined ${ANDROID_LINKER_FLAGS}" )
 endif()

 if (ANDROID_NDK MATCHES "-r[56].?$")
@@ -840,36 +906,55 @@
 else()
  __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES OFF )
 endif()
+
 set( ANDROID_SO_UNDEFINED ${ANDROID_SO_UNDEFINED} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE )
 mark_as_advanced( ANDROID_SO_UNDEFINED )
 if( ANDROID_SO_UNDEFINED )
- set( LINKER_FLAGS "${LINKER_FLAGS} -Wl,-allow-shlib-undefined" )
+ set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-allow-shlib-undefined" )
+endif()
+
+__INIT_VARIABLE( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON )
+set( ANDROID_FUNCTION_LEVEL_LINKING ON CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE )
+mark_as_advanced( ANDROID_FUNCTION_LEVEL_LINKING )
+if( ANDROID_FUNCTION_LEVEL_LINKING )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" )
+ set( ANDROID_LINKER_FLAGS "-Wl,--gc-sections ${ANDROID_LINKER_FLAGS}" )
 endif()

 if( ARMEABI_V7A )
  # this is *required* to use the following linker flags that routes around
  # a CPU bug in some Cortex-A8 implementations:
- set( LINKER_FLAGS "-Wl,--fix-cortex-a8 ${LINKER_FLAGS}" )
+ set( ANDROID_LINKER_FLAGS "-Wl,--fix-cortex-a8 ${ANDROID_LINKER_FLAGS}" )
 endif()

 #cache flags
 set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags" )
-set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c flags" )
+set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags" )
 set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "c++ Release flags" )
-set( CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "c Release flags" )
+set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "c Release flags" )
 set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "c++ Debug flags" )
-set( CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "c Debug flags" )
-set( CMAKE_SHARED_LINKER_FLAGS "${LINKER_FLAGS}" CACHE STRING "linker flags" )
-set( CMAKE_MODULE_LINKER_FLAGS "${LINKER_FLAGS}" CACHE STRING "linker flags" )
-set( CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections -Wl,-z,nocopyreloc ${LINKER_FLAGS}" CACHE STRING "linker flags" )
+set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "c Debug flags" )
+set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "linker flags" )
+set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "linker flags" )
+set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "linker flags" )

 include_directories( SYSTEM ${ANDROID_SYSTEM_INCLUDE_DIRS} )
 link_directories( ${ANDROID_SYSTEM_LIB_DIRS} )

 #finish flags
-set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" CACHE INTERNAL "Extra Android falgs")
-set( CMAKE_CXX_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
-set( CMAKE_C_FLAGS   "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
+set( ANDROID_CXX_FLAGS    "${ANDROID_CXX_FLAGS}"    CACHE INTERNAL "Extra Android compiler flags")
+set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS}" CACHE INTERNAL "Extra Android linker flags")
+set( CMAKE_CXX_FLAGS           "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
+set( CMAKE_C_FLAGS             "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
+if( MIPS AND BUILD_WITH_ANDROID_NDK )
+ set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
+ set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
+ set( CMAKE_EXE_LINKER_FLAGS    "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.x ${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
+else()
+ set( CMAKE_SHARED_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
+ set( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
+ set( CMAKE_EXE_LINKER_FLAGS    "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
+endif()

 #set these global flags for cmake client scripts to change behavior
 set( ANDROID True )
@@ -944,7 +1029,7 @@
 # export toolchain settings for the try_compile() command
 if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
  set( __toolchain_config "")
- foreach( __var ANDROID_ABI ANDROID_FORCE_ARM_BUILD ANDROID_NATIVE_API_LEVEL ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_SET_OBSOLETE_VARIABLES LIBRARY_OUTPUT_PATH_ROOT ANDROID_USE_STLPORT ANDROID_FORBID_SYGWIN ANDROID_NDK ANDROID_STANDALONE_TOOLCHAIN )
+ foreach( __var ANDROID_ABI ANDROID_FORCE_ARM_BUILD ANDROID_NATIVE_API_LEVEL ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_SET_OBSOLETE_VARIABLES LIBRARY_OUTPUT_PATH_ROOT ANDROID_USE_STLPORT ANDROID_FORBID_SYGWIN ANDROID_NDK ANDROID_STANDALONE_TOOLCHAIN ANDROID_FUNCTION_LEVEL_LINKING )
   if( DEFINED ${__var} )
    set( __toolchain_config "${__toolchain_config}set( ${__var} \"${${__var}}\" )\n" )
   endif()
@@ -963,16 +1048,19 @@
  set( ARMEABI_NDK_NAME "${ANDROID_NDK_ABI_NAME}" )
 endif()

+
 # Variables controlling behavior or set by cmake toolchain:
-#   ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86"
-#   ANDROID_FORCE_ARM_BUILD : ON/OFF
+#   ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips"
 #   ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14 (depends on NDK version)
+#   ANDROID_SET_OBSOLETE_VARIABLES : ON/OFF
+#   ANDROID_USE_STLPORT : OFF/ON - EXPERIMENTAL!!!
+#   ANDROID_FORBID_SYGWIN : ON/OFF
 #   ANDROID_NO_UNDEFINED : ON/OFF
 #   ANDROID_SO_UNDEFINED : OFF/ON  (default depends on NDK version)
-#   ANDROID_SET_OBSOLETE_VARIABLES : ON/OFF
+#   ANDROID_FUNCTION_LEVEL_LINKING : ON/OFF
+# Variables that takes effect only at first run:
+#   ANDROID_FORCE_ARM_BUILD : ON/OFF
 #   LIBRARY_OUTPUT_PATH_ROOT : <any valid path>
-#   ANDROID_USE_STLPORT : OFF/ON - EXPERIMENTAL!!!
-#   ANDROID_FORBID_SYGWIN : ON/OFF
 # Can be set only at the first run:
 #   ANDROID_NDK
 #   ANDROID_STANDALONE_TOOLCHAIN
@@ -996,8 +1084,9 @@
 #   BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used
 #   ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform
 #   ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a" or "x86" depending on ANDROID_ABI
-#   ANDROID_ARCH_NAME : "arm" or "x86" depending on ANDROID_ABI
+#   ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI
 #   TOOL_OS_SUFFIX : "" or ".exe" depending on host platform
+#   ANDROID_SYSROOT : path to the compiler sysroot
 #   ANDROID_SYSTEM_INCLUDE_DIRS
 #   ANDROID_SYSTEM_LIB_DIRS
 # Obsolete:
@@ -1007,7 +1096,6 @@
 #   ANDROID_COMPILER_VERSION : GCC version used
 #   ANDROID_CXX_FLAGS : C/C++ compiler flags required by Android platform
 #   ANDROID_SUPPORTED_ABIS : list of currently allowed values for ANDROID_ABI
-#   ANDROID_SYSROOT : path to the compiler sysroot
 #   ANDROID_TOOLCHAIN_NAME : "standalone", "arm-linux-androideabi-4.4.3" or "x86-4.4.3" or something similar.
 #   ANDROID_TOOLCHAIN_MACHINE_NAME : "arm-linux-androideabi", "arm-eabi" or "i686-android-linux"
 #   ANDROID_TOOLCHAIN_ROOT : path to the top level of toolchain (standalone or placed inside NDK)


Fix name-clash bug using STREQUAL

Fix name-clash bug using STREQUAL

--- components/ospcommon/cmake/macros.cmake
+++ components/ospcommon/cmake/macros.cmake
@@ -206,39 +206,39 @@
 # Helper function to return arguments of OSPRAY_CREATE_ in separate
 # variables, prefixed with PREFIX
 FUNCTION(OSPRAY_SPLIT_CREATE_ARGS PREFIX)
-  SET(SOURCES "")
+  SET(MY_SOURCES "")
   SET(LIBS "")
-  SET(EXCLUDE_FROM_ALL FALSE)
-  SET(COMPONENT ${OSPRAY_DEFAULT_COMPONENT})
-  SET(CURRENT_LIST SOURCES)
+  SET(MY_EXCLUDE_FROM_ALL FALSE)
+  SET(MY_COMPONENT ${OSPRAY_DEFAULT_COMPONENT})
+  SET(CURRENT_LIST MY_SOURCES)

   FOREACH(arg ${ARGN})
-    IF (${arg} STREQUAL "LINK")
+    IF ("${arg}" STREQUAL "LINK")
       SET(CURRENT_LIST LIBS)
-    ELSEIF (${arg} STREQUAL "EXCLUDE_FROM_ALL")
-      SET(EXCLUDE_FROM_ALL TRUE)
-    ELSEIF (${arg} STREQUAL "COMPONENT")
-      SET(CURRENT_LIST COMPONENT)
+    ELSEIF ("${arg}" STREQUAL "EXCLUDE_FROM_ALL")
+      SET(MY_EXCLUDE_FROM_ALL TRUE)
+    ELSEIF ("${arg}" STREQUAL "COMPONENT")
+      SET(CURRENT_LIST MY_COMPONENT)
     ELSE()
       LIST(APPEND ${CURRENT_LIST} ${arg})
     ENDIF ()
   ENDFOREACH()

   # COMPONENT only required when installed
-  IF (NOT ${EXCLUDE_FROM_ALL})
-    LIST(LENGTH COMPONENT COMPONENTS)
+  IF (NOT ${MY_EXCLUDE_FROM_ALL})
+    LIST(LENGTH MY_COMPONENT COMPONENTS)
     IF (COMPONENTS EQUAL 0)
       MESSAGE(WARNING "No COMPONENT for installation specified!")
-      SET(COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
+      SET(MY_COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
     ELSE()
-      LIST(GET COMPONENT -1 COMPONENT)
-    ENDIF()
-  ENDIF()
-
-  SET(${PREFIX}_SOURCES ${SOURCES} PARENT_SCOPE)
+      LIST(GET MY_COMPONENT -1 MY_COMPONENT)
+    ENDIF()
+  ENDIF()
+
+  SET(${PREFIX}_SOURCES ${MY_SOURCES} PARENT_SCOPE)
   SET(${PREFIX}_LIBS ${LIBS} PARENT_SCOPE)
-  SET(${PREFIX}_EXCLUDE_FROM_ALL ${EXCLUDE_FROM_ALL} PARENT_SCOPE)
-  SET(${PREFIX}_COMPONENT ${COMPONENT} PARENT_SCOPE)
+  SET(${PREFIX}_EXCLUDE_FROM_ALL ${MY_EXCLUDE_FROM_ALL} PARENT_SCOPE)
+  SET(${PREFIX}_COMPONENT ${MY_COMPONENT} PARENT_SCOPE)
 ENDFUNCTION()

 ## Conveniance macro for creating OSPRay libraries ##
@@ -328,19 +328,19 @@

 MACRO(OSPRAY_INSTALL_SDK_HEADERS)
   SET(HEADERS "")
-  SET(DESTINATION "")
+  SET(MY_DESTINATION "")

   SET(CURRENT_LIST HEADERS)
   FOREACH(arg ${ARGN})
-    IF (${arg} STREQUAL "DESTINATION")
-      SET(CURRENT_LIST DESTINATION)
+    IF ("${arg}" STREQUAL "DESTINATION")
+      SET(CURRENT_LIST MY_DESTINATION)
     ELSE()
       LIST(APPEND ${CURRENT_LIST} ${arg})
     ENDIF ()
   ENDFOREACH()

   INSTALL(FILES ${HEADERS}
-    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ospray/SDK/${DESTINATION}
+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ospray/SDK/${MY_DESTINATION}
     COMPONENT devel
   )
 ENDMACRO()


Add juajit support

Add juajit support

--- tests/FindLua.cmake
+++ tests/FindLua.cmake
@@ -87,6 +87,9 @@
              lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
              lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
              lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
+             luajit${CMAKE_MATCH_1}${CMAKE_MATCH_2}
+             luajit${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
+             luajit-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
         )
     endforeach ()

@@ -99,7 +102,7 @@
 find_path(LUA_INCLUDE_DIR lua.h
   HINTS
     ENV LUA_DIR
-  PATH_SUFFIXES ${_lua_include_subdirs} include/lua include
+  PATH_SUFFIXES ${_lua_include_subdirs} include/lua include/luajit-2.0 include/luajit-2.1 include/luajit include
   PATHS
   ~/Library/Frameworks
   /Library/Frameworks
@@ -107,11 +110,12 @@
   /opt/local # DarwinPorts
   /opt/csw # Blastwave
   /opt
+  NO_DEFAULT_PATH
 )
 unset(_lua_include_subdirs)

 find_library(LUA_LIBRARY
-  NAMES ${_lua_library_names} lua
+  NAMES ${_lua_library_names} lua luajit
   HINTS
     ENV LUA_DIR
   PATH_SUFFIXES lib
@@ -122,6 +126,7 @@
   /opt/local
   /opt/csw
   /opt
+  NO_DEFAULT_PATH
 )
 unset(_lua_library_names)


Fix indentation in cmake

Fix indentation in cmake

--- clrdefinitions.cmake
+++ clrdefinitions.cmake
@@ -133,7 +133,7 @@
 add_definitions(-DFEATURE_HOST_ASSEMBLY_RESOLVER)
 add_definitions(-DFEATURE_ICASTABLE)
 if (WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386))
-add_definitions(-DFEATURE_INTEROP_DEBUGGING)
+    add_definitions(-DFEATURE_INTEROP_DEBUGGING)
 endif (WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386))
 if (CLR_CMAKE_PLATFORM_UNIX OR CLR_CMAKE_TARGET_ARCH_ARM64)
   add_definitions(-DFEATURE_IMPLICIT_TLS)
@@ -142,7 +142,7 @@
 add_definitions(-DFEATURE_ISYM_READER)
 add_definitions(-DFEATURE_LOADER_OPTIMIZATION)
 if (NOT CLR_CMAKE_PLATFORM_UNIX)
-add_definitions(-DFEATURE_MANAGED_ETW)
+    add_definitions(-DFEATURE_MANAGED_ETW)
 endif(NOT CLR_CMAKE_PLATFORM_UNIX)
 add_definitions(-DFEATURE_MANAGED_ETW_CHANNELS)
 add_definitions(-DFEATURE_MAIN_CLR_MODULE_USES_CORE_NAME)


add stub joystick code

add stub joystick code

--- cmake/FileList.cmake
+++ cmake/FileList.cmake
@@ -106,6 +106,8 @@
 src/util/ftalleg.cpp
 src/util/funcs.cpp
 src/util/ebox.cpp
+src/util/joystick.cpp
+src/util/linux_joystick.cpp
 src/util/load_exception.cpp)

 set(LOADPNG_SRC


Compile CUDA files as C++.

Compile CUDA files as C++.

--- cmake/FindCUDA.cmake
+++ cmake/FindCUDA.cmake
@@ -57,7 +57,7 @@

 #SET(CUDA_OPTIONS "-ncfe")
-SET(CUDA_OPTIONS "")
+SET(CUDA_OPTIONS "--host-compilation=C++")

 IF (CUDA_EMULATION)
 	SET (CUDA_OPTIONS "${CUDA_OPTIONS} -deviceemu")
@@ -90,18 +90,18 @@
 	GET_FILENAME_COMPONENT(filepath ${file} PATH)

 	#  parse file for dependencies
-	FILE(READ "${file}" CONTENTS)
-	#STRING(REGEX MATCHALL "#[ \t]*include[ \t]+[<\"][^>\"]*" DEPS "${CONTENTS}")
-	STRING(REGEX MATCHALL "#[ \t]*include[ \t]+\"[^\"]*" DEPS "${CONTENTS}")
+	FILE(READ "${file}" CONTENTS)
+	#STRING(REGEX MATCHALL "#[ \t]*include[ \t]+[<\"][^>\"]*" DEPS "${CONTENTS}")
+	STRING(REGEX MATCHALL "#[ \t]*include[ \t]+\"[^\"]*" DEPS "${CONTENTS}")

 	SET(${dependencies})

 	FOREACH(DEP ${DEPS})
 		STRING(REGEX REPLACE "#[ \t]*include[ \t]+\"" "" DEP "${DEP}")
-
+
 		FIND_PATH(PATH_OF_${DEP} ${DEP}
 			${filepath})
-
+
 		IF(NOT ${PATH_OF_${DEP}} STREQUAL PATH_OF_${DEP}-NOTFOUND)
 			#MESSAGE("${file} : ${PATH_OF_${DEP}}/${DEP}")
 			SET(${dependencies} ${${dependencies}} ${PATH_OF_${DEP}}/${DEP})
@@ -119,22 +119,22 @@

 	FOREACH (CUFILE ${ARGN})
 		GET_FILENAME_COMPONENT (CUFILE ${CUFILE} ABSOLUTE)
-		GET_FILENAME_COMPONENT (CFILE ${CUFILE} NAME_WE)
-		SET (CFILE ${CMAKE_CURRENT_BINARY_DIR}/${CFILE}.gen.c)
+		GET_FILENAME_COMPONENT (CPPFILE ${CUFILE} NAME_WE)
+		SET (CPPFILE ${CMAKE_CURRENT_BINARY_DIR}/${CPPFILE}.gen.cpp)

 		GET_CUFILE_DEPENDENCIES(CUDEPS ${CUFILE})
 		#MESSAGE("${CUDEPS}")

 		ADD_CUSTOM_COMMAND (
-			OUTPUT ${CFILE}
+			OUTPUT ${CPPFILE}
 			COMMAND ${CUDA_COMPILER}
-			ARGS -cuda ${cuda_includes} ${CUDA_OPTIONS} -o ${CFILE} ${CUFILE}
+			ARGS -cuda ${cuda_includes} ${CUDA_OPTIONS} -o ${CPPFILE} ${CUFILE}
 			MAIN_DEPENDENCY ${CUFILE}
 			DEPENDS ${CUDEPS})

-		#MACRO_ADD_FILE_DEPENDENCIES(${CUFILE} ${CFILE})
+		#MACRO_ADD_FILE_DEPENDENCIES(${CUFILE} ${CPPFILE})

-		SET (${outfiles} ${${outfiles}} ${CFILE})
+		SET (${outfiles} ${${outfiles}} ${CPPFILE})
 	ENDFOREACH (CUFILE)

 	SET_SOURCE_FILES_PROPERTIES(${outfiles} PROPERTIES GENERATED 1)


Tidy and simplify cmake/FindPOPT.cmake.

Tidy and simplify cmake/FindPOPT.cmake.

The arguments given to `find_path()` and `find_library()` either matched the
default values, were redundant, or were better fixed by setting
`CMAKE_PREFIX_PATH` to point at the popt install location in the cmake cmdline.

The POPT_ROOT_DIR location hint has also been removed, but note that cmake
3.12 adds support for using `<PackageName>_ROOT` as the first location hint by
default.

--- cmake/FindPOPT.cmake
+++ cmake/FindPOPT.cmake
@@ -27,7 +27,6 @@
 # - Check for the presence of POPT
 #
 # The following vars can be set to change behaviour;
-#  POPT_ROOT_DIR - path hint for finding popt.
 #  POPT_INCLUDE_DIR - cached override for POPT_INCLUDE_DIRS.
 #  POPT_LIBRARY_RELEASE - cached override for POPT_LIBRARIES.
 #
@@ -49,12 +48,8 @@

 # Fallback to searching for path and library if PkgConfig didn't work.
 if (NOT POPT_FOUND)
-  find_path (POPT_INCLUDE_DIR popt.h
-    HINTS ${POPT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX} $ENV{programfiles}\\GnuWin32 $ENV{programfiles32}\\GnuWin32
-    PATH_SUFFIXES include)
-  find_library (POPT_LIBRARY_RELEASE popt
-    HINTS ${POPT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX} $ENV{programfiles}\\GnuWin32 $ENV{programfiles32}\\GnuWin32
-    PATH_SUFFIXES lib)
+  find_path (POPT_INCLUDE_DIR popt.h)
+  find_library (POPT_LIBRARY_RELEASE popt)
 endif (NOT POPT_FOUND)

 # Check library and paths and set POPT_FOUND appropriately.


Add llvm-config detection when dynlinking clang

--- cmake/Findllvm.cmake
+++ cmake/Findllvm.cmake
@@ -32,6 +32,37 @@
       /usr/local/llvm11/lib
       /usr/local/llvm110/lib
   )
+
+  find_program(LLVM_CONFIG_EXE
+      NAMES llvm-config-11 llvm-config-11.0 llvm-config110 llvm-config11 llvm-config
+      PATHS
+          "/mingw64/bin"
+          "/c/msys64/mingw64/bin"
+          "c:/msys64/mingw64/bin"
+          "C:/Libraries/llvm-11.0.0/bin")
+
+  if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
+    message(FATAL_ERROR "unable to find llvm-config")
+  endif()
+
+  if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
+    message(FATAL_ERROR "unable to find llvm-config")
+  endif()
+
+  execute_process(
+    COMMAND ${LLVM_CONFIG_EXE} --version
+    OUTPUT_VARIABLE LLVM_CONFIG_VERSION
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  if("${LLVM_CONFIG_VERSION}" VERSION_LESS 11)
+    message(FATAL_ERROR "expected LLVM 11.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
+  endif()
+  if("${LLVM_CONFIG_VERSION}" VERSION_EQUAL 12)
+    message(FATAL_ERROR "expected LLVM 11.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
+  endif()
+  if("${LLVM_CONFIG_VERSION}" VERSION_GREATER 11)
+    message(FATAL_ERROR "expected LLVM 11.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
+  endif()
 elseif(("${ZIG_TARGET_TRIPLE}" STREQUAL "native") OR ZIG_PREFER_LLVM_CONFIG)
   find_program(LLVM_CONFIG_EXE
       NAMES llvm-config-11 llvm-config-11.0 llvm-config110 llvm-config11 llvm-config


disable bogus clang warnings about template args because it ignores that the overloads are discarded via SFINAE

--- cmake/VcMacros.cmake
+++ cmake/VcMacros.cmake
@@ -278,6 +278,10 @@
       set(Vc_DEFINITIONS "${Vc_DEFINITIONS} -DNOMINMAX")
    elseif(Vc_COMPILER_IS_CLANG)
       # for now I don't know of any arguments I want to pass. -march and stuff is tried by OptimizeForArchitecture...
+
+      # disable these warnings because clang shows them for function overloads that were discarded via SFINAE
+      vc_add_compiler_flag(Vc_DEFINITIONS "-Wno-local-type-template-args")
+      vc_add_compiler_flag(Vc_DEFINITIONS "-Wno-unnamed-type-template-args")
    endif()

    OptimizeForArchitecture()


protobuf: build for musl

protobuf: build for musl

--- cmake/protobuf.cmake
+++ cmake/protobuf.cmake
@@ -11,7 +11,7 @@
 include_directories(${LIB_PROTOBUF})
 include_directories(${INCLUDEOS_ROOT}/api/posix)
 include_directories(${LIBCXX_INCLUDE_DIR})
-include_directories(${NEWLIB_INCLUDE_DIR})
+include_directories(${MUSL_INCLUDE_DIR})

 # Maybe possible to use wildcard with files(...) to gather all cc objects.
 set(PROTOBUF_SOURCES


Build `jxl_extras_dec` only as a shared library if necessary

This should fix libvips' CIFuzz and OSS-Fuzz integration.

--- lib/jxl_extras.cmake
+++ lib/jxl_extras.cmake
@@ -169,10 +169,18 @@

 target_compile_definitions(jxl_extras_dec-obj PRIVATE ${JXL_EXTRAS_DEC_PUBLIC_DEFINITIONS})

+### Static library.
 add_library(jxl_extras_dec-static STATIC $<TARGET_OBJECTS:jxl_extras_dec-obj>)
 target_compile_definitions(jxl_extras_dec-static PUBLIC ${JXL_EXTRAS_DEC_PUBLIC_DEFINITIONS})
 target_link_libraries(jxl_extras_dec-static PRIVATE ${JXL_EXTRAS_DEC_INTERNAL_LIBRARIES})

+### Shared library.
+if (((NOT DEFINED "${TARGET_SUPPORTS_SHARED_LIBS}") OR
+     TARGET_SUPPORTS_SHARED_LIBS) AND NOT JPEGXL_STATIC AND BUILD_SHARED_LIBS)
 add_library(jxl_extras_dec SHARED $<TARGET_OBJECTS:jxl_extras_dec-obj>)
 target_compile_definitions(jxl_extras_dec PUBLIC ${JXL_EXTRAS_DEC_PUBLIC_DEFINITIONS})
 target_link_libraries(jxl_extras_dec PRIVATE ${JXL_EXTRAS_DEC_INTERNAL_LIBRARIES} jxl)
+else()
+add_library(jxl_extras_dec ALIAS jxl_extras_dec-static)
+endif()  # TARGET_SUPPORTS_SHARED_LIBS AND NOT JPEGXL_STATIC AND
+         # BUILD_SHARED_LIBS


updates to test.cmake

updates to test.cmake

--- scripts/test.cmake
+++ scripts/test.cmake
@@ -24,7 +24,7 @@
   IF(NOT EXISTS "${TEST_MODELS_DIRECTORY}")
     MESSAGE("cloning test models ...")
     EXECUTE_PROCESS(
-      COMMAND ${CTEST_GIT_COMMAND} "clone" "git@git.sdvis.org:embree-models.git" embree-models
+      COMMAND ${CTEST_GIT_COMMAND} "clone" "git@git.sdvis.org:embree-models" embree-models
       WORKING_DIRECTORY $ENV{HOME}
     )
   ELSE()


Append to PYTHONPATH rather than override

--- tests/PythonTests.cmake
+++ tests/PythonTests.cmake
@@ -15,6 +15,12 @@
   "${py_coverage_rc}"
   @ONLY
 )
+
+if(WIN32)
+  set(_separator "\\;")
+else()
+  set(_separator ":")
+endif()

 function(python_tests_init)
   if(PYTHON_COVERAGE)
@@ -94,7 +100,7 @@
   endif()

   set_property(TEST ${name} PROPERTY ENVIRONMENT
-    "PYTHONPATH=${pythonpath}"
+    "PYTHONPATH=$ENV{PYTHONPATH}${_separator}${pythonpath}"
     "GIRDER_TEST_DB=mongodb://localhost:27017/girder_test_${name}"
     "GIRDER_TEST_ASSETSTORE=${name}"
   )


fixed error in wrap executable

fixed error in wrap executable

--- cmake/function/wrap_executable.cmake
+++ cmake/function/wrap_executable.cmake
@@ -45,7 +45,7 @@
           return()
         endif()

-        return_ref(sdout)
+        return_ref(stdout)
       endfunction()
       ")
     return()


Disable modules on aarch64 due to ODR violation

error: std::map<std::basic_string<char>, double, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, double> > >' has different definitions in different modules; first difference is defined here found end of class\n/usr/lib/gcc/aarch64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/stl_map.h:941:9: note: but in 'std.bits/stl_map.h' found friend declaration\n        operator==(const map<_K1, _T1, _C1, _A1>&,\n        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nroot.exe: ../../../../../../../../root/interpreter/cling/lib/Interpreter/Transaction.cpp:138: void cling::Transaction::append(cling::Transaction::DelayCallInfo): Assertion getState() == kCollecting && Cannot append declarations in current state.