add compiler flag detection for -Wmaybe-uninitialized

--- cmake/ElektraCompiling.cmake
+++ cmake/ElektraCompiling.cmake
@@ -6,6 +6,8 @@
 # make sure to update src/plugins/constants/constants.c
 #
 # if new flags are added
+
+include(CheckCCompilerFlag)

 #
 # The mode (standard) to be used by the compiler
@@ -85,10 +87,12 @@
 set (COMMON_FLAGS "${COMMON_FLAGS} -Wshadow")
 set (COMMON_FLAGS "${COMMON_FLAGS} -Wcomments -Wtrigraphs -Wundef")
 set (COMMON_FLAGS "${COMMON_FLAGS} -Wuninitialized -Winit-self")
-# Apple does not support -Wmaybe-uninitialized
-if (!APPLE)
+
+# Not every compiler understands -Wmaybe-uninitialized
+check_c_compiler_flag(-Wmaybe-uninitialized HAS_CFLAG_MAYBE_UNINITIALIZED)
+if (HAS_CFLAG_MAYBE_UNINITIALIZED)
 	set (COMMON_FLAGS "${COMMON_FLAGS} -Wmaybe-uninitialized")
-endif (!APPLE)
+endif (HAS_CFLAG_MAYBE_UNINITIALIZED)

 #set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--unresolved-symbols=ignore-in-shared-libs")


Revert "update findcuda"

Revert "update findcuda"

This reverts commit 0d36887a0043ebad41e82b6a6865958f0cdc4580.

--- cmake/Modules/FindCUDA.cmake
+++ cmake/Modules/FindCUDA.cmake
@@ -2,52 +2,37 @@
 # FindCUDA
 # --------
 #
-# .. note::
-#
-#   The FindCUDA module has been superseded by first-class support
-#   for the CUDA language in CMake.  It is no longer necessary to
-#   use this module or call ``find_package(CUDA)``.  This module
-#   now exists only for compatibility with projects that have not
-#   been ported.
-#
-#   Instead, list ``CUDA`` among the languages named in the top-level
-#   call to the :command:`project` command, or call the
-#   :command:`enable_language` command with ``CUDA``.
-#   Then one can add CUDA (``.cu``) sources to programs directly
-#   in calls to :command:`add_library` and :command:`add_executable`.
-#
 # Tools for building CUDA C files: libraries and build dependencies.
 #
-# This script locates the NVIDIA CUDA C tools.  It should work on Linux,
-# Windows, and macOS and should be reasonably up to date with CUDA C
+# This script locates the NVIDIA CUDA C tools.  It should work on linux,
+# windows, and mac and should be reasonably up to date with CUDA C
 # releases.
 #
-# This script makes use of the standard :command:`find_package` arguments of
-# ``<VERSION>``, ``REQUIRED`` and ``QUIET``.  ``CUDA_FOUND`` will report if an
+# This script makes use of the standard find_package arguments of
+# <VERSION>, REQUIRED and QUIET.  CUDA_FOUND will report if an
 # acceptable version of CUDA was found.
 #
-# The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if
+# The script will prompt the user to specify CUDA_TOOLKIT_ROOT_DIR if
 # the prefix cannot be determined by the location of nvcc in the system
-# path and ``REQUIRED`` is specified to :command:`find_package`.  To use
-# a different installed version of the toolkit set the environment variable
-# ``CUDA_BIN_PATH`` before running cmake (e.g.
-# ``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default
-# ``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring.  If
-# you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that
+# path and REQUIRED is specified to find_package().  To use a different
+# installed version of the toolkit set the environment variable
+# CUDA_BIN_PATH before running cmake (e.g.
+# CUDA_BIN_PATH=/usr/local/cuda1.0 instead of the default
+# /usr/local/cuda) or set CUDA_TOOLKIT_ROOT_DIR after configuring.  If
+# you change the value of CUDA_TOOLKIT_ROOT_DIR, various components that
 # depend on the path will be relocated.
 #
-# It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain
-# platforms, or to use a CUDA runtime not installed in the default
-# location.  In newer versions of the toolkit the CUDA library is
-# included with the graphics driver -- be sure that the driver version
-# matches what is needed by the CUDA runtime version.
+# It might be necessary to set CUDA_TOOLKIT_ROOT_DIR manually on certain
+# platforms, or to use a cuda runtime not installed in the default
+# location.  In newer versions of the toolkit the cuda library is
+# included with the graphics driver- be sure that the driver version
+# matches what is needed by the cuda runtime version.
 #
 # The following variables affect the behavior of the macros in the
-# script (in alphabetical order).  Note that any of these flags can be
+# script (in alphebetical order).  Note that any of these flags can be
 # changed multiple times in the same directory before calling
-# ``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``,
-# ``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN``
-# or ``CUDA_WRAP_SRCS``::
+# CUDA_ADD_EXECUTABLE, CUDA_ADD_LIBRARY, CUDA_COMPILE, CUDA_COMPILE_PTX,
+# CUDA_COMPILE_FATBIN, CUDA_COMPILE_CUBIN or CUDA_WRAP_SRCS::
 #
 #   CUDA_64_BIT_DEVICE_CODE (Default matches host bit size)
 #   -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code.
@@ -82,13 +67,6 @@
 #   -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files
 #      when CUDA_BUILD_EMULATION is TRUE.
 #
-#   CUDA_LINK_LIBRARIES_KEYWORD (Default "")
-#    -- The <PRIVATE|PUBLIC|INTERFACE> keyword to use for internal
-#       target_link_libraries calls. The default is to use no keyword which
-#       uses the old "plain" form of target_link_libraries. Note that is matters
-#       because whatever is used inside the FindCUDA module must also be used
-#       outside - the two forms of target_link_libraries cannot be mixed.
-#
 #   CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR)
 #   -- Set to the path you wish to have the generated files placed.  If it is
 #      blank output files will be placed in CMAKE_CURRENT_BINARY_DIR.
@@ -98,15 +76,12 @@
 #   CUDA_HOST_COMPILATION_CPP (Default ON)
 #   -- Set to OFF for C compilation of host code.
 #
-#   CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER)
+#   CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER, $(VCInstallDir)/bin for VS)
 #   -- Set the host compiler to be used by nvcc.  Ignored if -ccbin or
 #      --compiler-bindir is already present in the CUDA_NVCC_FLAGS or
-#      CUDA_NVCC_FLAGS_<CONFIG> variables.  For Visual Studio targets,
-#      the host compiler is constructed with one or more visual studio macros
-#      such as $(VCInstallDir), that expands out to the path when
+#      CUDA_NVCC_FLAGS_<CONFIG> variables.  For Visual Studio targets
+#      $(VCInstallDir)/bin is a special value that expands out to the path when
 #      the command is run from within VS.
-#      If the CUDAHOSTCXX environment variable is set it will
-#      be used as the default.
 #
 #   CUDA_NVCC_FLAGS
 #   CUDA_NVCC_FLAGS_<CONFIG>
@@ -149,7 +124,7 @@
 #      VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will
 #      always print the output.
 #
-# The script creates the following macros (in alphabetical order)::
+# The script creates the following macros (in alphebetical order)::
 #
 #   CUDA_ADD_CUFFT_TO_TARGET( cuda_target )
 #   -- Adds the cufft library to the target (can be any target).  Handles whether
@@ -177,7 +152,7 @@
 #   -- Same as CUDA_ADD_EXECUTABLE except that a library is created.
 #
 #   CUDA_BUILD_CLEAN_TARGET()
-#   -- Creates a convenience target that deletes all the dependency files
+#   -- Creates a convience target that deletes all the dependency files
 #      generated.  You should make clean after running this target to ensure the
 #      dependency files get regenerated.
 #
@@ -343,27 +318,7 @@
 #   CUDA_nppc_LIBRARY     -- NVIDIA Performance Primitives lib (core).
 #                            Only available for CUDA version 5.5+.
 #   CUDA_nppi_LIBRARY     -- NVIDIA Performance Primitives lib (image processing).
-#                            Only available for CUDA version 5.5 - 8.0.
-#   CUDA_nppial_LIBRARY   -- NVIDIA Performance Primitives lib (image processing).
-#                            Only available for CUDA version 9.0.
-#   CUDA_nppicc_LIBRARY   -- NVIDIA Performance Primitives lib (image processing).
-#                            Only available for CUDA version 9.0.
-#   CUDA_nppicom_LIBRARY  -- NVIDIA Performance Primitives lib (image processing).
-#                            Only available for CUDA version 9.0.
-#   CUDA_nppidei_LIBRARY  -- NVIDIA Performance Primitives lib (image processing).
-#                            Only available for CUDA version 9.0.
-#   CUDA_nppif_LIBRARY    -- NVIDIA Performance Primitives lib (image processing).
-#                            Only available for CUDA version 9.0.
-#   CUDA_nppig_LIBRARY    -- NVIDIA Performance Primitives lib (image processing).
-#                            Only available for CUDA version 9.0.
-#   CUDA_nppim_LIBRARY    -- NVIDIA Performance Primitives lib (image processing).
-#                            Only available for CUDA version 9.0.
-#   CUDA_nppist_LIBRARY   -- NVIDIA Performance Primitives lib (image processing).
-#                            Only available for CUDA version 9.0.
-#   CUDA_nppisu_LIBRARY   -- NVIDIA Performance Primitives lib (image processing).
-#                            Only available for CUDA version 9.0.
-#   CUDA_nppitc_LIBRARY   -- NVIDIA Performance Primitives lib (image processing).
-#                            Only available for CUDA version 9.0.
+#                            Only available for CUDA version 5.5+.
 #   CUDA_npps_LIBRARY     -- NVIDIA Performance Primitives lib (signal processing).
 #                            Only available for CUDA version 5.5+.
 #   CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library.
@@ -527,18 +482,10 @@
 option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON)

 # Extra user settable flags
-cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.")
-
-if(DEFINED ENV{CUDAHOSTCXX})
-  set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC")
-elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
-  set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)")
-  if(MSVC_VERSION LESS 1910)
-   set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin")
-  endif()
-
-  set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC")
-
+set(CUDA_NVCC_FLAGS "" CACHE STRING "Semi-colon delimit multiple arguments.")
+
+if(CMAKE_GENERATOR MATCHES "Visual Studio")
+  set(CUDA_HOST_COMPILER "$(VCInstallDir)bin" CACHE FILEPATH "Host side compiler used by NVCC")
 else()
   if(APPLE
       AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang"
@@ -561,11 +508,6 @@
       set(c_compiler_realpath "")
     endif()
     set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC")
-  elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache")
-    # NVCC does not think it will work if it is passed clcache.exe or sccache.exe
-    # as the host compiler, which means that builds with CC=cl.exe won't work.
-    # Best to just feed it whatever the actual cl.exe is as the host compiler.
-    set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC")
   else()
     set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}"
       CACHE FILEPATH "Host side compiler used by NVCC")
@@ -573,7 +515,7 @@
 endif()

 # Propagate the host flags to the host compiler via -Xcompiler
-option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON)
+option(CUDA_PROPAGATE_HOST_FLAGS "Propage C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON)

 # Enable CUDA_SEPARABLE_COMPILATION
 option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled.  Requires CUDA 5.0+" OFF)
@@ -594,17 +536,19 @@
   CUDA_SEPARABLE_COMPILATION
   )

-# Single config generators like Makefiles or Ninja don't usually have
-# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by
-# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for
-# single config generators (and should not be defined for multi-config
-# generators). To ensure we get a complete superset of all possible
-# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and
-# all of the standard configurations, then weed out duplicates with
-# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have
-# each configuration-specific set of nvcc flags defined and marked as advanced.
+# Makefile and similar generators don't define CMAKE_CONFIGURATION_TYPES, so we
+# need to add another entry for the CMAKE_BUILD_TYPE.  We also need to add the
+# standerd set of 4 build types (Debug, MinSizeRel, Release, and RelWithDebInfo)
+# for completeness.  We need run this loop in order to accomodate the addition
+# of extra configuration types.  Duplicate entries will be removed by
+# REMOVE_DUPLICATES.
 set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo)
 list(REMOVE_DUPLICATES CUDA_configuration_types)
+foreach(config ${CUDA_configuration_types})
+    string(TOUPPER ${config} config_upper)
+    set(CUDA_NVCC_FLAGS_${config_upper} "" CACHE STRING "Semi-colon delimit multiple arguments.")
+    mark_as_advanced(CUDA_NVCC_FLAGS_${config_upper})
+endforeach()

 ###############################################################################
 ###############################################################################
@@ -638,6 +582,7 @@
   unset(CUDA_npps_LIBRARY CACHE)
   unset(CUDA_nvcuvenc_LIBRARY CACHE)
   unset(CUDA_nvcuvid_LIBRARY CACHE)
+  unset(CUDA_USE_STATIC_CUDA_RUNTIME CACHE)
   unset(CUDA_GPU_DETECT_OUTPUT CACHE)
 endmacro()

@@ -680,7 +625,8 @@
   find_path(CUDA_TOOLKIT_ROOT_DIR
     NAMES nvcc nvcc.exe
     PATHS /opt/cuda/bin
-    PATH_SUFFIXES cuda/bin
+          /usr/local/bin
+          /usr/local/cuda/bin
     DOC "Toolkit location."
     )

@@ -726,11 +672,7 @@
   # add known CUDA targetr root path to the set of directories we search for programs, libraries and headers
   set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}")
   macro( cuda_find_host_program )
-    if (COMMAND find_host_program)
-      find_host_program( ${ARGN} )
-    else()
-      find_program( ${ARGN} )
-    endif()
+    find_host_program( ${ARGN} )
   endmacro()
 else()
   # for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR
@@ -742,20 +684,16 @@

 # CUDA_NVCC_EXECUTABLE
-if(DEFINED ENV{CUDA_NVCC_EXECUTABLE})
-  set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler")
-else()
-  cuda_find_host_program(CUDA_NVCC_EXECUTABLE
-    NAMES nvcc
-    PATHS "${CUDA_TOOLKIT_ROOT_DIR}"
-    ENV CUDA_PATH
-    ENV CUDA_BIN_PATH
-    PATH_SUFFIXES bin bin64
-    NO_DEFAULT_PATH
-    )
-  # Search default search paths, after we search our own set of paths.
-  cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc)
-endif()
+cuda_find_host_program(CUDA_NVCC_EXECUTABLE
+  NAMES nvcc
+  PATHS "${CUDA_TOOLKIT_ROOT_DIR}"
+  ENV CUDA_PATH
+  ENV CUDA_BIN_PATH
+  PATH_SUFFIXES bin bin64
+  NO_DEFAULT_PATH
+  )
+# Search default search paths, after we search our own set of paths.
+cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc)
 mark_as_advanced(CUDA_NVCC_EXECUTABLE)

 if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION)
@@ -853,17 +791,12 @@
 if(CUDA_cudart_static_LIBRARY)
   # If static cudart available, use it by default, but provide a user-visible option to disable it.
   option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON)
+  set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY)
 else()
   # If not available, silently disable the option.
   set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "")
-endif()
-
-if(CUDA_USE_STATIC_CUDA_RUNTIME)
-  set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY)
-else()
   set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY)
 endif()
-
 if(NOT CUDA_VERSION VERSION_LESS "5.0")
   cuda_find_library_local_first(CUDA_cudadevrt_LIBRARY cudadevrt "\"cudadevrt\" library")
   mark_as_advanced(CUDA_cudadevrt_LIBRARY)
@@ -975,28 +908,9 @@
     find_cuda_helper_libs(nvcuvid)
   endif()
 endif()
-if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2")
-  # In CUDA 9.2 cublas_device was deprecated
+if(CUDA_VERSION VERSION_GREATER "5.0")
   find_cuda_helper_libs(cublas_device)
-endif()
-
-if(NOT CUDA_VERSION VERSION_LESS "9.0")
-  # In CUDA 9.0 NPP was nppi was removed
-  find_cuda_helper_libs(nppc)
-  find_cuda_helper_libs(nppial)
-  find_cuda_helper_libs(nppicc)
-  find_cuda_helper_libs(nppicom)
-  find_cuda_helper_libs(nppidei)
-  find_cuda_helper_libs(nppif)
-  find_cuda_helper_libs(nppig)
-  find_cuda_helper_libs(nppim)
-  find_cuda_helper_libs(nppist)
-  find_cuda_helper_libs(nppisu)
-  find_cuda_helper_libs(nppitc)
-  find_cuda_helper_libs(npps)
-  set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}")
-elseif(CUDA_VERSION VERSION_GREATER "5.0")
-  # In CUDA 5.5 NPP was split into 3 separate libraries.
+  # In CUDA 5.5 NPP was splitted onto 3 separate libraries.
   find_cuda_helper_libs(nppc)
   find_cuda_helper_libs(nppi)
   find_cuda_helper_libs(npps)
@@ -1334,11 +1248,11 @@
   endif()

   # This needs to be passed in at this stage, because VS needs to fill out the
-  # various macros from within VS.  Note that CCBIN is only used if
+  # value of VCInstallDir from within VS.  Note that CCBIN is only used if
   # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches
-  # _CUDA_MSVC_HOST_COMPILER
+  # $(VCInstallDir)/bin.
   if(CMAKE_GENERATOR MATCHES "Visual Studio")
-    set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" )
+    set(ccbin_flags -D "\"CCBIN:PATH=$(VCInstallDir)bin\"" )
   else()
     set(ccbin_flags)
   endif()
@@ -1457,7 +1371,7 @@
   if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11")
     # Add the c++11 flag to nvcc if it isn't already present.  Note that we only look at
     # the main flag instead of the configuration specific flags.
-    if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" )
+    if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std;c\\+\\+11" )
       list(APPEND nvcc_flags --std c++11)
     endif()
     string(REGEX REPLACE "[-]+std=c\\+\\+11" "" _cuda_host_flags "${_cuda_host_flags}")
@@ -1578,7 +1492,7 @@
       # Bring in the dependencies.  Creates a variable CUDA_NVCC_DEPEND #######
       cuda_include_nvcc_dependencies(${cmake_dependency_file})

-      # Convenience string for output #########################################
+      # Convience string for output ###########################################
       if(CUDA_BUILD_EMULATION)
         set(cuda_build_type "Emulation")
       else()
@@ -1777,7 +1691,6 @@
         COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file}
         ${flags}
         COMMENT "Building NVCC intermediate link file ${output_file_relative_path}"
-        COMMAND_EXPAND_LISTS
         ${_verbatim}
         )
     else()
@@ -1788,7 +1701,6 @@
         COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}"
         COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}"
         COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}"
-        COMMAND_EXPAND_LISTS
         ${_verbatim}
         )
     endif()
@@ -1828,12 +1740,12 @@
   # variable will have been defined.
   CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}")

-  target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD}
+  target_link_libraries(${cuda_target}
     ${CUDA_LIBRARIES}
     )

   if(CUDA_SEPARABLE_COMPILATION)
-    target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD}
+    target_link_libraries(${cuda_target}
       ${CUDA_cudadevrt_LIBRARY}
       )
   endif()
@@ -1878,7 +1790,7 @@
   # variable will have been defined.
   CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}")

-  target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD}
+  target_link_libraries(${cuda_target}
     ${CUDA_LIBRARIES}
     )

@@ -1906,7 +1818,7 @@
   else()
     set(_counter 1)
   endif()
-  string(APPEND _cuda_target "_${_counter}")
+  set(_cuda_target "${_cuda_target}_${_counter}")
   set_property(DIRECTORY PROPERTY _cuda_internal_phony_counter ${_counter})

   # Separate the sources from the options
@@ -1964,9 +1876,9 @@
 ###############################################################################
 macro(CUDA_ADD_CUFFT_TO_TARGET target)
   if (CUDA_BUILD_EMULATION)
-    target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY})
+    target_link_libraries(${target} ${CUDA_cufftemu_LIBRARY})
   else()
-    target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY})
+    target_link_libraries(${target} ${CUDA_cufft_LIBRARY})
   endif()
 endmacro()

@@ -1977,9 +1889,9 @@
 ###############################################################################
 macro(CUDA_ADD_CUBLAS_TO_TARGET target)
   if (CUDA_BUILD_EMULATION)
-    target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY})
+    target_link_libraries(${target} ${CUDA_cublasemu_LIBRARY})
   else()
-    target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY})
+    target_link_libraries(${target} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY})
   endif()
 endmacro()

@@ -1989,9 +1901,9 @@
 ###############################################################################
 ###############################################################################
 macro(CUDA_BUILD_CLEAN_TARGET)
-  # Call this after you add all your CUDA targets, and you will get a
-  # convenience target.  You should also make clean after running this target
-  # to get the build system to generate all the code again.
+  # Call this after you add all your CUDA targets, and you will get a convience
+  # target.  You should also make clean after running this target to get the
+  # build system to generate all the code again.

   set(cuda_clean_target_name clean_cuda_depends)
   if (CMAKE_GENERATOR MATCHES "Visual Studio")


build: replace some is_darwin_sdk usage

build: replace some is_darwin_sdk usage

Use the simpler inline form of the check in most places.  The two sites
that remain have multiple uses in a single function.  It should be
possible to replace those as well, though it is unclear if the overhead
of inlining the check to all the places in the function will make a
measurable difference.

--- cmake/modules/AddSwift.cmake
+++ cmake/modules/AddSwift.cmake
@@ -542,8 +542,7 @@
     list(APPEND source_binaries $<TARGET_FILE:${source_target}>)
   endforeach()

-  is_darwin_based_sdk("${LIPO_SDK}" IS_DARWIN)
-  if(IS_DARWIN)
+  if(${LIPO_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
     if(LIPO_CODESIGN)
       set(codesign_command COMMAND "codesign" "-f" "-s" "-" "${LIPO_OUTPUT}")
     endif()
@@ -751,8 +750,7 @@
   endif()

   if (SWIFT_COMPILER_VERSION)
-    is_darwin_based_sdk("${SWIFTLIB_SINGLE_SDK}" IS_DARWIN)
-    if(IS_DARWIN)
+    if(${SWIFTLIB_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
       list(APPEND SWIFTLIB_SINGLE_LINK_FLAGS "-Xlinker" "-current_version" "-Xlinker" "${SWIFT_COMPILER_VERSION}" "-Xlinker" "-compatibility_version" "-Xlinker" "1")
     endif()
   endif()
@@ -1014,8 +1012,7 @@
     endforeach()
   endif()

-  is_darwin_based_sdk("${SWIFTLIB_SINGLE_SDK}" IS_DARWIN)
-  if(IS_DARWIN)
+  if(${SWIFTLIB_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
     set(install_name_dir "@rpath")

     if(SWIFTLIB_SINGLE_IS_STDLIB)
@@ -2084,8 +2081,7 @@
     list(APPEND link_flags "-Wl,-no_pie")
   endif()

-  is_darwin_based_sdk("${SWIFTEXE_SINGLE_SDK}" IS_DARWIN)
-  if(IS_DARWIN)
+  if(${SWIFTEXE_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
     list(APPEND link_flags
         "-Xlinker" "-rpath"
         "-Xlinker" "@executable_path/../lib/swift/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}")
@@ -2227,8 +2223,7 @@
           ${SWIFTEXE_TARGET_DONT_STRIP_NON_MAIN_SYMBOLS_FLAG}
           ${SWIFTEXE_DISABLE_ASLR_FLAG})

-      is_darwin_based_sdk("${sdk}" IS_DARWIN)
-      if(IS_DARWIN)
+      if(${sdk} IN_LIST SWIFT_APPLE_PLATFORMS)
         add_custom_command_target(unused_var2
          COMMAND "codesign" "-f" "-s" "-" "${SWIFT_RUNTIME_OUTPUT_INTDIR}/${VARIANT_NAME}"
          CUSTOM_TARGET_NAME "${VARIANT_NAME}_signed"


[CMake][NFC] Remove unused logic to choose swift component

add_swift_target_library should always have `TARGET_LIBRARY` set. A few
lines down, there is a precondition that makes sure that it is set. This
check and subsequent assignment of `SWIFTLIB_INSTALL_IN_TARGET` should
never get triggered.

--- cmake/modules/AddSwift.cmake
+++ cmake/modules/AddSwift.cmake
@@ -1741,10 +1741,6 @@
     set(SWIFTLIB_TARGET_LIBRARY TRUE)
   endif()

-  if(NOT SWIFTLIB_TARGET_LIBRARY)
-    set(SWIFTLIB_INSTALL_IN_COMPONENT dev)
-  endif()
-
   # If target SDKs are not specified, build for all known SDKs.
   if("${SWIFTLIB_TARGET_SDKS}" STREQUAL "")
     set(SWIFTLIB_TARGET_SDKS ${SWIFT_SDKS})


More lua changes

More lua changes

--- cmake/modules/BuildLua.cmake
+++ cmake/modules/BuildLua.cmake
@@ -12,6 +12,14 @@
     CMAKE_ARGS -G ${CMAKE_GENERATOR} -Dlua_MSVC_STATIC_RUNTIME=ON
     INSTALL_DIR ${LUA_INSTALL_DIR}
     BUILD_BYPRODUCTS ${_byproducts}
+  )
+
+  ExternalProject_Add_Step(
+    lua
+    copy-lua
+    DEPENDEES download
+    COMMAND ${CMAKE_SCRIPT_PATH}/robocopy.bat "<SOURCE_DIR>/src" "<INSTALL_DIR>/include/" "*.h"
+    COMMAND ${CMAKE_SCRIPT_PATH}/robocopy.bat "<SOURCE_DIR>/src" "<INSTALL_DIR>/include/" "*.hpp"
   )
 else()
   find_library(LUA_DL_LIBRARY dl)
@@ -39,7 +47,7 @@
 )

 if(WIN32)
-  set(LUA_LIBRARY "${install_dir}/lib/liblua.lib")
+  set(LUA_LIBRARY "${install_dir}/lib/lua51.lib")
   set(LUA_LIBRARIES "${LUA_LIBRARY}")
   set(LUA_INSTALL_LIBS "${install_dir}/lib/lua51.dll")
 else()


fixed previous commit

fixed previous commit

--- cmake/modules/QcaMacro.cmake
+++ cmake/modules/QcaMacro.cmake
@@ -19,7 +19,8 @@
     EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_HEADERS" OUTPUT_VARIABLE QT_INCLUDE_DIR )
     EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_DOCS" OUTPUT_VARIABLE QT_DOC_DIR )
     EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_DATA" OUTPUT_VARIABLE QT_DATA_DIR )
-    SET( QT_MKSPECS_DIR ${QT_DATA_DIR}/mkspecs )
+    EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_ARCHDATA" OUTPUT_VARIABLE QT_ARCHDATA_DIR )
+    SET( QT_MKSPECS_DIR "${QT_ARCHDATA_DIR}/mkspecs" )
   ENDMACRO(SETUP_QT5_DIRS)
 ENDIF()


Fix the php extension build on mac os x.

--- cmake_modules/FindPHP5.cmake
+++ cmake_modules/FindPHP5.cmake
@@ -51,6 +51,7 @@
   SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
    "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -Wl,-flat_namespace")
   FOREACH(symbol
+    _convert_to_boolean
     _zend_throw_exception
     _zend_register_long_constant
     _zend_get_constant


BALLMacros.cmake: fix for dll finding in BALL_LIB_TO_DLL

If, as e.g. in case of libfftw-3.3.lib, the filename contained
more than one '.', not only the extension '.lib' was cut off by
get_filename_component(...) but also the last part of the filename itself
(in the example: '.3.lib') and the file has not been found. This has been fixed.

--- cmake/BALLMacros.cmake
+++ cmake/BALLMacros.cmake
@@ -199,7 +199,9 @@
 			SET(NEXT_LIB_IS_OPT TRUE)
 		ELSE()
 			GET_FILENAME_COMPONENT(LIBPATH "${LIB}" PATH)
-			GET_FILENAME_COMPONENT(LIBNAME "${LIB}" NAME_WE)
+			GET_FILENAME_COMPONENT(LIBNAME "${LIB}" NAME)
+			STRING(REGEX REPLACE "lib$" "dll" LIBNAME ${LIBNAME})
+
 			SET(DLLPATH "DLLPATH-NOTFOUND" CACHE STRING "" FORCE)
 			FIND_FILE(DLLPATH
 				NAMES  "${LIBNAME}.dll"


Updated FindMatlab

Updated FindMatlab

--- cmake/FindMatlab.cmake
+++ cmake/FindMatlab.cmake
@@ -228,6 +228,7 @@
 endif()

 set(MATLAB_VERSIONS_MAPPING
+  "R2015b=8.6"
   "R2015a=8.5"
   "R2014b=8.4"
   "R2014a=8.3"


Update defines

Update defines

--- cmake/FindWebRTC.cmake
+++ cmake/FindWebRTC.cmake
@@ -342,7 +342,8 @@
   list(APPEND WEBRTC_DEFINES
     -DNOMINMAX -DPSAPI_VERSION=1 -D_CRT_RAND_S
     -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS
-    -D_ATL_NO_OPENGL -D_SECURE_ATL -D_HAS_EXCEPTIONS=0
+    -D_ATL_NO_OPENGL -D_SECURE_ATL
+    # -D_HAS_EXCEPTIONS=0
     -D_WINSOCK_DEPRECATED_NO_WARNINGS
     -DNO_TCMALLOC -D__STD_C
     -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE


MINIFICPP-1883 Enable compression in Prometheus client

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

--- cmake/Prometheus.cmake
+++ cmake/Prometheus.cmake
@@ -20,7 +20,7 @@
 set(ENABLE_PUSH OFF CACHE BOOL "" FORCE)
 set(ENABLE_TESTING OFF CACHE BOOL "" FORCE)
 set(USE_THIRDPARTY_LIBRARIES OFF CACHE BOOL "" FORCE)
-set(ENABLE_COMPRESSION OFF CACHE BOOL "" FORCE)
+set(ENABLE_COMPRESSION ON CACHE BOOL "" FORCE)

 set(PATCH_FILE "${CMAKE_SOURCE_DIR}/thirdparty/prometheus-cpp/remove-find_package.patch")
 set(PC ${Bash_EXECUTABLE}  -c "set -x &&\


fix(qt): Qt include directories are still broken :(

--- cmake/consort/qt.cmake
+++ cmake/consort/qt.cmake
@@ -163,19 +163,14 @@

 			message(STATUS "Qt version: ${Qt5Core_VERSION_STRING} (${QT_ROOT})")

-			if( Qt5Core_VERSION_STRING VERSION_LESS "5.1" )
-				# Qt before 5.1 can generate errors
-				foreach(m ${_qt_modules})
-					co_debug(Qt5${m}_INCLUDE_DIRS)
-					foreach(d ${Qt5${m}_INCLUDE_DIRS})
-						if(NOT IS_DIRECTORY "${d}")
-							co_debug(d)
-							list(REMOVE_ITEM Qt5${m}_INCLUDE_DIRS "${d}")
-						endif()
-					endforeach()
-					co_debug(Qt5${m}_INCLUDE_DIRS)
+			# Some versions of Qt reference invalid include directories
+			foreach(m Core ${_modules})
+				foreach(d ${Qt5${m}_INCLUDE_DIRS})
+					if(NOT IS_DIRECTORY "${d}")
+						list(REMOVE_ITEM Qt5${m}_INCLUDE_DIRS "${d}")
+					endif()
 				endforeach()
-			endif()
+			endforeach()

 			if( NOT QT_TRANSLATIONS_DIR)
 				get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)


fixed gtest function for bc

fixed gtest function for bc

--- cmake/test/gtest.cmake
+++ cmake/test/gtest.cmake
@@ -47,9 +47,9 @@
   catkin_run_tests_target("gtest" ${target} "gtest-${target}.xml" COMMAND ${cmd} WORKING_DIRECTORY ${_gtest_WORKING_DIRECTORY})
 endfunction()

-function(add_gtest target)
+function(add_gtest)
   message(WARNING "add_gtest() is deprecated, please rename the function call to catkin_add_gtest()")
-  catkin_add_gtest($ARGN)
+  catkin_add_gtest(${ARGN})
 endfunction()

 if(_CATKIN_GTEST_SRC_FOUND)


PKG: exclude python dll in packaging

PKG: exclude python dll in packaging

--- SuperBuild/Packaging/PackageHelper.cmake
+++ SuperBuild/Packaging/PackageHelper.cmake
@@ -1013,6 +1013,7 @@
   concrt*.*.dll
   odbc32.dll
   psapi.dll
+  python...dll
   vcomp*.*.dll)

 set(LINUX_SYSTEM_DLLS


BUG: Mantis-1364: mach-o bundle not detected caused missing libraries in package

--- SuperBuild/Packaging/PackageMacros.cmake
+++ SuperBuild/Packaging/PackageMacros.cmake
@@ -241,6 +241,13 @@
       return()
     endif()

+    # detect shared libraries on Mac OSX
+    # where "file" gives "Mach-O 64-bit x86_64 bundle"
+    if("${file_ov}" MATCHES "mach-o.*bundle")
+      set(${result_var} 1 PARENT_SCOPE)
+      return()
+    endif()
+
   endif(APPLE)

 endfunction()


ENH:  Update ITK.

ENH:  Update ITK.

--- SuperBuild/External_ITKv4.cmake
+++ SuperBuild/External_ITKv4.cmake
@@ -150,7 +150,7 @@
   ### --- End Project specific additions
   set(${proj}_REPOSITORY ${git_protocol}://itk.org/ITK.git)
   set(${proj}_REPOSITORY "https://github.com/InsightSoftwareConsortium/ITK.git")
-  set(${proj}_GIT_TAG 796b9313d8b081ccf9a0f277c7f64341ad335855)
+  set(${proj}_GIT_TAG 5d193c91ff8fc5e85fd0b36e6eabb14f503dfb9e)
   set(ITK_VERSION_ID ITK-4.6)

   ExternalProject_Add(${proj}


Fix ITK's HDF5 on-disk format as well

Fix ITK's HDF5 on-disk format as well

--- SuperBuild/External_ITKv5.cmake
+++ SuperBuild/External_ITKv5.cmake
@@ -148,7 +148,7 @@

   ### --- End Project specific additions
   set(${proj}_REPOSITORY ${git_protocol}://github.com/InsightSoftwareConsortium/ITK.git)
-  set(${proj}_GIT_TAG 05226185feb360139e954a1bf3b6eb86f11e5abc ) ##
+  set(${proj}_GIT_TAG e5520e9078ed0ca6085e1defccbd132d85ed49f7 ) ##
   set(ITK_VERSION_ID ITK-5.0) ### NOTE: When updating GIT_TAG, also update ITK_VERSION_ID

   ExternalProject_Add(${proj}


Remove underscores from CFBundleIdentifier of libraries.

Underscores aren't permitted in these identifiers.
Fixes rdar://84645973.

--- stdlib/cmake/modules/AddSwiftStdlib.cmake
+++ stdlib/cmake/modules/AddSwiftStdlib.cmake
@@ -1263,7 +1263,9 @@
   set(PLIST_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
   if("${SWIFTLIB_SINGLE_SDK}" IN_LIST SWIFT_DARWIN_PLATFORMS AND SWIFTLIB_SINGLE_IS_STDLIB)
     set(PLIST_INFO_NAME ${name})
-    set(PLIST_INFO_UTI "com.apple.dt.runtime.${name}")
+
+    # Underscores aren't permitted in the bundle identifier.
+    string(REPLACE "_" "" PLIST_INFO_UTI "com.apple.dt.runtime.${name}")
     set(PLIST_INFO_VERSION "${SWIFT_VERSION}")
     if (SWIFT_COMPILER_VERSION)
       set(PLIST_INFO_BUILD_VERSION


CTest: Omit git hash on nightlies

CTest: Omit git hash on nightlies

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

--- test.cmake
+++ test.cmake
@@ -280,7 +280,15 @@
    set(build_type_short "${build_type}")
 endif()

-string(STRIP "${git_hash} ${git_branch} ${COMPILER_VERSION} ${CXXFLAGS} ${build_type_short} ${tmp}" CTEST_BUILD_NAME)
+string(STRIP "${git_branch} ${COMPILER_VERSION} ${CXXFLAGS} ${build_type_short} ${tmp}" CTEST_BUILD_NAME)
+if(NOT is_nightly)
+   # nightly builds shouldn't contain the git hash, since it makes expected builds impossible
+   string(STRIP "${git_hash} ${CTEST_BUILD_NAME}" CTEST_BUILD_NAME)
+   # instead make sure the hash is included in the notes
+   if(EXISTS "${CTEST_SOURCE_DIRECTORY}/.git/refs/heads/${git_branch}")
+      list(APPEND CTEST_NOTES_FILES "${CTEST_SOURCE_DIRECTORY}/.git/refs/heads/${git_branch}")
+   endif()
+endif()
 if(DEFINED subset)
    set(CTEST_BUILD_NAME "${CTEST_BUILD_NAME} ${subset}")
 endif()


Fixed typo in tools classpath (linux).

Fixed typo in tools classpath (linux).

--- tools/component_definitions.cmake
+++ tools/component_definitions.cmake
@@ -213,7 +213,7 @@

         target_link_libraries(${${COMPONENT}_JAVA_BINDING_LIB} ${${COMPONENT}_SHARED_LIB} ${FIELDS_JAVA_BINDING_LIBS} ${VTK_LIBS} ${JDK_LIBS})

-        list(APPEND ${COMPONENT}_CLASSPATH ${FIELDS_CLASSPATH} ${OUTDIR}/${${COMPONENT}_JAVA_BINDING_JAR} ${VTK_JAR} ${JMF_JAR})
+        list(APPEND ${COMPONENT}_CLASSPATH ${FIELDS_CLASSPATH} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${${COMPONENT}_JAVA_BINDING_JAR} ${VTK_JAR} ${JMF_JAR})
         set(${COMPONENT}_CLASSPATH ${${COMPONENT}_CLASSPATH} CACHE STRING "Cumulative classpath for ${PROJECT_NAME}" FORCE)

          # Create the bindings jar file
@@ -240,6 +240,7 @@
             # and store the result in parent_classpath.
             string(REGEX REPLACE ";" ":" parent_classpath "${FIELDS_CLASSPATH}")
             string(REGEX REPLACE ";" ":" this_classpath "${${COMPONENT}_CLASSPATH}")
+            message(STATUS "${this_classpath}")
             # The default list item separator in cmake is ";". If Linux, then exchange ";" for  the UNIX style ":"
             # and store the result in parent_classpath.
             string(REGEX REPLACE ";" ":" parent_classpath "${FIELDS_CLASSPATH};${VTK_JAR};${JMF_JAR}")
@@ -268,6 +269,7 @@

          # Build the SheafScope jar
         if(WIN64INTEL OR WIN64MSVC)
+          message(STATUS "${this_classpath}")
              add_custom_target(SheafScope.jar ALL
                                  DEPENDS ${PROJECT_NAME}_java_binding.jar
                                  COMMAND ${CMAKE_COMMAND} -E make_directory ${LIB_JAR_DIR}
@@ -287,12 +289,13 @@
                                  COMMAND ${JAR_EXECUTABLE} cvmf ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/SheafScope/manifest.txt ${OUTDIR}/SheafScope.jar  -C ${LIB_JAR_DIR} .
                               )
         else()
+                  message(STATUS "${this_classpath}")
          # Build the SheafScope jar
              add_custom_target(SheafScope.jar ALL
                                  DEPENDS ${PROJECT_NAME}_java_binding.jar
                                  COMMAND ${CMAKE_COMMAND} -E make_directory ${LIB_JAR_DIR}
                                  COMMAND ${CMAKE_COMMAND} -E echo "Compiling Java files..."
-                                 COMMAND ${JAVAC_EXECUTABLE} -classpath "${parent_classpath}" -g -d ${LIB_JAR_DIR} @${CMAKE_BINARY_DIR}/scopesrcs
+                                 COMMAND ${JAVAC_EXECUTABLE} -classpath "${this_classpath}" -g -d ${LIB_JAR_DIR} @${CMAKE_BINARY_DIR}/scopesrcs
                                  COMMAND ${CMAKE_COMMAND} -E make_directory ${LIB_JAR_DIR}/tools/common/gui/resources
                                  COMMAND ${CMAKE_COMMAND} -E make_directory ${LIB_JAR_DIR}/tools/viewer/resources/docs
                                  COMMAND ${CMAKE_COMMAND} -E make_directory ${LIB_JAR_DIR}/tools/SheafScope/resources/docs


Updating ITK super to master on 4/14/14

Updating ITK super to master on 4/14/14

Change-Id: I9d95e384a58ca218d0602cb9e773a3c92b82a7b1

--- SuperBuild/External_ITK.cmake
+++ SuperBuild/External_ITK.cmake
@@ -35,8 +35,8 @@
 set(ITK_REPOSITORY git://itk.org/ITK.git)

 # NOTE: it is very important to update the ITK_DIR path with the ITK version
-# master on 6/03/14
-set(ITK_TAG_COMMAND GIT_TAG fb0227e9294f52190af154b4e2c22636ed2dd03f )
+# master on 6/14/14
+set(ITK_TAG_COMMAND GIT_TAG 3b7314b1ecbc5e81b082f83b9819ff04d64217a9)

 if( ${ITK_WRAPPING} OR ${BUILD_SHARED_LIBS} )


Updating ITK Superbuild towards 4.9 along master branch

Change-Id: I44ce49c46243847d791df60a9f45d60cbc8bfdba

--- SuperBuild/External_ITK.cmake
+++ SuperBuild/External_ITK.cmake
@@ -35,7 +35,7 @@
 set(ITK_REPOSITORY git://itk.org/ITK.git)

 # NOTE: it is very important to update the ITK_DIR path with the ITK version
-set(ITK_TAG_COMMAND GIT_TAG v4.8.1)
+set(ITK_TAG_COMMAND GIT_TAG 8c446afdd2781c0c54a2d9b115528c6d01d93abb)

 if( ${ITK_WRAPPING} OR ${BUILD_SHARED_LIBS} )
   set( ITK_BUILD_SHARED_LIBS ON )


COMP: need 6.2 tag

COMP: need 6.2 tag

--- SuperBuild/External_VTK.cmake
+++ SuperBuild/External_VTK.cmake
@@ -19,7 +19,7 @@
 # SlicerMacroCheckExternalProjectDependency
 set(extProjName VTK) #The find_package known name
 set(proj        VTK) #This local name
-set(${extProjName}_REQUIRED_VERSION "6")  #If a required version is necessary, then set this, else leave blank
+set(${extProjName}_REQUIRED_VERSION "6.2")  #If a required version is necessary, then set this, else leave blank

 #if(${USE_SYSTEM_${extProjName}})
 #  unset(${extProjName}_DIR CACHE)


ENH: Bump Superbuild ITK version to 4.7.0.

Change-Id: I849eb4d5887d5c6bbc9c7ba2890b0368bd277dcb

--- Superbuild/External-ITK.cmake
+++ Superbuild/External-ITK.cmake
@@ -2,7 +2,7 @@
 # Get and build itk

 if( NOT ITK_TAG )
-  set( ITK_TAG "v4.6.1" )
+  set( ITK_TAG "v4.7.0" )
 endif()

 set( _vtk_args )


Minor Win32 cross-compile fix (#1071)

Minor Win32 cross-compile fix (#1071)

See https://github.com/koreader/koreader/issues/4512#issuecomment-605433402

This is not intended to actually fix the build, just to make it so that an interested party won't have to start at 0.

--- thirdparty/cmake_modules/CMakeCross.cmake
+++ thirdparty/cmake_modules/CMakeCross.cmake
@@ -12,6 +12,10 @@
 # set target system name
 set(CMAKE_SYSTEM_NAME Linux)
 # set target system processor, because we can't set CMAKE_SYSTEM_NAME without setting CMAKE_SYSTEM_PROCESSOR too...
+
+if($ENV{WIN32})
+    set(CMAKE_SYSTEM_NAME Windows)
+endif()

 # x86 Android
 if($ENV{CROSS_TC} MATCHES "^i686-.*")


Add more warning detection for jenkins

Add more warning detection for jenkins

--- Testing/jenkins_mercury.cmake
+++ Testing/jenkins_mercury.cmake
@@ -61,7 +61,7 @@

 # Initial cache used to build mercury, options can be modified here
 set(dashboard_cache "
-CMAKE_C_FLAGS:STRING=-Wall -Wextra -Wshadow
+CMAKE_C_FLAGS:STRING=-Wall -Wextra -Wshadow -Winline -Wundef -Wcast-qual -Wc++-compat -std=gnu99

 BUILD_SHARED_LIBS:BOOL=${mercury_build_shared}
 BUILD_TESTING:BOOL=ON


[OGRE-275] Fix bin path searching on OS X.

--HG--
branch : v1-9

--- CMake/Packages/FindOGRE.cmake
+++ CMake/Packages/FindOGRE.cmake
@@ -127,6 +127,10 @@

     set(OGRE_BIN_SEARCH_PATH ${dir}/bin ${OGRE_BIN_SEARCH_PATH})
     set(OGRE_BIN_SEARCH_PATH ${dir}/Samples/Common/bin ${OGRE_BIN_SEARCH_PATH})
+
+    if(APPLE AND NOT OGRE_BUILD_PLATFORM_APPLE_IOS)
+      set(OGRE_BIN_SEARCH_PATH ${dir}/bin/macosx ${OGRE_BIN_SEARCH_PATH})
+    endif()
   endforeach(dir)

   if (OGRE_PREFIX_DEPENDENCIES_DIR)


#14 cmake: Set ARCHIVE_OUTPUT_NAME library target property

--- CMake/mirtk_add_library.cmake
+++ CMake/mirtk_add_library.cmake
@@ -47,6 +47,7 @@
     ${target_name} PROPERTIES
       VERSION             "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
       SOVERSION           "${PROJECT_SOVERSION}"
+      ARCHIVE_OUTPUT_NAME "${PROJECT_PACKAGE_NAME}${PROJECT_NAME}"
       LIBRARY_OUTPUT_NAME "${PROJECT_PACKAGE_NAME}${PROJECT_NAME}"
   )
   foreach (dep IN LISTS TARGET_DEPENDS)


Add DataModel to StandAlone group.

Add DataModel to StandAlone group.

This make it easier to build editions which just include DataModel and
dependencies. DataModel module gets included in a "StandAlone" build of
VTK since several other modules in the StandAlone group depend on
DataModel. However, if the edition only has DataModel (and none of the
other modules that depend on it), it doesn't get enabled by default.
Given our definition of "StandAlone" module, DataModule should indeed be
a part of it. Hence, adding it to that group.

--- Common/DataModel/module.cmake
+++ Common/DataModel/module.cmake
@@ -1,4 +1,6 @@
 vtk_module(vtkCommonDataModel
+  GROUPS
+    StandAlone
   DEPENDS
     vtkCommonSystem
     vtkCommonMath


Use a qRestAPI version compatible with Qt 4.6.2

--- CMakeExternals/qRestAPI.cmake
+++ CMakeExternals/qRestAPI.cmake
@@ -24,7 +24,7 @@

 if(NOT DEFINED ${proj}_DIR)

-  set(revision_tag "778ac3f871")
+  set(revision_tag "0d46f8a682")
   if(${proj}_REVISION_TAG)
     set(revision_tag ${${proj}_REVISION_TAG})
   endif()


Enable C++11 on clang

Enable C++11 on clang

--- Compiler.cmake
+++ Compiler.cmake
@@ -42,6 +42,9 @@
     else()
       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
     endif()
+  endif()
+  if(CMAKE_COMPILER_IS_CLANG)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
   endif()

 # icc


Fixed symbolic link.

Fixed symbolic link.


Update HunterGate module

Update HunterGate module

--- examples/iOS/CubeExample/cmake/HunterGate.cmake
+++ examples/iOS/CubeExample/cmake/HunterGate.cmake
@@ -201,10 +201,20 @@
 endmacro()

 function(hunter_gate_download dir)
-  if(NOT HUNTER_RUN_INSTALL)
+  string(
+      COMPARE
+      NOTEQUAL
+      "$ENV{HUNTER_DISABLE_AUTOINSTALL}"
+      ""
+      disable_autoinstall
+  )
+  if(disable_autoinstall AND NOT HUNTER_RUN_INSTALL)
     hunter_gate_fatal_error(
-        "Hunter not found in '${HUNTER_GATE_ROOT}'"
+        "Hunter not found in '${dir}'"
         "Set HUNTER_RUN_INSTALL=ON to auto-install it from '${HUNTER_GATE_URL}'"
+        "Settings:"
+        "  HUNTER_ROOT: ${HUNTER_GATE_ROOT}"
+        "  HUNTER_SHA1: ${HUNTER_GATE_SHA1}"
         WIKI "error.run.install"
     )
   endif()
@@ -393,12 +403,16 @@
         HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE
     )
     hunter_gate_status_debug("HUNTER_ROOT: ${HUNTER_GATE_ROOT}")
-    string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces)
-    if(NOT _contain_spaces EQUAL -1)
-      hunter_gate_fatal_error(
-          "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces"
-          WIKI "error.spaces.in.hunter.root"
-      )
+    if(NOT HUNTER_ALLOW_SPACES_IN_PATH)
+      string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces)
+      if(NOT _contain_spaces EQUAL -1)
+        hunter_gate_fatal_error(
+            "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces."
+            "Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error"
+            "(Use at your own risk!)"
+            WIKI "error.spaces.in.hunter.root"
+        )
+      endif()
     endif()

     string(


Use EXECUTABLE macro option for snippet.

--- documentation/snippets/uServices-singleton/files.cmake
+++ documentation/snippets/uServices-singleton/files.cmake
@@ -7,6 +7,5 @@

 usFunctionGenerateModuleInit(snippet_src_files
                              NAME "uServices_singleton"
-                             LIBRARY_NAME ""
-                             DEPENDS ""
+                             EXECUTABLE
                             )


Update Android-Google-APIs-Intel-x86-Atom-System-Image

--- cmake/projects/Android-Google-APIs-Intel-x86-Atom-System-Image/hunter.cmake
+++ cmake/projects/Android-Google-APIs-Intel-x86-Atom-System-Image/hunter.cmake
@@ -31,9 +31,9 @@
     VERSION
     "21" # version affect layout: <sdk>/system-images/android-21/google_apis/
     URL
-    "https://dl.google.com/android/repository/sys-img/google_apis/sysimg_x86-21_r06.zip"
+    "https://dl.google.com/android/repository/sys-img/google_apis/sysimg_x86-21_r09.zip"
     SHA1
-    1e8dbdd5de5ef579eb7e3dd6d3caf9081694092f
+    b6a979f63c72e88142ea449b906e443f986a12cf
 )

 hunter_pick_scheme(DEFAULT url_sha1_unpack)


place_constraints: linearize cmake dependencies of VPR grid map

Signed-off-by: Alessandro Comodi <622632e70fd6771cf2cd943f69e5e51ab66adef8@antmicro.com>

--- xc/common/cmake/project_ray.cmake
+++ xc/common/cmake/project_ray.cmake
@@ -143,7 +143,13 @@
     )

   add_file_target(FILE channels.db GENERATED)
+  get_file_target(CHAN channels.db)
+
   add_file_target(FILE vpr_grid_map.csv GENERATED)
+
+  # Linearize dependency to avoid double builds
+  get_file_target(GRID_MAP vpr_grid_map.csv)
+  add_dependencies(${GRID_MAP} ${CHAN})

   append_file_dependency(DEPS ${symbiflow-arch-defs_SOURCE_DIR}/xc/${FAMILY}/archs/${ARCH}/pin_assignments.json)
   append_file_dependency(DEPS channels.db)
@@ -222,8 +228,14 @@
       )

     add_file_target(FILE ${CHANNELS} GENERATED)
+    get_file_target(CHAN ${CHANNELS})
+
     add_file_target(FILE ${VPR_GRID_MAP} GENERATED)
-    get_file_target(CHAN ${CHANNELS})
+
+    # Linearize dependency to avoid double builds
+    get_file_target(GRID_MAP ${VPR_GRID_MAP})
+    add_dependencies(${GRID_MAP} ${CHAN})
+
   endforeach()

   set(PROTOTYPE_CHANNELS channels/${PROTOTYPE_PART}/channels.db)


Use _INCLUDE_DIRS as project header variable name

--- glraw-config.cmake
+++ glraw-config.cmake
@@ -2,7 +2,7 @@
 # GLRAW_DIR
 # GLRAW_FOUND
 # GLRAW_LIBRARIES
-# GLRAW_INCLUDES
+# GLRAW_INCLUDE_DIRS

 # GLRAW_LIBRARY
 # GLRAW_LIBRARY_RELEASE
@@ -64,7 +64,7 @@
     endif()

-    set(GLRAW_INCLUDES  ${GLRAW_INCLUDES}  ${${LIB_NAME_UPPER}_INCLUDE_DIR} PARENT_SCOPE)
+    set(GLRAW_INCLUDE_DIRS  ${GLRAW_INCLUDE_DIRS}  ${${LIB_NAME_UPPER}_INCLUDE_DIR} PARENT_SCOPE)
     set(GLRAW_LIBRARIES ${GLRAW_LIBRARIES} ${${LIB_NAME_UPPER}_LIBRARY} PARENT_SCOPE)

     # DEBUG MESSAGES
@@ -138,9 +138,9 @@
 endif()

 # DEBUG
-#message("GLRAW_INCLUDES  = ${GLRAW_INCLUDES}")
+#message("GLRAW_INCLUDE_DIRS  = ${GLRAW_INCLUDE_DIRS}")
 #message("GLRAW_LIBRARIES = ${GLRAW_LIBRARIES}")

 include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(GLRAW DEFAULT_MSG GLRAW_LIBRARIES GLRAW_INCLUDES)
+find_package_handle_standard_args(GLRAW DEFAULT_MSG GLRAW_LIBRARIES GLRAW_INCLUDE_DIRS)
 mark_as_advanced(GLRAW_FOUND)


Better output for lookup packages that are found initially

--- scripts/PackageLookup.cmake
+++ scripts/PackageLookup.cmake
@@ -93,10 +93,8 @@
     if(recursive AND REQUIRED)
         set(required REQUIRED)
     endif()
-    set(quiet "")
-    if(QIET)
-        set(quiet QUIET)
-    elseif(NOT recursive)
+    unset(quiet)
+    if(QUIET OR (NOT QUIET AND NOT recursive))
         set(quiet QUIET)
     endif()
     if(dolook OR do_rootchange)
@@ -107,18 +105,19 @@
             set(_SAVE_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH})
             list(INSERT CMAKE_PREFIX_PATH 0 "${EXTERNAL_ROOT}")
         endif()
-        find_package(${package} ${ARGN}
-            ${required} ${quiet}
-        )
+        find_package(${package} ${ARGN} ${required} ${quiet})
         if(do_rootchange)
             _unset_root_path()
             unset(do_rootchange)
-            if(${PACKAGE}_FOUND OR ${PACKAGE_UPPER}_FOUND)
+            if(${PACKAGE}_FOUND OR ${package}_FOUND)
                 message(STATUS "Found ${package} in external "
                     "projects directory ${EXTERNAL_ROO}")
             endif()
         else()
             set(CMAKE_PREFIX_PATH ${_SAVE_CMAKE_PREFIX_PATH})
+            if(NOT QUIET AND (${PACKAGE}_FOUND OR ${package}_FOUND))
+                message(STATUS "Found ${package}")
+            endif()
         endif()
     endif()
 endmacro()


Find NaturalDocs with caps as well

Find NaturalDocs with caps as well

--- CMakeModules/FindNaturalDocs.cmake
+++ CMakeModules/FindNaturalDocs.cmake
@@ -9,7 +9,7 @@
 #    <https://github.com/malaterre/GDCM/>
 #

-find_program(NATURALDOCS_EXECUTABLE naturaldocs)
+find_program(NATURALDOCS_EXECUTABLE NAMES naturaldocs NaturalDocs)

 if(NATURALDOCS_EXECUTABLE)
     execute_process(COMMAND ${NATURALDOCS_EXECUTABLE} --help


link against zlibstatic built by ghoul

link against zlibstatic built by ghoul

--- support/cmake/support_macros.cmake
+++ support/cmake/support_macros.cmake
@@ -126,7 +126,7 @@
         libOpenSpace
         # sgct
         sgct_light glew glfw png16_static quat  tinythreadpp tinyxml2static turbojpeg-static
-        vrpn zlibstatic
+        vrpn
         ${GLFW_LIBRARIES}
     )


save_to_cache: replace HUNTER_INSTALL_PREFIX in unrelocatable text files

--- cmake/modules/hunter_save_to_cache.cmake
+++ cmake/modules/hunter_save_to_cache.cmake
@@ -77,6 +77,15 @@
       INSTALL_PREFIX "${HUNTER_PACKAGE_INSTALL_PREFIX}"
   )

+  # HUNTER_INSTALL_PREFIX could be present on the text file and must be replaced
+  # The cached package can be uncompressed in a different HUNTER_INSTALL_PREFIX
+  # see https://github.com/ruslo/hunter/issues/472
+  hunter_patch_unrelocatable_text_files(
+      FROM "${HUNTER_INSTALL_PREFIX}"
+      TO "__HUNTER_PACKAGE_INSTALL_PREFIX__"
+      INSTALL_PREFIX "${HUNTER_PACKAGE_INSTALL_PREFIX}"
+  )
+
   ### Lock cache directory
   set(cache_directory "${HUNTER_CACHED_ROOT}/_Base/Cache")
   hunter_lock_directory("${cache_directory}" "")


Clean compile flags

Clean compile flags

Fat LTO object is required for our toolchain

--- platform/stm32f4xx/compiler/gnu/gnu.cmake
+++ platform/stm32f4xx/compiler/gnu/gnu.cmake
@@ -8,13 +8,6 @@
 # TODO: separate debug\release builds
 set(CC_WARN_FLAGS "-Wall -Wextra -Wpedantic -Werror")
 set(CXX_WARN_FLAGS "${CC_WARN_FLAGS} -Weffc++")
-
-# optimization flags
-set(CC_OPT_FLAGS "-Os -flto=4 ")
-set(CXX_OPT_FLAGS "${CC_OPT_FLAGS}")
-# used in debug mode
-set(CC_NO_OPT_FLAGS "-O0 -g3")
-set(CXX_NO_OPT_FLAGS "${CC_NO_OPT_FLAGS}")

 # common flags for current platform
 set(CC_PLATFORM_FLAGS "-ffreestanding -mcpu=cortex-m4 -mthumb -fdata-sections -ffunction-sections -fno-common")
@@ -35,11 +28,21 @@
 set(CMAKE_CXX_FLAGS
 "${CMAKE_CXX_FLAGS} ${CXX_PLATFORM_FLAGS} ${CC_WARN_FLAGS} ${CXX_EXTRA_FLAGS}")

-# Default flags of the release mode are OK for our builds
-# Default flags of the minimum size mode are OK for our builds
-# Debug mode
-set(CMAKE_C_FLAGS_DEBUG  "${CC_OPT_FLAGS}")
-set(CMAKE_CXX_FLAGS_DEBUG "${CXX_OPT_FLAGS}")
+# Release flags, optimization is on,
+set(CMAKE_C_FLAGS_RELEASE "-O3 -flto=4 -ffat-lto-objects ")
+set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
+
+# Minimum size release flags, LTO and minimum size
+set(CMAKE_C_FLAGS_MINSIZEREL "-Os -flto=4 -ffat-lto-objects ")
+set(CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL})
+
+# Debug mode, no LTO and maximum debug info
+set(CMAKE_C_FLAGS_DEBUG  "-O0 -g3 ")
+set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
+
+# GCC is used as a linker in order to use LTO properly
+set(CMAKE_C_LINKER "arm-none-eabi-gcc")
+set(CMAKE_CXX_LINKER "arm-none-eabi-g++")

 # Linker flags
 set(CMAKE_C_LINK_FLAGS
@@ -48,9 +51,9 @@
 	"-fuse-linker-plugin -nostdlib -nostartfiles -T${CMAKE_CURRENT_LIST_DIR}/stm32.ld -flto -Wl,--gc-sections ")
 set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
 set(CMAKE_C_LINK_EXECUTABLE
-"arm-none-eabi-gcc <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
+"${CMAKE_C_LINKER} <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
 set(CMAKE_CXX_LINK_EXECUTABLE
-"arm-none-eabi-g++ <OBJECTS> <CMAKE_CXX_LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
+"${CMAKE_CXX_LINKER} <OBJECTS> <CMAKE_CXX_LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")

 # TODO: merge these flags with compiler one
 set(CMAKE_ASM-ATT_COMPILER_ARG1 "-mcpu=cortex-m4")


update android.toolchain.cmake

update android.toolchain.cmake

--- platforms/android/android.toolchain.cmake
+++ platforms/android/android.toolchain.cmake
@@ -29,12 +29,9 @@
 # POSSIBILITY OF SUCH DAMAGE.

 # ------------------------------------------------------------------------------
-#  Android CMake toolchain file, for use with the Android NDK r5-r9
+#  Android CMake toolchain file, for use with the Android NDK r5-r10d
 #  Requires cmake 2.6.3 or newer (2.8.5 or newer is recommended).
 #  See home page: https://github.com/taka-no-me/android-cmake
-#
-#  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
 #
 #  Usage Linux:
 #   $ export ANDROID_NDK=/absolute/path/to/the/android-ndk
@@ -50,7 +47,7 @@
 #
 #  Usage Windows:
 #     You need native port of make to build your project.
-#     Android NDK r7 (or newer) already has make.exe on board.
+#     Android NDK r7 (and 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
 #
@@ -76,36 +73,54 @@
 #      used by ndk-build tool from Android NDK.
 #
 #      Possible targets are:
-#        "armeabi" - matches to the NDK ABI with the same name.
-#           See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
-#        "armeabi-v7a" - matches to the NDK ABI with the same name.
-#           See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
+#        "armeabi" - ARMv5TE based CPU with software floating point operations
+#        "armeabi-v7a" - ARMv7 based devices with hardware FPU instructions
+#            this ABI target is used by default
 #        "armeabi-v7a with NEON" - same as armeabi-v7a, but
 #            sets NEON as floating-point unit
 #        "armeabi-v7a with VFPV3" - same as armeabi-v7a, but
-#            sets VFPV3 as floating-point unit (has 32 registers instead of 16).
-#        "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP.
-#        "x86" - matches to the NDK ABI with the same name.
-#            See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
-#        "mips" - matches to the NDK ABI with the same name.
-#            See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
+#            sets VFPV3 as floating-point unit (has 32 registers instead of 16)
+#        "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP
+#        "x86" - IA-32 instruction set
+#        "mips" - MIPS32 instruction set
+#
+#      64-bit ABIs for NDK r10 and newer:
+#        "arm64-v8a" - ARMv8 AArch64 instruction set
+#        "x86_64" - Intel64 instruction set (r1)
+#        "mips64" - MIPS64 instruction set (r6)
 #
 #    ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for.
 #      Option is read-only when standalone toolchain is used.
-#
-#    ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.6 - the name of compiler
+#      Note: building for "android-L" requires explicit configuration.
+#
+#    ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 - the name of compiler
 #      toolchain to be used. The list of possible values depends on the NDK
-#      version. For NDK r8c the possible values are:
-#
-#        * arm-linux-androideabi-4.4.3
+#      version. For NDK r10c the possible values are:
+#
+#        * aarch64-linux-android-4.9
+#        * aarch64-linux-android-clang3.4
+#        * aarch64-linux-android-clang3.5
 #        * arm-linux-androideabi-4.6
-#        * arm-linux-androideabi-clang3.1
-#        * mipsel-linux-android-4.4.3
+#        * arm-linux-androideabi-4.8
+#        * arm-linux-androideabi-4.9 (default)
+#        * arm-linux-androideabi-clang3.4
+#        * arm-linux-androideabi-clang3.5
+#        * mips64el-linux-android-4.9
+#        * mips64el-linux-android-clang3.4
+#        * mips64el-linux-android-clang3.5
 #        * mipsel-linux-android-4.6
-#        * mipsel-linux-android-clang3.1
-#        * x86-4.4.3
+#        * mipsel-linux-android-4.8
+#        * mipsel-linux-android-4.9
+#        * mipsel-linux-android-clang3.4
+#        * mipsel-linux-android-clang3.5
 #        * x86-4.6
-#        * x86-clang3.1
+#        * x86-4.8
+#        * x86-4.9
+#        * x86-clang3.4
+#        * x86-clang3.5
+#        * x86_64-4.9
+#        * x86_64-clang3.4
+#        * x86_64-clang3.5
 #
 #    ANDROID_FORCE_ARM_BUILD=OFF - set ON to generate 32-bit ARM instructions
 #      instead of Thumb. Is not available for "x86" (inapplicable) and
@@ -181,8 +196,9 @@
 #    ANDROID and BUILD_ANDROID will be set to true, you may test any of these
 #    variables to make necessary Android-specific configuration changes.
 #
-#    Also ARMEABI or ARMEABI_V7A or X86 or MIPS will be set true, mutually
-#    exclusive. NEON option will be set true if VFP is set to NEON.
+#    Also ARMEABI or ARMEABI_V7A or X86 or MIPS or ARM64_V8A or X86_64 or MIPS64
+#    will be set true, mutually exclusive. NEON option will be set true
+#    if VFP is set to NEON.
 #
 #    LIBRARY_OUTPUT_PATH_ROOT should be set in cache to determine where Android
 #    libraries will be installed.
@@ -190,117 +206,6 @@
 #    under the ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}
 #    (depending on the target ABI). This is convenient for Android packaging.
 #
-#  Change Log:
-#   - initial version December 2010
-#   - 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
-#     [+] added toolchain option to compile to 32-bit ARM instructions
-#     [+] added toolchain option to disable SWIG search
-#     [+] added platform "armeabi-v7a with VFPV3"
-#     [~] ARM_TARGETS renamed to ARM_TARGET
-#     [+] 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
-#   - 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
-#   - 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
-#     [-] removed SWIG-related stuff from toolchain
-#     [+] added macro find_host_package, find_host_program to search
-#         packages/programs on the host system
-#     [~] fixed path to STL library
-#   - July 2011
-#     [~] fixed options caching
-#     [~] search for all supported NDK versions
-#     [~] allowed spaces in NDK path
-#   - September 2011
-#     [~] updated for NDK r6b
-#   - November 2011
-#     [*] rewritten for NDK r7
-#     [+] x86 toolchain support (experimental)
-#     [+] added "armeabi-v6 with VFP" ABI for ARMv6 processors.
-#     [~] improved compiler and linker flags management
-#     [+] support different build flags for Release and Debug configurations
-#     [~] by default compiler flags the same as used by ndk-build (but only
-#         where reasonable)
-#     [~] ANDROID_NDK_TOOLCHAIN_ROOT is splitted to ANDROID_STANDALONE_TOOLCHAIN
-#         and ANDROID_TOOLCHAIN_ROOT
-#     [~] 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
-#   - 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
-#   - February 2012
-#     [+] updated for NDK r7b
-#     [~] fixed cmake try_compile() command
-#     [~] Fix for missing install_name_tool on OS X
-#   - 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
-#   - April 2012
-#     [+] updated for NDK r7c
-#     [~] fixed most of problems with compiler/linker flags and caching
-#     [+] added option ANDROID_FUNCTION_LEVEL_LINKING
-#   - May 2012
-#     [+] updated for NDK r8
-#     [+] added mips architecture support
-#   - August 2012
-#     [+] updated for NDK r8b
-#     [~] all intermediate files generated by toolchain are moved to CMakeFiles
-#     [~] libstdc++ and libsupc are removed from explicit link libraries
-#     [+] added CCache support (via NDK_CCACHE environment or cmake variable)
-#     [+] added gold linker support for NDK r8b
-#     [~] fixed mips linker flags for NDK r8b
-#   - September 2012
-#     [+] added NDK release name detection (see ANDROID_NDK_RELEASE)
-#     [+] added support for all C++ runtimes from NDK
-#         (system, gabi++, stlport, gnustl)
-#     [+] improved warnings on known issues of NDKs
-#     [~] use gold linker as default if available (NDK r8b)
-#     [~] globally turned off rpath
-#     [~] compiler options are aligned with NDK r8b
-#   - October 2012
-#     [~] fixed C++ linking: explicitly link with math library (OpenCV #2426)
-#   - November 2012
-#     [+] 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
-#   - July 2013
-#     [+] updated for NDK r9
-#   - November 2013
-#     [+] updated for NDK r9b
-#   - December 2013
-#     [+] updated for NDK r9c
-#   - January 2014
-#     [~] fix copying of shared STL
 # ------------------------------------------------------------------------------

 cmake_minimum_required( VERSION 2.6.3 )
@@ -311,23 +216,31 @@
 endif()

 if( CMAKE_TOOLCHAIN_FILE )
- # touch toolchain variable only to suppress "unused variable" warning
-endif()
-
+ # touch toolchain variable to suppress "unused variable" warning
+endif()
+
+# inherit settings in recursive loads
 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()

 # this one is important
-set( CMAKE_SYSTEM_NAME Linux )
+if( CMAKE_VERSION VERSION_GREATER "3.0.99" )
+ set( CMAKE_SYSTEM_NAME Android )
+else()
+ set( CMAKE_SYSTEM_NAME Linux )
+endif()
+
 # this one not so much
 set( CMAKE_SYSTEM_VERSION 1 )

 # rpath makes low sence for Android
+set( CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "" )
 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} -r9c -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
+# NDK search paths
+set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r10d -r10c -r10b -r10 -r9d -r9c -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
 if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS)
  if( CMAKE_HOST_WIN32 )
   file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS )
@@ -341,13 +254,21 @@
  set( ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH /opt/android-toolchain )
 endif()

+# known ABIs
 set( ANDROID_SUPPORTED_ABIS_arm "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" )
+set( ANDROID_SUPPORTED_ABIS_arm64 "arm64-v8a" )
 set( ANDROID_SUPPORTED_ABIS_x86 "x86" )
-set( ANDROID_SUPPORTED_ABIS_mipsel "mips" )
-
+set( ANDROID_SUPPORTED_ABIS_x86_64 "x86_64" )
+set( ANDROID_SUPPORTED_ABIS_mips "mips" )
+set( ANDROID_SUPPORTED_ABIS_mips64 "mips64" )
+
+# API level defaults
 set( ANDROID_DEFAULT_NDK_API_LEVEL 8 )
+set( ANDROID_DEFAULT_NDK_API_LEVEL_arm64 21 )
 set( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 )
+set( ANDROID_DEFAULT_NDK_API_LEVEL_x86_64 21 )
 set( ANDROID_DEFAULT_NDK_API_LEVEL_mips 9 )
+set( ANDROID_DEFAULT_NDK_API_LEVEL_mips64 21 )

 macro( __LIST_FILTER listvar regex )
@@ -423,7 +344,7 @@
 endmacro()

 macro( __DETECT_NATIVE_API_LEVEL _var _path )
- SET( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*$" )
+ SET( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*.*$" )
  FILE( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" )
  if( NOT __apiFileContent )
   message( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." )
@@ -535,12 +456,15 @@
  set( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" FORCE )
  set( BUILD_WITH_ANDROID_NDK True )
  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}" )
+  file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE_FULL LIMIT_COUNT 1 REGEX "r[0-9]+[a-z]?" )
+  string( REGEX MATCH "r([0-9]+)([a-z]?)" ANDROID_NDK_RELEASE "${ANDROID_NDK_RELEASE_FULL}" )
  else()
   set( ANDROID_NDK_RELEASE "r1x" )
   set( ANDROID_NDK_RELEASE_FULL "unreleased" )
  endif()
+ string( REGEX REPLACE "r([0-9]+)([a-z]?)" "\\1*1000" ANDROID_NDK_RELEASE_NUM "${ANDROID_NDK_RELEASE}" )
+ string( FIND " abcdefghijklmnopqastuvwxyz" "${CMAKE_MATCH_2}" __ndkReleaseLetterNum )
+ math( EXPR ANDROID_NDK_RELEASE_NUM "${ANDROID_NDK_RELEASE_NUM}+${__ndkReleaseLetterNum}" )
 elseif( ANDROID_STANDALONE_TOOLCHAIN )
  get_filename_component( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE )
  # try to detect change
@@ -621,12 +545,18 @@
  if( NOT __availableToolchainMachines )
   message( FATAL_ERROR "Could not determine machine name of your toolchain. Probably your Android standalone toolchain is broken." )
  endif()
- if( __availableToolchainMachines MATCHES i686 )
+ if( __availableToolchainMachines MATCHES x86_64 )
+  set( __availableToolchainArchs "x86_64" )
+ elseif( __availableToolchainMachines MATCHES i686 )
   set( __availableToolchainArchs "x86" )
+ elseif( __availableToolchainMachines MATCHES aarch64 )
+  set( __availableToolchainArchs "arm64" )
  elseif( __availableToolchainMachines MATCHES arm )
   set( __availableToolchainArchs "arm" )
+ elseif( __availableToolchainMachines MATCHES mips64el )
+  set( __availableToolchainArchs "mips64" )
  elseif( __availableToolchainMachines MATCHES mipsel )
-  set( __availableToolchainArchs "mipsel" )
+  set( __availableToolchainArchs "mips" )
  endif()
  execute_process( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" -dumpversion
                   OUTPUT_VARIABLE __availableToolchainCompilerVersions OUTPUT_STRIP_TRAILING_WHITESPACE )
@@ -642,24 +572,44 @@
 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}" )
+   SET( __toolchainVersionRegex "^TOOLCHAIN_VERSION[\t ]+:=[\t ]+(.*)$" )
+   FILE( STRINGS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}/setup.mk" __toolchainVersionStr REGEX "${__toolchainVersionRegex}" )
+   if( __toolchainVersionStr )
+    string( REGEX REPLACE "${__toolchainVersionRegex}" "\\1" __toolchainVersionStr "${__toolchainVersionStr}" )
+    string( REGEX REPLACE "-clang3[.][0-9]$" "-${__toolchainVersionStr}" __gcc_toolchain "${__toolchain}" )
+   else()
+    string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" )
+   endif()
+   unset( __toolchainVersionStr )
+   unset( __toolchainVersionRegex )
   else()
    set( __gcc_toolchain "${__toolchain}" )
   endif()
   __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" )
   if( __machine )
    string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" )
-   if( __machine MATCHES i686 )
+   if( __machine MATCHES x86_64 )
+    set( __arch "x86_64" )
+   elseif( __machine MATCHES i686 )
     set( __arch "x86" )
+   elseif( __machine MATCHES aarch64 )
+    set( __arch "arm64" )
    elseif( __machine MATCHES arm )
     set( __arch "arm" )
+   elseif( __machine MATCHES mips64el )
+    set( __arch "mips64" )
    elseif( __machine MATCHES mipsel )
-    set( __arch "mipsel" )
+    set( __arch "mips" )
+   else()
+    set( __arch "" )
    endif()
-   list( APPEND __availableToolchainMachines "${__machine}" )
-   list( APPEND __availableToolchainArchs "${__arch}" )
-   list( APPEND __availableToolchainCompilerVersions "${__version}" )
-   list( APPEND ${__availableToolchainsVar} "${__toolchain}" )
+   #message("machine: !${__machine}!\narch: !${__arch}!\nversion: !${__version}!\ntoolchain: !${__toolchain}!\n")
+   if (__arch)
+    list( APPEND __availableToolchainMachines "${__machine}" )
+    list( APPEND __availableToolchainArchs "${__arch}" )
+    list( APPEND __availableToolchainCompilerVersions "${__version}" )
+    list( APPEND ${__availableToolchainsVar} "${__toolchain}" )
+   endif()
   endif()
   unset( __gcc_toolchain )
  endforeach()
@@ -735,28 +685,45 @@
  set( X86 true )
  set( ANDROID_NDK_ABI_NAME "x86" )
  set( ANDROID_ARCH_NAME "x86" )
- set( ANDROID_ARCH_FULLNAME "x86" )
  set( ANDROID_LLVM_TRIPLE "i686-none-linux-android" )
  set( CMAKE_SYSTEM_PROCESSOR "i686" )
+elseif( ANDROID_ABI STREQUAL "x86_64" )
+ set( X86 true )
+ set( X86_64 true )
+ set( ANDROID_NDK_ABI_NAME "x86_64" )
+ set( ANDROID_ARCH_NAME "x86_64" )
+ set( CMAKE_SYSTEM_PROCESSOR "x86_64" )
+ set( ANDROID_LLVM_TRIPLE "x86_64-none-linux-android" )
+elseif( ANDROID_ABI STREQUAL "mips64" )
+ set( MIPS64 true )
+ set( ANDROID_NDK_ABI_NAME "mips64" )
+ set( ANDROID_ARCH_NAME "mips64" )
+ set( ANDROID_LLVM_TRIPLE "mips64el-none-linux-android" )
+ set( CMAKE_SYSTEM_PROCESSOR "mips64" )
 elseif( ANDROID_ABI STREQUAL "mips" )
  set( MIPS true )
  set( ANDROID_NDK_ABI_NAME "mips" )
  set( ANDROID_ARCH_NAME "mips" )
- set( ANDROID_ARCH_FULLNAME "mipsel" )
  set( ANDROID_LLVM_TRIPLE "mipsel-none-linux-android" )
  set( CMAKE_SYSTEM_PROCESSOR "mips" )
+elseif( ANDROID_ABI STREQUAL "arm64-v8a" )
+ set( ARM64_V8A true )
+ set( ANDROID_NDK_ABI_NAME "arm64-v8a" )
+ set( ANDROID_ARCH_NAME "arm64" )
+ set( ANDROID_LLVM_TRIPLE "aarch64-none-linux-android" )
+ set( CMAKE_SYSTEM_PROCESSOR "aarch64" )
+ set( VFPV3 true )
+ set( NEON true )
 elseif( ANDROID_ABI STREQUAL "armeabi" )
  set( ARMEABI true )
  set( ANDROID_NDK_ABI_NAME "armeabi" )
  set( ANDROID_ARCH_NAME "arm" )
- set( ANDROID_ARCH_FULLNAME "arm" )
  set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" )
  set( CMAKE_SYSTEM_PROCESSOR "armv5te" )
 elseif( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" )
  set( ARMEABI_V6 true )
  set( ANDROID_NDK_ABI_NAME "armeabi" )
  set( ANDROID_ARCH_NAME "arm" )
- set( ANDROID_ARCH_FULLNAME "arm" )
  set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" )
  set( CMAKE_SYSTEM_PROCESSOR "armv6" )
  # need always fallback to older platform
@@ -765,14 +732,12 @@
  set( ARMEABI_V7A true )
  set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
  set( ANDROID_ARCH_NAME "arm" )
- set( ANDROID_ARCH_FULLNAME "arm" )
  set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
  set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
 elseif( ANDROID_ABI STREQUAL "armeabi-v7a with VFPV3" )
  set( ARMEABI_V7A true )
  set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
  set( ANDROID_ARCH_NAME "arm" )
- set( ANDROID_ARCH_FULLNAME "arm" )
  set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
  set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
  set( VFPV3 true )
@@ -780,7 +745,6 @@
  set( ARMEABI_V7A true )
  set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
  set( ANDROID_ARCH_NAME "arm" )
- set( ANDROID_ARCH_FULLNAME "arm" )
  set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
  set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
  set( VFPV3 true )
@@ -814,7 +778,7 @@
 To configure the toolchain set CMake variable ANDROID_TOOLCHAIN_NAME to one of the following values:\n${toolchains_list}\n" )
  endif()
  list( GET __availableToolchainArchs ${__toolchainIdx} __toolchainArch )
- if( NOT __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
+ if( NOT __toolchainArch STREQUAL ANDROID_ARCH_NAME )
   message( SEND_ERROR "Selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." )
  endif()
 else()
@@ -825,7 +789,7 @@
  math( EXPR __availableToolchainsCount "${__availableToolchainsCount}-1" )
  foreach( __idx RANGE ${__availableToolchainsCount} )
   list( GET __availableToolchainArchs ${__idx} __toolchainArch )
-  if( __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
+  if( __toolchainArch STREQUAL ANDROID_ARCH_NAME )
    list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion )
    string( REPLACE "x" "99" __toolchainVersion "${__toolchainVersion}")
    if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion )
@@ -854,15 +818,16 @@

 # 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}" )
+string( REPLACE "android-" "" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
+string( STRIP "${ANDROID_NATIVE_API_LEVEL}" ANDROID_NATIVE_API_LEVEL )
 # 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 )
+ if( (__level LESS ANDROID_NATIVE_API_LEVEL OR __level STREQUAL 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 )
+if( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL STREQUAL __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()
@@ -874,7 +839,7 @@
 else()
  if( BUILD_WITH_ANDROID_NDK )
   __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
-  if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL )
+  if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL AND NOT __realApiLevel GREATER 9000 )
    message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
   endif()
   unset( __realApiLevel )
@@ -891,8 +856,8 @@
 # remember target ABI
 set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE )
 if( CMAKE_VERSION VERSION_GREATER "2.8" )
- list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME} )
- set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} )
+ list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME} )
+ set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME}} )
 endif()

@@ -1034,7 +999,7 @@
  string( REGEX MATCH "[0-9]+[.][0-9]+" ANDROID_CLANG_VERSION "${ANDROID_CLANG_VERSION}")
 elseif( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" )
  string( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}")
- string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-4.6" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
+ string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-${ANDROID_COMPILER_VERSION}" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
  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()
@@ -1067,7 +1032,7 @@
   set( ANDROID_EXCEPTIONS       ON )
   set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" )
  elseif( ANDROID_STL MATCHES "gabi" )
-  if( ANDROID_NDK_RELEASE STRLESS "r7" )
+  if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7
    message( FATAL_ERROR "gabi++ is not awailable in your NDK. You have to upgrade to NDK r7 or newer to use gabi++.")
   endif()
   set( ANDROID_RTTI             ON )
@@ -1075,12 +1040,12 @@
   set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/gabi++/include" )
   set( __libstl                 "${ANDROID_NDK}/sources/cxx-stl/gabi++/libs/${ANDROID_NDK_ABI_NAME}/libgabi++_static.a" )
  elseif( ANDROID_STL MATCHES "stlport" )
-  if( NOT ANDROID_NDK_RELEASE STRLESS "r8d" )
+  if( NOT ANDROID_NDK_RELEASE_NUM LESS 8004 ) # before r8d
    set( ANDROID_EXCEPTIONS       ON )
   else()
    set( ANDROID_EXCEPTIONS       OFF )
   endif()
-  if( ANDROID_NDK_RELEASE STRLESS "r7" )
+  if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7
    set( ANDROID_RTTI            OFF )
   else()
    set( ANDROID_RTTI            ON )
@@ -1101,7 +1066,7 @@
   else()
    set( __libstl                "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++" )
   endif()
-  set( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" )
+  set( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" "${__libstl}/include/backward" )
   if( EXISTS "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" )
    set( __libstl                "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" )
   else()
@@ -1203,10 +1168,14 @@
 include( CMakeForceCompiler )
 CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
 if( ANDROID_COMPILER_IS_CLANG )
- set( CMAKE_C_COMPILER_ID Clang)
+ set( CMAKE_C_COMPILER_ID Clang )
 endif()
 set( CMAKE_C_PLATFORM_ID Linux )
-set( CMAKE_C_SIZEOF_DATA_PTR 4 )
+if( X86_64 OR MIPS64 OR ARM64_V8A )
+ set( CMAKE_C_SIZEOF_DATA_PTR 8 )
+else()
+ set( CMAKE_C_SIZEOF_DATA_PTR 4 )
+endif()
 set( CMAKE_C_HAS_ISYSROOT 1 )
 set( CMAKE_C_COMPILER_ABI ELF )
 CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU )
@@ -1214,7 +1183,7 @@
  set( CMAKE_CXX_COMPILER_ID Clang)
 endif()
 set( CMAKE_CXX_PLATFORM_ID Linux )
-set( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
+set( CMAKE_CXX_SIZEOF_DATA_PTR ${CMAKE_C_SIZEOF_DATA_PTR} )
 set( CMAKE_CXX_HAS_ISYSROOT 1 )
 set( CMAKE_CXX_COMPILER_ABI ELF )
 set( CMAKE_CXX_SOURCE_FILE_EXTENSIONS cc cp cxx cpp CPP c++ C )
@@ -1225,6 +1194,14 @@
 set( CMAKE_ASM_COMPILER_FORCED TRUE )
 set( CMAKE_COMPILER_IS_GNUASM 1)
 set( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s S asm )
+
+foreach( lang C CXX ASM )
+ if( ANDROID_COMPILER_IS_CLANG )
+  set( CMAKE_${lang}_COMPILER_VERSION ${ANDROID_CLANG_VERSION} )
+ else()
+  set( CMAKE_${lang}_COMPILER_VERSION ${ANDROID_COMPILER_VERSION} )
+ endif()
+endforeach()

 # flags and definitions
 remove_definitions( -DANDROID )
@@ -1255,8 +1232,15 @@
 endif()

 # NDK flags
-if( ARMEABI OR ARMEABI_V7A )
- set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -funwind-tables" )
+if (ARM64_V8A )
+ set( ANDROID_CXX_FLAGS         "${ANDROID_CXX_FLAGS} -ffunction-sections -funwind-tables" )
+ set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" )
+ set( ANDROID_CXX_FLAGS_DEBUG   "-fno-omit-frame-pointer -fno-strict-aliasing" )
+ if( NOT ANDROID_COMPILER_IS_CLANG )
+  set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -funswitch-loops -finline-limit=300" )
+ endif()
+elseif( ARMEABI OR ARMEABI_V7A)
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" )
  if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 )
   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" )
@@ -1271,17 +1255,15 @@
    set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" )
   endif()
  endif()
-elseif( X86 )
+elseif( X86 OR X86_64 )
  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 -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0" )
+elseif( MIPS OR MIPS64 )
+ set( ANDROID_CXX_FLAGS         "${ANDROID_CXX_FLAGS} -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 )
@@ -1359,7 +1341,7 @@
 endif()

 # variables controlling optional build flags
-if (ANDROID_NDK_RELEASE STRLESS "r7")
+if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7
  # libGLESv2.so in NDK's prior to r7 refers to missing external symbols.
  # So this flag option is required for all projects using OpenGL from native.
  __INIT_VARIABLE( ANDROID_SO_UNDEFINED                      VALUES ON )
@@ -1375,7 +1357,7 @@
 set( ANDROID_NO_UNDEFINED           ${ANDROID_NO_UNDEFINED}           CACHE BOOL "Show all undefined symbols as linker errors" )
 set( ANDROID_SO_UNDEFINED           ${ANDROID_SO_UNDEFINED}           CACHE BOOL "Allows or disallows undefined symbols in shared libraries" )
 set( ANDROID_FUNCTION_LEVEL_LINKING ${ANDROID_FUNCTION_LEVEL_LINKING} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" )
-set( ANDROID_GOLD_LINKER            ${ANDROID_GOLD_LINKER}            CACHE BOOL "Enables gold linker (only avaialble for NDK r8b for ARM and x86 architectures on linux-86 and darwin-x86 hosts)" )
+set( ANDROID_GOLD_LINKER            ${ANDROID_GOLD_LINKER}            CACHE BOOL "Enables gold linker" )
 set( ANDROID_NOEXECSTACK            ${ANDROID_NOEXECSTACK}            CACHE BOOL "Allows or disallows undefined symbols in shared libraries" )
 set( ANDROID_RELRO                  ${ANDROID_RELRO}                  CACHE BOOL "Enables RELRO - a memory corruption mitigation technique" )
 mark_as_advanced( ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_FUNCTION_LEVEL_LINKING ANDROID_GOLD_LINKER ANDROID_NOEXECSTACK ANDROID_RELRO )
@@ -1410,9 +1392,9 @@
 endif()

 if( ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" )
- if( ANDROID_GOLD_LINKER AND (CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE STRGREATER "r8b") AND (ARMEABI OR ARMEABI_V7A OR X86) )
+ if( ANDROID_GOLD_LINKER AND (CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE_NUM GREATER 8002) AND (ARMEABI OR ARMEABI_V7A OR X86) )
   set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" )
- elseif( ANDROID_NDK_RELEASE STRGREATER "r8b")
+ elseif( ANDROID_NDK_RELEASE_NUM GREATER 8002 ) # after r8b
   set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=bfd" )
  elseif( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND NOT _CMAKE_IN_TRY_COMPILE )
   message( WARNING "The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342
@@ -1436,13 +1418,7 @@
 endif()

 if( ANDROID_COMPILER_IS_CLANG )
- set( ANDROID_CXX_FLAGS "-Qunused-arguments ${ANDROID_CXX_FLAGS}" )
- if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD )
-  set( ANDROID_CXX_FLAGS_RELEASE "-target thumbv7-none-linux-androideabi ${ANDROID_CXX_FLAGS_RELEASE}" )
-  set( ANDROID_CXX_FLAGS_DEBUG   "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS_DEBUG}" )
- else()
-  set( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS}" )
- endif()
+ set( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} -Qunused-arguments ${ANDROID_CXX_FLAGS}" )
  if( BUILD_WITH_ANDROID_NDK )
   set( ANDROID_CXX_FLAGS "-gcc-toolchain ${ANDROID_TOOLCHAIN_ROOT} ${ANDROID_CXX_FLAGS}" )
  endif()
@@ -1480,6 +1456,16 @@
  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()
+
+# pie/pic
+if( NOT (ANDROID_NATIVE_API_LEVEL LESS 16) AND (NOT DEFINED ANDROID_APP_PIE OR ANDROID_APP_PIE) AND (CMAKE_VERSION VERSION_GREATER 2.8.8) )
+ set( CMAKE_POSITION_INDEPENDENT_CODE TRUE )
+ set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie")
+else()
+ set( CMAKE_POSITION_INDEPENDENT_CODE FALSE )
+ set( CMAKE_CXX_FLAGS "-fpic ${CMAKE_CXX_FLAGS}" )
+ set( CMAKE_C_FLAGS   "-fpic ${CMAKE_C_FLAGS}" )
 endif()

 # configure rtti
@@ -1663,6 +1649,7 @@
                 ANDROID_RELRO
                 ANDROID_LIBM_PATH
                 ANDROID_EXPLICIT_CRT_LINK
+                ANDROID_APP_PIE
                 )
   if( DEFINED ${__var} )
    if( "${__var}" MATCHES " ")
@@ -1701,8 +1688,8 @@

 # Variables controlling behavior or set by cmake toolchain:
-#   ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips"
-#   ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14 (depends on NDK version)
+#   ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips", "arm64-v8a", "x86_64", "mips64"
+#   ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14,15,16,17,18,19,21 (depends on NDK version)
 #   ANDROID_STL : gnustl_static/gnustl_shared/stlport_static/stlport_shared/gabi++_static/gabi++_shared/system_re/system/none
 #   ANDROID_FORBID_SYGWIN : ON/OFF
 #   ANDROID_NO_UNDEFINED : ON/OFF
@@ -1735,17 +1722,21 @@
 #   ARMEABI : TRUE for arm v6 and older devices
 #   ARMEABI_V6 : TRUE for arm v6
 #   ARMEABI_V7A : TRUE for arm v7a
+#   ARM64_V8A : TRUE for arm64-v8a
 #   NEON : TRUE if NEON unit is enabled
 #   VFPV3 : TRUE if VFP version 3 is enabled
 #   X86 : TRUE if configured for x86
+#   X86_64 : TRUE if configured for x86_64
 #   MIPS : TRUE if configured for mips
+#   MIPS64 : TRUE if configured for mips64
 #   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" 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, r9, r9b, r9c; set only for NDK
-#   ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI
+#   ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "x86", "mips", "arm64-v8a", "x86_64", "mips64" depending on ANDROID_ABI
+#   ANDROID_NDK_RELEASE : from r5 to r10d; set only for NDK
+#   ANDROID_NDK_RELEASE_NUM : numeric ANDROID_NDK_RELEASE version (1000*major+minor)
+#   ANDROID_ARCH_NAME : "arm", "x86", "mips", "arm64", "x86_64", "mips64" depending on ANDROID_ABI
 #   ANDROID_SYSROOT : path to the compiler sysroot
 #   TOOL_OS_SUFFIX : "" or ".exe" depending on host platform
 #   ANDROID_COMPILER_IS_CLANG : TRUE if clang compiler is used
@@ -1753,7 +1744,8 @@
 #   ARMEABI_NDK_NAME : superseded by ANDROID_NDK_ABI_NAME
 #
 # Secondary (less stable) read-only variables:
-#   ANDROID_COMPILER_VERSION : GCC version used
+#   ANDROID_COMPILER_VERSION : GCC version used (not Clang version)
+#   ANDROID_CLANG_VERSION : version of clang compiler if clang is used
 #   ANDROID_CXX_FLAGS : C/C++ compiler flags required by Android platform
 #   ANDROID_SUPPORTED_ABIS : list of currently allowed values for ANDROID_ABI
 #   ANDROID_TOOLCHAIN_MACHINE_NAME : "arm-linux-androideabi", "arm-eabi" or "i686-android-linux"
@@ -1764,7 +1756,6 @@
 #   ANDROID_RTTI : if rtti is enabled by the runtime
 #   ANDROID_EXCEPTIONS : if exceptions are enabled by the runtime
 #   ANDROID_GCC_TOOLCHAIN_NAME : read-only, differs from ANDROID_TOOLCHAIN_NAME only if clang is used
-#   ANDROID_CLANG_VERSION : version of clang compiler if clang is used
 #   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:


Bake templates into the compiler binary

Bake templates into the compiler binary

Summary: [Thrift] Bake templates into the compiler binary rather than having to package the templates with the compiler.

Reviewed By: stevegury, vitaut

Differential Revision: D16356056

fbshipit-source-id: b971dce7aada8dc2a26587fbf818e661acd0c555

--- build/fbcode_builder/CMake/FBThriftCppLibrary.cmake
+++ build/fbcode_builder/CMake/FBThriftCppLibrary.cmake
@@ -99,10 +99,6 @@
     thrift_include_options
     "-I;$<JOIN:$<TARGET_PROPERTY:${LIB_NAME}.thrift_includes,INTERFACE_INCLUDE_DIRECTORIES>,;-I;>"
   )
-  file(
-    GLOB_RECURSE THRIFT_TEMPLATE_FILES
-    FOLLOW_SYMLINKS "${FBTHRIFT_TEMPLATES_DIR}/cpp2/*.mustache"
-  )

   # Emit the rule to run the thrift compiler
   add_custom_command(
@@ -115,7 +111,6 @@
     COMMAND
       "${FBTHRIFT_COMPILER}"
       --strict
-      --templates "${FBTHRIFT_TEMPLATES_DIR}"
       --gen "mstch_cpp2:${GEN_ARG_STR}"
       "${thrift_include_options}"
       -o "${output_dir}"


Use ExternalData download for lua source

Change-Id: If14482e4532043c0215f3106773cd567f7ce9c05

--- SuperBuild/External_Lua.cmake
+++ SuperBuild/External_Lua.cmake
@@ -7,11 +7,16 @@

 set(proj Lua)

+set(lua_TARGET_VERSION 5.1.5)
+set(lua_DOWNLOAD_SOURCE_HASH "2e115fe26e435e33b0d5c022e4490567")
+
+
 # follow the standard EP_PREFIX locations
 set(lua_binary_dir ${CMAKE_CURRENT_BINARY_DIR}/${proj}-prefix/src/${proj}-build)
 set(lua_source_dir ${CMAKE_CURRENT_BINARY_DIR}/${proj}-prefix/src/${proj})
 set(lua_install_dir ${CMAKE_CURRENT_BINARY_DIR}/${proj})
-set(lua_URL "https://www.lua.org/ftp/lua-5.1.5.tar.gz")
+sitkSourceDownload(lua_URL "lua-${lua_TARGET_VERSION}.tar.gz" ${lua_DOWNLOAD_SOURCE_HASH})
+

 file(WRITE "${lua_binary_dir}/CMakeCacheInit.txt" "${ep_common_cache}" )

@@ -22,7 +27,7 @@

 ExternalProject_Add(Lua
   URL "${lua_URL}"
-  URL_MD5 2e115fe26e435e33b0d5c022e4490567
+  URL_MD5 "${lua_DOWNLOAD_SOURCE_HASH}"
   PATCH_COMMAND ${lua_PATCH_COMMAND}
   CMAKE_GENERATOR ${gen}
   CMAKE_ARGS
@@ -32,4 +37,9 @@
     -D BUILD_SHARED_LIBS:BOOL=OFF
     -D CMAKE_INSTALL_PREFIX:PATH=${lua_install_dir}
 )
+
+# the ExternalProject_Add DEPENDS options is not effective for the DOWNLOAD STEP
+add_dependencies( Lua  "SuperBuildSimpleITKSource" )
+
+
 set(SITK_LUA_EXECUTABLE  "${lua_install_dir}/bin/lua")


ENH: Bump ITK superbuild to 4.3.1.

ENH: Bump ITK superbuild to 4.3.1.

Latest stable tag.

Change-Id: Ib44ab82752ebdbb763683e1ba82bb700063cf809

--- Superbuild/External-ITK.cmake
+++ Superbuild/External-ITK.cmake
@@ -2,7 +2,7 @@
 # Get and build itk

 if( NOT ITK_TAG )
-  set( ITK_TAG "v4.2.1" )
+  set( ITK_TAG "v4.3.1" )
 endif()

 ExternalProject_Add( ITK


Split off 7.12.90

Split off 7.12.90

Signed-off-by: Richard Chapman <5900d56196fe29dba8e3ae556d57eae28e9f0195@hpccsystems.com>

--- version.cmake
+++ version.cmake
@@ -5,7 +5,7 @@
 set ( HPCC_PROJECT "nagios-monitoring" )
 set ( HPCC_MAJOR 7 )
 set ( HPCC_MINOR 12 )
-set ( HPCC_POINT 89 )
+set ( HPCC_POINT 91 )
 set ( HPCC_MATURITY "closedown" )
 set ( HPCC_SEQUENCE 0 )
 ###


Graph Control 6.0.2-1 Gold

Graph Control 6.0.2-1 Gold

Signed-off-by: Richard Chapman <5900d56196fe29dba8e3ae556d57eae28e9f0195@hpccsystems.com>

--- version.cmake
+++ version.cmake
@@ -5,7 +5,7 @@
 set ( HPCC_MAJOR 6 )
 set ( HPCC_MINOR 0 )
 set ( HPCC_POINT 2 )
-set ( HPCC_MATURITY "rc" )
+set ( HPCC_MATURITY "release" )
 set ( HPCC_SEQUENCE 1 )
 ###
 IF ( ${HPCC_POINT} GREATER 65 )


only print missing pks if pkgs are actually missing

Change-Id: Ic16968d7edbe4c8b9af4d6e4d4d9953c48c893cb

--- VAD_HendriksWrappers.cmake
+++ VAD_HendriksWrappers.cmake
@@ -118,12 +118,13 @@
       endif()
     endforeach()

-    message("missings PKGs: ")
-    foreach(PKG ${_VAD_AUTODEP_MISSING_PKGS})
-      message("  - ${PKG} (required by ${_VAD_AUTODEP_REQ_${PKG}})")
-      option(VAD_BUILD_${PKG}_FROM_GIT "integrate LIVE source into project" off)
-    endforeach()
     if (_VAD_AUTODEP_MISSING_PKGS)
+      message("missings PKGs: ")
+      foreach(PKG ${_VAD_AUTODEP_MISSING_PKGS})
+        message("  - ${PKG} (required by ${_VAD_AUTODEP_REQ_${PKG}})")
+        option(VAD_BUILD_${PKG}_FROM_GIT "integrate LIVE source into project" off)
+      endforeach()
+
       #cleanup
       set(_VAD_AUTODEP_MISSING_PKGS "" CACHE STRING "" FORCE)


removed a superfluous extremely long running test

--- tests/package/project_tests/scenarios/test_repos_bitbucket_test.cmake
+++ tests/package/project_tests/scenarios/test_repos_bitbucket_test.cmake
@@ -1,37 +0,0 @@
-function(test)
-
-  project_open()
-  ans(project)
-
-  assign(project.project_descriptor.package_source = default_package_source())
-
-
-  project_close(${project})
-
-
-  project_open()
-  ans(project)
-
-  project_change_dependencies(${project}
-    "bitbucket:toeb/test_repo_hg"
-    "bitbucket:toeb/test_repo_git"
-    "github:toeb/cmakepp"
-    "svnscm+https://github.com/toeb/cmakepp"
-    "gitscm:git@github.com:toeb/cppdynamic.git"
-    "https://github.com/toeb/libarchive/archive/v3.1.2.tar.gz"
-   )
-  ans(res)
-  json_print(${res})
-
-  project_close(${project})
-
-  project_open()
-  ans(project)
-
-
-  project_materialize_dependencies(${project})
-  ans(res)
-
-
-
-endfunction()


Removed setting .pyd extension (not needed and actually breaks on unix)

--- tools/cmake/ANHPythonBinding.cmake
+++ tools/cmake/ANHPythonBinding.cmake
@@ -108,8 +108,7 @@
     SET_TARGET_PROPERTIES(${name}
         PROPERTIES OUTPUT_NAME py_${base_name}
         LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
-        PREFIX ""
-        SUFFIX ".pyd")
+        PREFIX "")

     IF(_project_deps_list_length GREATER 0)
         ADD_DEPENDENCIES(${name} ${ANHPYTHONLIB_DEPENDS})


Corrected cmake log message (#197)

Corrected cmake log message (#197)

--- Options.cmake
+++ Options.cmake
@@ -75,7 +75,7 @@
 IF(G3_SHARED_LIB)
    MESSAGE("-DG3_SHARED_LIB=ON\tBuild shared library")
 ELSE()
-   MESSAGE("-DG3_SHARED_LIB=ON\tBuild static library")
+   MESSAGE("-DG3_SHARED_LIB=OFF\tBuild static library")
 ENDIF()

 # WINDOWS OPTIONS


Update SimpleITK Superbuild version to 4.13.2

--- SuperBuild/External_ITK.cmake
+++ SuperBuild/External_ITK.cmake
@@ -52,7 +52,7 @@
 mark_as_advanced(ITK_GIT_REPOSITORY)
 sitk_legacy_naming(ITK_GIT_REPOSITORY ITK_REPOSITORY)

-set(ITK_GIT_TAG "8bbd7e7ac6ee71932bfb4b00a34c70f1ac02f7e7" CACHE
+set(ITK_GIT_TAG "v4.13.2" CACHE
   STRING "Tag in ITK git repo") # release-4.13
 mark_as_advanced(ITK_GIT_TAG)
 set(ITK_TAG_COMMAND GIT_TAG "${ITK_GIT_TAG}")


ENH: Bump ITK External Project version to v5.1.0

--- Superbuild/External-ITK.cmake
+++ Superbuild/External-ITK.cmake
@@ -2,7 +2,7 @@
 # Get and build itk

 if(NOT ITK_TAG)
-  set(ITK_TAG "v5.1rc02")
+  set(ITK_TAG "v5.1.0")
 endif()

 set(_vtk_args)


Remove unneccessary message

Remove unneccessary message

--- cmake-modules/FindYder.cmake
+++ cmake-modules/FindYder.cmake
@@ -48,9 +48,7 @@
 elseif (YDER_INCLUDE_DIR AND EXISTS "${YDER_INCLUDE_DIR}/yder.h")
     set(regex_yder_version "^#define[ \t]+YDER_VERSION[ \t]+([^\"]+).*")
     file(STRINGS "${YDER_INCLUDE_DIR}/yder.h" yder_version REGEX "${regex_yder_version}")
-		MESSAGE("found " ${yder_version})
     string(REGEX REPLACE "${regex_yder_version}" "\\1" YDER_VERSION_STRING "${yder_version}")
-		MESSAGE("regex found " ${YDER_VERSION_STRING})
     unset(regex_yder_version)
     unset(yder_version)
 endif ()


FIX: Ensure cmake vars are expanded correctly so right libname is used.

--- cmake/CEGUIFindHelpers.cmake
+++ cmake/CEGUIFindHelpers.cmake
@@ -36,7 +36,7 @@
         string(TOUPPER "${_L}" _UL)
         find_library(${_UL}_LIBRARY${_LIBS_VAR_EXT} NAMES ${_L} HINTS ${PC_${_PREFIX}_LIBDIR} ${PC_${_PREFIX}${_STATIC}_LIBRARY_DIRS} PATH_SUFFIXES ${_PATH_SUFFIXES})
         if(${_UL}_LIBRARY${_LIBS_VAR_EXT})
-            list(APPEND ${_PREFIX}_LIBRARIES${_LIBS_VAR_EXT} ${${_UL}_LIBRARY}${_LIBS_VAR_EXT})
+            list(APPEND ${_PREFIX}_LIBRARIES${_LIBS_VAR_EXT} ${${_UL}_LIBRARY${_LIBS_VAR_EXT}})
         else()
             set(${_PREFIX}_FOUND_ALL_LIBS${_LIBS_VAR_EXT} FALSE)
         endif()