[CMAKE] Fix scope issue in the remove_<lang>_compiler_flags() functions

Summary:
The `CMAKE_<LANG>_FLAGS` where not propagated to the parent scope.
The configuration specific variables were correctly scoped if a
configuration is defined, which is our default, but invalid if unset.

Test Plan:
  ninja check

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D4584

--- cmake/modules/AddCompilerFlags.cmake
+++ cmake/modules/AddCompilerFlags.cmake
@@ -51,20 +51,22 @@

 function(remove_c_compiler_flags)
 	remove_compiler_flags_from_var(CMAKE_C_FLAGS ${ARGN})
+	set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} PARENT_SCOPE)
 	if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
 		string(TOUPPER "CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}" BUILD_TYPE_FLAGS)
 		remove_compiler_flags_from_var(${BUILD_TYPE_FLAGS} ${ARGN})
+		set(${BUILD_TYPE_FLAGS} ${${BUILD_TYPE_FLAGS}} PARENT_SCOPE)
 	endif()
-	set(${BUILD_TYPE_FLAGS} ${${BUILD_TYPE_FLAGS}} PARENT_SCOPE)
 endfunction()

 function(remove_cxx_compiler_flags)
 	remove_compiler_flags_from_var(CMAKE_CXX_FLAGS ${ARGN})
+	set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} PARENT_SCOPE)
 	if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
 		string(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" BUILD_TYPE_FLAGS)
 		remove_compiler_flags_from_var(${BUILD_TYPE_FLAGS} ${ARGN})
+		set(${BUILD_TYPE_FLAGS} ${${BUILD_TYPE_FLAGS}} PARENT_SCOPE)
 	endif()
-	set(${BUILD_TYPE_FLAGS} ${${BUILD_TYPE_FLAGS}} PARENT_SCOPE)
 endfunction()

 macro(remove_compiler_flags)


Fix for ROOT-8032 - minimal/gminimal use CACHE FORCE OFF on core build features

--- cmake/modules/RootBuildOptions.cmake
+++ cmake/modules/RootBuildOptions.cmake
@@ -3,14 +3,24 @@
 #---------------------------------------------------------------------------------------------------
 #---ROOT_BUILD_OPTION( name defvalue [description] )
 #---------------------------------------------------------------------------------------------------
-function(ROOT_BUILD_OPTION name defvalue)
+function(ROOT_BUILD_OPTION opt defvalue)
   if(ARGN)
     set(description ${ARGN})
   else()
     set(description " ")
-  endif()
-  option(${name} "${description}" ${defvalue})
-  set(root_build_options ${root_build_options} ${name} PARENT_SCOPE )
+  endif()
+  set(${opt}_defvalue    ${defvalue} PARENT_SCOPE)
+  set(${opt}_description ${description} PARENT_SCOPE)
+  set(root_build_options  ${root_build_options} ${opt} PARENT_SCOPE )
+endfunction()
+
+#---------------------------------------------------------------------------------------------------
+#---ROOT_APPLY_OPTIONS()
+#---------------------------------------------------------------------------------------------------
+function(ROOT_APPLY_OPTIONS)
+  foreach(opt ${root_build_options})
+     option(${opt} "${${opt}_description}" ${${opt}_defvalue})
+  endforeach()
 endfunction()

 #---------------------------------------------------------------------------------------------------
@@ -44,61 +54,11 @@
   endforeach()
 endfunction()

-#---Define default values depending on platform before the options are defined----------------------
-if(WIN32)
-  set(x11_defvalue OFF)
-  set(memstat_defvalue OFF)
-  set(explicitlink_defvalue ON)
-  set(cocoa_defvalue OFF)
-  set(davix_defvalue OFF)
-elseif(APPLE)
-  execute_process(COMMAND sw_vers "-productVersion" COMMAND cut -d . -f 1-2
-                  OUTPUT_VARIABLE MACOSX_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
-  set(memstat_defvalue ON)
-  set(explicitlink_defvalue ON)
-  if(MACOSX_VERSION VERSION_GREATER 10.7 AND ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
-    set(x11_defvalue OFF)
-    set(cocoa_defvalue ON)
-  else()
-    set(x11_defvalue ON)
-    set(cocoa_defvalue OFF)
-  endif()
-  set(davix_defvalue OFF)
-else()
-  set(x11_defvalue ON)
-  set(memstat_defvalue ON)
-  set(explicitlink_defvalue ON)
-  set(cocoa_defvalue OFF)
-  set(davix_defvalue OFF)
-endif()
-
-if(all)
- set(gdml_defvalue ON)
- set(http_defvalue ON)
- set(qt_defvalue ON)
- set(qtgsi_defvalue ON)
- set(roofit_defvalue ON)
- set(minuit2_defvalue ON)
- set(table_defvalue ON)
- set(unuran_defvalue ON)
- if(WIN32)
-   set(vc_defvalue OFF)
- else()
-   set(vc_defvalue ON)
- endif()
- set(vdt_defvalue ON)
-else()
- set(gdml_defvalue OFF)
- set(http_defvalue OFF)
- set(qt_defvalue OFF)
- set(qtgsi_defvalue OFF)
- set(roofit_defvalue OFF)
- set(minuit2_defvalue OFF)
- set(table_defvalue OFF)
- set(unuran_defvalue OFF)
- set(vc_defvalue OFF)
- set(vdt_defvalue OFF)
-endif()
+
+#--------------------------------------------------------------------------------------------------
+#---Full list of options with their descriptios and default values
+#   The default value can be changed as many times as we wish before calling ROOT_APPLY_OPTIONS()
+#--------------------------------------------------------------------------------------------------

 ROOT_BUILD_OPTION(afdsmgrd OFF "Dataset manager for PROOF-based analysis facilities")
 ROOT_BUILD_OPTION(afs OFF "AFS support, requires AFS libs and objects")
@@ -125,28 +85,28 @@
 ROOT_BUILD_OPTION(chirp ON "Chirp support (Condor remote I/O), requires libchirp_client")
 ROOT_BUILD_OPTION(cintex ON "Build the libCintex Reflex interface library")
 ROOT_BUILD_OPTION(cling OFF "Enable new CLING C++ interpreter")
-ROOT_BUILD_OPTION(cocoa ${cocoa_defvalue} "Use native Cocoa/Quartz graphics backend (MacOS X only)")
-ROOT_BUILD_OPTION(davix ${davix_defvalue} "DavIx library for HTTP/WEBDAV access")
+ROOT_BUILD_OPTION(cocoa OFF "Use native Cocoa/Quartz graphics backend (MacOS X only)")
+ROOT_BUILD_OPTION(davix ON "DavIx library for HTTP/WEBDAV access")
 ROOT_BUILD_OPTION(dcache ON "dCache support, requires libdcap from DESY")
 ROOT_BUILD_OPTION(exceptions ON "Turn on compiler exception handling capability")
-ROOT_BUILD_OPTION(explicitlink ${explicitlink_defvalue} "Explicitly link with all dependent libraries")
+ROOT_BUILD_OPTION(explicitlink ON "Explicitly link with all dependent libraries")
 ROOT_BUILD_OPTION(fftw3 ON "Fast Fourier Transform support, requires libfftw3")
 ROOT_BUILD_OPTION(fitsio ON "Read images and data from FITS files, requires cfitsio")
 ROOT_BUILD_OPTION(fortran ON "Enable the Fortran components of ROOT")
 ROOT_BUILD_OPTION(gviz ON "Graphs visualization support, requires graphviz")
-ROOT_BUILD_OPTION(gdml ${gdml_defvalue} "GDML writer and reader")
+ROOT_BUILD_OPTION(gdml OFF "GDML writer and reader")
 ROOT_BUILD_OPTION(genvector ON "Build the new libGenVector library")
 ROOT_BUILD_OPTION(gfal ON "GFAL support, requires libgfal")
 ROOT_BUILD_OPTION(glite ON "gLite support, requires libglite-api-wrapper v.3 from GSI (https://subversion.gsi.de/trac/dgrid/wiki)")
 ROOT_BUILD_OPTION(globus OFF "Globus authentication support, requires Globus toolkit")
 ROOT_BUILD_OPTION(gsl_shared OFF "Enable linking against shared libraries for GSL (default no)")
 ROOT_BUILD_OPTION(hdfs ON "HDFS support; requires libhdfs from HDFS >= 0.19.1")
-ROOT_BUILD_OPTION(http ${http_defvalue} "HTTP Server support")
+ROOT_BUILD_OPTION(http OFF "HTTP Server support")
 ROOT_BUILD_OPTION(krb5 ON "Kerberos5 support, requires Kerberos libs")
 ROOT_BUILD_OPTION(ldap ON "LDAP support, requires (Open)LDAP libs")
 ROOT_BUILD_OPTION(mathmore ON "Build the new libMathMore extended math library, requires GSL (vers. >= 1.8)")
-ROOT_BUILD_OPTION(memstat ${memstat_defvalue} "A memory statistics utility, helps to detect memory leaks")
-ROOT_BUILD_OPTION(minuit2 ${minuit2_defvalue} "Build the new libMinuit2 minimizer library")
+ROOT_BUILD_OPTION(memstat ON "A memory statistics utility, helps to detect memory leaks")
+ROOT_BUILD_OPTION(minuit2 OFF "Build the new libMinuit2 minimizer library")
 ROOT_BUILD_OPTION(monalisa ON "Monalisa monitoring support, requires libapmoncpp")
 ROOT_BUILD_OPTION(mysql ON "MySQL support, requires libmysqlclient")
 ROOT_BUILD_OPTION(odbc ON "ODBC support, requires libiodbc or libodbc")
@@ -158,10 +118,10 @@
 ROOT_BUILD_OPTION(pythia6_nolink OFF "Delayed linking of Pythia6 library")
 ROOT_BUILD_OPTION(pythia8 ON "Pythia8 EG support, requires libPythia8")
 ROOT_BUILD_OPTION(python ON "Python ROOT bindings, requires python >= 2.2")
-ROOT_BUILD_OPTION(qt ${qt_defvalue} "Qt graphics backend, requires libqt >= 4.8")
-ROOT_BUILD_OPTION(qtgsi ${qtgsi_defvalue} "GSI's Qt integration, requires libqt >= 4.8")
+ROOT_BUILD_OPTION(qt OFF "Qt graphics backend, requires libqt >= 4.8")
+ROOT_BUILD_OPTION(qtgsi OFF "GSI's Qt integration, requires libqt >= 4.8")
 ROOT_BUILD_OPTION(reflex ON "Build the libReflex dictionary library")
-ROOT_BUILD_OPTION(roofit ${roofit_defvalue} "Build the libRooFit advanced fitting package")
+ROOT_BUILD_OPTION(roofit OFF "Build the libRooFit advanced fitting package")
 ROOT_BUILD_OPTION(ruby OFF "Ruby ROOT bindings, requires ruby >= 1.8")
 ROOT_BUILD_OPTION(rfio ON "RFIO support, requires libshift from CASTOR >= 1.5.2")
 ROOT_BUILD_OPTION(rpath OFF "Set run-time library load path on executables and shared libraries (at installation area)")
@@ -173,16 +133,16 @@
 ROOT_BUILD_OPTION(srp ON "SRP support, requires SRP source tree")
 ROOT_BUILD_OPTION(ssl ON "SSL encryption support, requires openssl")
 ROOT_BUILD_OPTION(gnuinstall OFF "Perform installation following the GNU guidelines")
-ROOT_BUILD_OPTION(table ${table_defvalue} "Build libTable contrib library")
+ROOT_BUILD_OPTION(table OFF "Build libTable contrib library")
 ROOT_BUILD_OPTION(thread ON "Using thread library (cannot be disabled)")
 ROOT_BUILD_OPTION(tmva ON "Build TMVA multi variate analysis library")
-ROOT_BUILD_OPTION(unuran ${unuran_defvalue} "UNURAN - package for generating non-uniform random numbers")
-ROOT_BUILD_OPTION(vc ${vc_defvalue} "Vc adds a few new types for portable and intuitive SIMD programming")
-ROOT_BUILD_OPTION(vdt ${vdt_defvalue} "VDT adds a set of fast and vectorisable mathematical functions")
+ROOT_BUILD_OPTION(unuran OFF "UNURAN - package for generating non-uniform random numbers")
+ROOT_BUILD_OPTION(vc OFF "Vc adds a few new types for portable and intuitive SIMD programming")
+ROOT_BUILD_OPTION(vdt ON "VDT adds a set of fast and vectorisable mathematical functions")
 ROOT_BUILD_OPTION(winrtdebug OFF "Link against the Windows debug runtime library")
 ROOT_BUILD_OPTION(xft ON "Xft support (X11 antialiased fonts)")
 ROOT_BUILD_OPTION(xml ON "XML parser interface")
-ROOT_BUILD_OPTION(x11 ${x11_defvalue} "X11 support")
+ROOT_BUILD_OPTION(x11 ON "X11 support")
 ROOT_BUILD_OPTION(xrootd ON "Build xrootd file server and its client (if supported)")

 option(fail-on-missing "Fail the configure step if a required external package is missing" OFF)
@@ -196,16 +156,51 @@
   set(cxx11 ${c++11} CACHE BOOL "" FORCE)
 endif()

+#--- Minor chnages in defaults due to platform--------------------------------------------------
+if(WIN32)
+  set(x11_defvalue OFF)
+  set(memstat_defvalue OFF)
+  set(davix_defvalue OFF)
+elseif(APPLE)
+  set(x11_defvalue OFF)
+  set(cocoa_defvalue ON)
+  set(davix_defvalue OFF)
+endif()
+
+#--- The 'all' option swithes ON major options---------------------------------------------------
+if(all)
+ set(gdml_defvalue ON)
+ set(http_defvalue ON)
+ set(qt_defvalue ON)
+ set(qtgsi_defvalue ON)
+ set(roofit_defvalue ON)
+ set(minuit2_defvalue ON)
+ set(r_defvalue ON)
+ set(root7_defvalue ON)
+ set(table_defvalue ON)
+ set(unuran_defvalue ON)
+ set(vc_defvalue ON)
+endif()
+
+#---VC does not support yet Arm and PPC processors----------------------------------------------
+if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
+   message(STATUS "A system not supported by Vc, ${CMAKE_SYSTEM_PROCESSOR}, was detected. Disabling Vc by default.")
+   set(vc_defvalue OFF)
+endif()
+
 #---Apply minimal or gminimal------------------------------------------------------------------
 foreach(opt ${root_build_options})
   if(NOT opt MATCHES "thread|cxx11|cling|builtin_llvm|builtin_ftgl|explicitlink")
     if(minimal)
-      set(${opt} OFF CACHE BOOL "" FORCE)
+      set(${opt}_defvalue OFF)
     elseif(gminimal AND NOT opt MATCHES "x11|cocoa")
-      set(${opt} OFF CACHE BOOL "" FORCE)
+      set(${opt}_defvalue OFF)
     endif()
   endif()
 endforeach()
+
+#---Define at moment the options with the selected default values-----------------------------
+ROOT_APPLY_OPTIONS()

 #---Avoid creating dependencies to 'non-standard' header files -------------------------------
 include_regular_expression("^[^.]+$|[.]h$|[.]icc$|[.]hxx$|[.]hpp$")


[cmake] Enable built-in RPATH by default

--- cmake/modules/RootBuildOptions.cmake
+++ cmake/modules/RootBuildOptions.cmake
@@ -160,7 +160,7 @@
 ROOT_BUILD_OPTION(roofit ON "Build the advanced fitting package RooFit, and RooStats for statistical tests. If xml is available, also build HistFactory.")
 ROOT_BUILD_OPTION(webgui ON "Build Web-based UI components of ROOT (requires C++14 standard or higher)")
 ROOT_BUILD_OPTION(root7 ON "Build ROOT 7 components of ROOT (requires C++14 standard or higher)")
-ROOT_BUILD_OPTION(rpath OFF "Link libraries with built-in RPATH (run-time search path)")
+ROOT_BUILD_OPTION(rpath ON "Link libraries with built-in RPATH (run-time search path)")
 ROOT_BUILD_OPTION(runtime_cxxmodules ON "Enable runtime support for C++ modules")
 ROOT_BUILD_OPTION(shadowpw OFF "Enable support for shadow passwords")
 ROOT_BUILD_OPTION(shared ON "Use shared 3rd party libraries if possible")


Update facts.cmake

Update facts.cmake

--- facts/facts.cmake
+++ facts/facts.cmake
@@ -69,7 +69,7 @@
 	endif(CMAKE_CL_64)
 ELSE()
 	execute_process(
-		COMMAND sh detect_operative_system.sh
+		COMMAND bash detect_operative_system.sh
 		WORKING_DIRECTORY "${CMAKI_PATH}/ci"
 		OUTPUT_VARIABLE RESULT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
 	set(CMAKI_PLATFORM "${RESULT_VERSION}")


ffmpeg configure --enable-pic

ffmpeg configure --enable-pic

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

--- projects/ffmpeg.cmake
+++ projects/ffmpeg.cmake
@@ -65,7 +65,7 @@
     set(XP_CONFIGURE_BASE ${CMAKE_COMMAND} -E env PKG_CONFIG_PATH=${STAGE_DIR}/share/cmake
       PATH=${STAGE_DIR}/bin:$ENV{PATH} # prepend path to yasm
       <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> #--enable-shared --disable-static
-      --enable-libopenh264 --disable-bzlib --disable-iconv
+      --enable-pic --enable-libopenh264 --disable-bzlib --disable-iconv
       --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-libxcb-shape
       --disable-lzma --disable-sdl --disable-xlib --disable-zlib
       )


cmake: add missing GRN_LOCK_TIMEOUT entry

--- config.h.cmake
+++ config.h.cmake
@@ -30,6 +30,7 @@

 #define GRN_STACK_SIZE       ${GRN_STACK_SIZE}

+#define GRN_LOCK_TIMEOUT     ${GRN_LOCK_TIMEOUT}
 #define GRN_LOCK_WAIT_TIME_NANOSECOND \
   ${GRN_LOCK_WAIT_TIME_NANOSECOND}


use correct BUILD_Gadgetron flag

use correct BUILD_Gadgetron flag

--- SuperBuild/External_SIRF.cmake
+++ SuperBuild/External_SIRF.cmake
@@ -25,7 +25,7 @@
 # Set dependency list
 set(${proj}_DEPENDENCIES "Boost;HDF5;ISMRMRD;FFTW3;SWIG")

-if (${BUILD_GADGETRON})
+if (${BUILD_Gadgetron})
     set(${proj}_DEPENDENCIES "${${proj}_DEPENDENCIES};Gadgetron")
 endif()
 if (${BUILD_NIFTYREG})


From Mattias Helsing, "I just made Find3rdPartyDependencies search for curllib if it can't
find libcurl. Mike's 3rdParty only has curllib.

I realize now that the in appended file I have earlier removed
searching for freetype219 since I have it but it will break the build
of osg."

--- CMakeModules/Find3rdPartyDependencies.cmake
+++ CMakeModules/Find3rdPartyDependencies.cmake
@@ -52,14 +52,14 @@

 MACRO(SEARCH_3RDPARTY OSG_3RDPARTY_BIN)
         FIND_DEPENDENCY(TIFF tiff.h libtiff ${OSG_3RDPARTY_BIN} "D")
-        FIND_DEPENDENCY(FREETYPE ft2build.h "freetype;freetype219;freetype234;freetype234MT;freetype235" ${OSG_3RDPARTY_BIN} "_D")
+        FIND_DEPENDENCY(FREETYPE ft2build.h "freetype;freetype234;freetype234MT;freetype235" ${OSG_3RDPARTY_BIN} "_D")
         IF(FREETYPE_FOUND)
             #forcing subsequent FindFreeType stuff to not search for other variables.... kind of a hack
             SET(FREETYPE_INCLUDE_DIR_ft2build ${FREETYPE_INCLUDE_DIR} CACHE PATH "")
             SET(FREETYPE_INCLUDE_DIR_freetype2 ${FREETYPE_INCLUDE_DIR} CACHE PATH "")
             MARK_AS_ADVANCED(FREETYPE_INCLUDE_DIR_ft2build FREETYPE_INCLUDE_DIR_freetype2)
         ENDIF(FREETYPE_FOUND)
-        FIND_DEPENDENCY(CURL curl/curl.h libcurl ${OSG_3RDPARTY_BIN} "D")
+        FIND_DEPENDENCY(CURL curl/curl.h "libcurl;curllib" ${OSG_3RDPARTY_BIN} "D")
         FIND_DEPENDENCY(JPEG jpeglib.h libjpeg ${OSG_3RDPARTY_BIN} "D")
         #FIND_DEPENDENCY(GDAL gdal.h "gdal;gdal_i" ${OSG_3RDPARTY_BIN})
         FIND_DEPENDENCY(GLUT GL/glut.h glut32 ${OSG_3RDPARTY_BIN} "D")


Add libcrypto as a dependency of core on non-Apple platforms as it's required by encryption.

--- CMake/RealmCore.cmake
+++ CMake/RealmCore.cmake
@@ -21,6 +21,23 @@

 find_package(PkgConfig)
 find_package(Threads)
+
+if(APPLE)
+    find_library(Foundation Foundation)
+    find_library(Foundation Security)
+
+    set(CRYPTO_LIBRARIES "")
+    set(SSL_LIBRARIES Foundation Security)
+elseif(REALM_PLATFORM STREQUAL "Android")
+    # The Android core and sync libraries include the necessary portions of OpenSSL.
+    set(CRYPTO_LIBRARIES "")
+    set(SSL_LIBRARIES "")
+else()
+    find_package(OpenSSL REQUIRED)
+
+    set(CRYPTO_LIBRARIES OpenSSL::Crypto)
+    set(SSL_LIBRARIES OpenSSL::SSL)
+endif()

 if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
     set(MAKE_EQUAL_MAKE "MAKE=$(MAKE)")
@@ -112,7 +129,7 @@
     set_property(TARGET realm PROPERTY IMPORTED_LOCATION_RELEASE ${core_library_release})
     set_property(TARGET realm PROPERTY IMPORTED_LOCATION ${core_library_release})

-    set_property(TARGET realm PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)
+    set_property(TARGET realm PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads ${CRYPTO_LIBRARIES})

     set(REALM_CORE_INCLUDE_DIR ${core_directory}/include PARENT_SCOPE)
 endfunction()
@@ -136,7 +153,7 @@
     set_property(TARGET realm PROPERTY IMPORTED_LOCATION_RELEASE ${core_library_release})
     set_property(TARGET realm PROPERTY IMPORTED_LOCATION ${core_library_release})

-    set_property(TARGET realm PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)
+    set_property(TARGET realm PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads ${CRYPTO_LIBRARIES})

     set(REALM_CORE_INCLUDE_DIR ${core_directory}/src PARENT_SCOPE)
 endmacro()
@@ -177,10 +194,6 @@

 function(build_realm_sync sync_directory)
     get_filename_component(sync_directory ${sync_directory} ABSOLUTE)
-    if(APPLE)
-        find_library(FOUNDATION Foundation)
-        find_library(SECURITY Security)
-    endif()
     ExternalProject_Add(realm-sync-lib
         DEPENDS realm-core
         URL ""
@@ -210,11 +223,8 @@
     set_property(TARGET realm-sync PROPERTY IMPORTED_LOCATION_COVERAGE ${sync_library_debug})
     set_property(TARGET realm-sync PROPERTY IMPORTED_LOCATION_RELEASE ${sync_library_release})
     set_property(TARGET realm-sync PROPERTY IMPORTED_LOCATION ${sync_library_release})
-    if(APPLE)
-        set_property(TARGET realm-sync PROPERTY INTERFACE_LINK_LIBRARIES ${FOUNDATION} ${SECURITY})
-    else()
-        set_property(TARGET realm-sync PROPERTY INTERFACE_LINK_LIBRARIES -lcrypto -lssl)
-    endif()
+
+    set_property(TARGET realm-sync PROPERTY INTERFACE_LINK_LIBRARIES ${SSL_LIBRARIES})

     # Sync server library is built as part of the sync library build
     ExternalProject_Add(realm-server-lib
@@ -245,11 +255,7 @@
     set_property(TARGET realm-sync-server PROPERTY IMPORTED_LOCATION ${sync_server_library_release})

     pkg_check_modules(YAML QUIET yaml-cpp)
-    if(APPLE)
-        set_property(TARGET realm-sync-server PROPERTY INTERFACE_LINK_LIBRARIES ${FOUNDATION} ${SECURITY} ${YAML_LDFLAGS})
-    else()
-        set_property(TARGET realm-sync-server PROPERTY INTERFACE_LINK_LIBRARIES -lcrypto -lssl  ${YAML_LDFLAGS})
-    endif()
+    set_property(TARGET realm-sync-server PROPERTY INTERFACE_LINK_LIBRARIES ${SSL_LIBRARIES} ${YAML_LDFLAGS})

     set(REALM_SYNC_INCLUDE_DIR ${sync_directory}/src PARENT_SCOPE)
 endfunction()


Use modern CMake for the definitions and the includes

--- CMake/Utilities.cmake
+++ CMake/Utilities.cmake
@@ -60,10 +60,6 @@
   message(ERROR "No name set for ${PREFIX}")
 endif(NOT ${PREFIX}_NAME)

-add_definitions(${${PREFIX}_DEFINITIONS})
-
-include_directories(${PROJECT_SOURCE_DIR} ${${PREFIX}_INCLUDE})
-
 ATK_scan_SIMD(${PREFIX} COMPILABLE_ARCHS)

 if(ENABLE_STATIC_LIBRARIES)
@@ -72,6 +68,9 @@
       ${${PREFIX}_SRC} ${${PREFIX}_HEADERS} ${NATVIS_FILE}
   )

+  target_compile_definitions(${${PREFIX}_NAME}_static PRIVATE ${${PREFIX}_DEFINITIONS})
+  target_include_directories(${${PREFIX}_NAME}_static PRIVATE ${${PREFIX}_INCLUDE} ${PROJECT_SOURCE_DIR})
+
   set_target_properties (${${PREFIX}_NAME}_static PROPERTIES
     FOLDER C++/static
   )
@@ -84,13 +83,13 @@
 endif(ENABLE_STATIC_LIBRARIES)

 if(ENABLE_SHARED_LIBRARIES)
-  add_definitions(-DBUILD_${PREFIX})
-  add_definitions(-DATK_SHARED)
-
   add_library(${${PREFIX}_NAME}
     SHARED
     ${${PREFIX}_SRC} ${${PREFIX}_HEADERS} ${NATVIS_FILE} ${${PREFIX}_ARCH_GEN_SRC}
   )
+
+  target_compile_definitions(${${PREFIX}_NAME} PRIVATE ${${PREFIX}_DEFINITIONS} -DBUILD_${PREFIX} -DATK_SHARED)
+  target_include_directories(${${PREFIX}_NAME} PRIVATE ${${PREFIX}_INCLUDE} ${PROJECT_SOURCE_DIR})

   set_target_properties (${${PREFIX}_NAME} PROPERTIES
     FOLDER C++/shared


ENH: add the .exe executable extension to clang-format on Windows

--- CMake/ITKClangFormatSetup.cmake
+++ CMake/ITKClangFormatSetup.cmake
@@ -41,12 +41,16 @@
     message(FATAL_ERROR "UNKOWN SYSTEM: Set CLANGFORMAT_EXECUTABLE manually to the clang-format version 8.0 binary")
   endif()
   file(MAKE_DIRECTORY "${ITK_BINARY_DIR}/temp")
-  file(DOWNLOAD "${CLANGFORMAT_DOWNLOAD_URL}" "${ITK_BINARY_DIR}/temp/clang-format-${CMAKE_SYSTEM_NAME}")
-  file(COPY "${ITK_BINARY_DIR}/temp/clang-format-${CMAKE_SYSTEM_NAME}"
+  if(WIN32)
+    set(exe .exe)
+  endif()
+  set(CLANGFORMAT_EXECUTABLE_NAME "clang-format-${CMAKE_SYSTEM_NAME}${exe}")
+  file(DOWNLOAD "${CLANGFORMAT_DOWNLOAD_URL}" "${ITK_BINARY_DIR}/temp/${CLANGFORMAT_EXECUTABLE_NAME}")
+  file(COPY "${ITK_BINARY_DIR}/temp/${CLANGFORMAT_EXECUTABLE_NAME}"
        DESTINATION "${ITK_BINARY_DIR}"
        FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
   unset( CLANGFORMAT_DOWNLOAD_URL )
-  set( CLANGFORMAT_EXECUTABLE "${ITK_BINARY_DIR}/clang-format-${CMAKE_SYSTEM_NAME}" CACHE FILEPATH "The binary for clang-format" FORCE)
+  set( CLANGFORMAT_EXECUTABLE "${ITK_BINARY_DIR}/${CLANGFORMAT_EXECUTABLE_NAME}" CACHE FILEPATH "The binary for clang-format" FORCE)
 endif()
 if(CLANGFORMAT_EXECUTABLE)
   mark_as_advanced(CLANGFORMAT_EXECUTABLE)


fix typo

fix typo

--- CMake/Utils/AndroidMacros.cmake
+++ CMake/Utils/AndroidMacros.cmake
@@ -59,7 +59,7 @@
       else()
 	    SET(ANDROID_EXECUTABLE "/opt/android-sdk/tools/android")
       endif()
-      if(EXISTS $ENV{ANDROID_SDK})
+      if(EXISTS $ENV{ANDROID_NDK})
         SET(NDK_BUILD_EXECUTABLE "$ENV{ANDROID_NDK}/ndk-build")
       else()
         SET(NDK_BUILD_EXECUTABLE "${ANDROID_NDK}/ndk-build")


Only use exact if python interpreter has been found

Then removes a CMake warning:
CMake Warning (dev) at D:/SimpleITK/CMake/sitkLanguageOptions.cmake:71
(find_pac                                        kage):
  Ignoring EXACT since no version is requested.

Change-Id: Ia4247bbaa226cdf9ff03fb5d1777367bf18827a5

--- CMake/sitkLanguageOptions.cmake
+++ CMake/sitkLanguageOptions.cmake
@@ -68,7 +68,11 @@

 set_QUIET( WRAP_PYTHON )
 find_package ( PythonInterp ${_QUIET})
-find_package ( PythonLibs ${PYTHON_VERSION_STRING} EXACT ${_QUIET_LIBRARY} )
+if ( PYTHONINTERP_FOUND )
+  find_package ( PythonLibs ${PYTHON_VERSION_STRING} EXACT ${_QUIET_LIBRARY} )
+else ()
+  find_package ( PythonLibs ${_QUIET_LIBRARY} )
+endif()

 if ( PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND
     AND PYTHON_VERSION_STRING VERSION_LESS 2.6 )


ENH: Prevent header generation when unchanged.

Added CMake logic to prevent the regeneration of the headers
and .i files in the case when the list have not actually changed.
This should prevent unnecessary rebuilds after running cmake,
but still should update the .h and .i files when new filters
are added via .json files.

--- Code/BasicFilters/SourceCodeGenerator.cmake
+++ Code/BasicFilters/SourceCodeGenerator.cmake
@@ -28,9 +28,29 @@
 endforeach()

 # clear the include files
-file ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.h "" )
-file ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.i "" )
+file ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.h.tmp "" )
+file ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.i.tmp "" )
 foreach ( filter ${GENERATED_FILTER_LIST} )
-  file ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.h "#include \"sitk${filter}ImageFilter.h\"\n" )
-  file ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.i "%include \"sitk${filter}ImageFilter.h\"\n" )
+  file ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.h.tmp "#include \"sitk${filter}ImageFilter.h\"\n" )
+  file ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.i.tmp "%include \"sitk${filter}ImageFilter.h\"\n" )
 endforeach()
+# Check if they have changed, and only in they have, copy them as new ones.
+file( DIFFERENT GENERATED_HEADERS_CHANGED FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.h
+  ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.h.tmp )
+file( DIFFERENT GENERATED_INTERFACES_CHANGED FILES
+  ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.i
+  ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.i.tmp )
+if( GENERATED_HEADERS_CHANGED )
+  configure_file(
+    ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.h.tmp
+    ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.h
+    COPYONLY )
+endif()
+if( GENERATED_INTERFACES_CHANGED )
+  configure_file(
+    ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.i.tmp
+    ${CMAKE_CURRENT_BINARY_DIR}/SimpleITKBasicFiltersGeneratedHeaders.i
+    COPYONLY )
+endif()
+


Use CMake's FindPackageHandleStandardArgs

Equivalent of https://github.com/robotology/blockfactory/commit/d6fc14d3d306cfd709449179edea2fbe114b9ebc

--- cmake/FindMatlab.cmake
+++ cmake/FindMatlab.cmake
@@ -254,7 +254,7 @@

 set(_FindMatlab_SELF_DIR "${CMAKE_CURRENT_LIST_DIR}")

-include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+include(FindPackageHandleStandardArgs)
 include(CheckCXXCompilerFlag)
 include(CheckCCompilerFlag)


boards: mps2_an521: add remote Zephyr dir for openamp

Add remote Zephyr directory for openamp sample, so that the sample
will correctly set emulator flags when compiled with sysbuild

Signed-off-by: Daniel DeGrasse <002dd1d4ac44ebb71088aae93501e62b784ed821@nxp.com>

--- boards/arm/mps2_an521/board.cmake
+++ boards/arm/mps2_an521/board.cmake
@@ -21,7 +21,8 @@
   # TF-M (Secure) & Zephyr (Non Secure) image (when running
   # in-tree tests).
   set(QEMU_KERNEL_OPTION "-device;loader,file=${CMAKE_BINARY_DIR}/tfm_merged.hex")
-
+elseif(CONFIG_OPENAMP)
+  set(QEMU_EXTRA_FLAGS "-device;loader,file=${REMOTE_ZEPHYR_DIR}/zephyr.elf")
 elseif (CONFIG_SOC_MPS2_AN521_CPU1)
   set(CPU0_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/zephyr/boards/arm/mps2_an521/empty_cpu0-prefix/src/empty_cpu0-build/zephyr)
   set(QEMU_KERNEL_OPTION "-device;loader,file=${CPU0_BINARY_DIR}/zephyr.elf")


Bring in fix for QVTKOpenGLWidget destructor

--- versions.cmake
+++ versions.cmake
@@ -92,7 +92,7 @@
   set(_paraview_revision "master")
 else()
   # Test the revision with OpenGL2 rendering before updating, update often!
-  set(_paraview_revision "a46eaca267da6b23ea906c4aa0a28078da57aecc")
+  set(_paraview_revision "f38113aa2a2a7a7549e1aa5033b546586c07bb74")
 endif()
 add_revision(paraview
   GIT_REPOSITORY "https://gitlab.kitware.com/paraview/paraview.git"


Update 64-bit Windows FFMPEG Binaries

Update 64-bit Windows FFMPEG Binaries

The new binaries were compiled with 64-bit Visual Studio 2015
for FFMPEG version 2.8.15.

Signed-off-by: Patrick Avery <743342299f279e7a8c3ff5eb40671fce3e95f13a@kitware.com>

--- versions.cmake
+++ versions.cmake
@@ -31,9 +31,10 @@
 if (WIN32)
   if (64bit_build)
     add_revision(ffmpeg
-      URL "https://paraview.org/files/dependencies/ffmpeg-kitware-20150514gitbc25918-win64.tar.bz2"
-      URL_MD5 887217ae04ee9004e2ec121442553259)
+      URL "https://openchemistry.org/files/tpl/ffmpeg-2.8.15-vs2015-x64.tar.gz"
+      URL_MD5 08da7cb4828c53d8c6985ee378bb7ed9)
   else ()
+    # The one below probably won't work... may need to build another
     add_revision(ffmpeg
       URL "https://paraview.org/files/dependencies/ffmpeg-kitware-20150514gitbc25918-win32.tar.bz2"
       URL_MD5 b8b3068699e272789ca02df5c132c05c)


Remove misspelled compiler argument that we don't want anyway.

--- build/cmake/CondorConfigure.cmake
+++ build/cmake/CondorConfigure.cmake
@@ -735,11 +735,6 @@
 		if (cxx_fstack_protector)
 			set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
 		endif(cxx_fstack_protector)
-
-		check_cxx_compiler_flag(-fnostack-protector cxx_fnostack_protector)
-		if (cxx_fnostack_protector)
-			set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fnostack-protector")
-		endif(cxx_fnostack_protector)
 	endif(NOT AIX)

 	check_cxx_compiler_flag(-rdynamic cxx_rdynamic)


switch to c++11

switch to c++11

--- cmake/CMakeCompilerSettings.cmake
+++ cmake/CMakeCompilerSettings.cmake
@@ -1,7 +1,8 @@
 # Set necessary compile and link flags

 if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
-	set(CMAKE_CXX_FLAGS_DEBUG   "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wnon-virtual-dtor -fprofile-arcs -ftest-coverage -fPIC -O0")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+        set(CMAKE_CXX_FLAGS_DEBUG   "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 -Wall -Wextra -Wnon-virtual-dtor -fprofile-arcs -ftest-coverage -fPIC -O0")
 elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
 # TODO figure clang stuff to enable test-coverage
 # Instrument Program flow should be set to Yes


make sure that regex does not match cmake

--- cmake/EigenConfigureTesting.cmake
+++ cmake/EigenConfigureTesting.cmake
@@ -26,7 +26,7 @@
 # try to grab the default flags
 string(REGEX MATCH "MakeCommand:.*-- (.*)\nDefaultCTestConfigurationType" EIGEN_DUMMY ${EIGEN_DART_CONFIG_FILE})
 if(NOT CMAKE_MATCH_1)
-string(REGEX MATCH "MakeCommand:.*make (.*)\nDefaultCTestConfigurationType" EIGEN_DUMMY ${EIGEN_DART_CONFIG_FILE})
+string(REGEX MATCH "MakeCommand:.*[^c]make (.*)\nDefaultCTestConfigurationType" EIGEN_DUMMY ${EIGEN_DART_CONFIG_FILE})
 endif()
 string(REGEX REPLACE "MakeCommand:.*DefaultCTestConfigurationType" "MakeCommand: ${CMAKE_COMMAND} --build . --target buildtests --config \"\${CTEST_CONFIGURATION_TYPE}\" -- ${CMAKE_MATCH_1} ${EIGEN_TEST_BUILD_FLAGS}\nDefaultCTestConfigurationType"
        EIGEN_DART_CONFIG_FILE2 ${EIGEN_DART_CONFIG_FILE})


Fix symlink install python when shebang line is rewritten (#1100)

* Refactor catkin_install_python.cmake

Signed-off-by: Kenji Miyake <bfae1df48a060ed7fb56eae8a402572418f0da8b@tier4.jp>

* Use source-permissions for rewritten_files

Signed-off-by: Kenji Miyake <bfae1df48a060ed7fb56eae8a402572418f0da8b@tier4.jp>

* rename temp variable

* add comment

Co-authored-by: Dirk Thomas <19795c8185177e940eedd30ceb2b716a54a3d5dc@users.noreply.github.com>

--- cmake/catkin_install_python.cmake
+++ cmake/catkin_install_python.cmake
@@ -38,6 +38,9 @@
         get_filename_component(filename ${source_file} NAME)
         set(rewritten_file "${CMAKE_CURRENT_BINARY_DIR}/catkin_generated/installspace")
         file(MAKE_DIRECTORY ${rewritten_file})
+        # even though the content of the file is overwritten
+        # the copy makes sure the file has the right permissions
+        file(COPY ${source_file} DESTINATION ${rewritten_file} USE_SOURCE_PERMISSIONS)
         set(rewritten_file "${rewritten_file}/${filename}")
         file(WRITE ${rewritten_file} "${data}")
       else()


2nd part of darktable/5597 - remove unnecessary C-warnings that don't apply to C++

this ultimatelly fixes darktable/5377 by removing all C-only warnings

--- cmake/compiler-warnings-gcc.cmake
+++ cmake/compiler-warnings-gcc.cmake
@@ -12,17 +12,17 @@
   "extra"
   "extra-semi"
   "format=2"
-  "missing-prototypes"
+#  "missing-prototypes"
   "old-style-casts"
   "pointer-arith"
-  "strict-prototypes"
+#  "strict-prototypes"
 #  "suggest-attribute=const"
 #  "suggest-attribute=noreturn"
 #  "suggest-attribute=pure"
 #  "suggest-final-methods"
 #  "suggest-final-types"
 #  "suggest-override"
-  "traditional"
+#  "traditional"
   "vla"
 # "cast-align"
 # "conversion"


Remove unused COMPILER_VERSION variable

Remove unused COMPILER_VERSION variable

--- cmake/modules/CheckCompiler.cmake
+++ cmake/modules/CheckCompiler.cmake
@@ -50,7 +50,7 @@
   string(REGEX REPLACE "^.*[ ]version[ ]([0-9]+)\\.[0-9]+.*" "\\1" CLANG_MAJOR "${_clang_version_info}")
   string(REGEX REPLACE "^.*[ ]version[ ][0-9]+\\.([0-9]+).*" "\\1" CLANG_MINOR "${_clang_version_info}")
   message(STATUS "Found Clang. Major version ${CLANG_MAJOR}, minor version ${CLANG_MINOR}")
-  set(COMPILER_VERSION clang${CLANG_MAJOR}${CLANG_MINOR})
+
   if(CMAKE_GENERATOR STREQUAL "Ninja")
     # LLVM/Clang are automatically checking if we are in interactive terminal mode.
     # We use color output only for Ninja, because Ninja by default is buffering the output,
@@ -87,7 +87,6 @@
     set(GCC_MAJOR "")
   endif()
   message(STATUS "Found GCC. Major version ${GCC_MAJOR}, minor version ${GCC_MINOR}")
-  set(COMPILER_VERSION gcc${GCC_MAJOR}${GCC_MINOR}${GCC_PATCH})
   if("${GCC_MAJOR}.${GCC_MINOR}" VERSION_GREATER_EQUAL 4.9
       AND CMAKE_GENERATOR STREQUAL "Ninja")
     # GCC checks automatically if we are in interactive terminal mode.


[CMake] Polish a comment

[CMake] Polish a comment

git-svn-id: 4c4cc70b1ef44ba2b7963015e681894188cea27e@365459 91177308-0d34-0410-b5e6-96231b3b80d8

--- cmake/modules/LLDBFramework.cmake
+++ cmake/modules/LLDBFramework.cmake
@@ -26,7 +26,8 @@
   MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in
 )

-# Defined in AddLLVM.cmake; handles edge cases for multi-config generators
+# Used in llvm_add_library() to set default output directories for multi-config
+# generators. Overwrite to account for special framework output directory.
 set_output_directory(liblldb
   BINARY_DIR ${framework_target_dir}
   LIBRARY_DIR ${framework_target_dir}


Training '/' is very important for installation of headers

--- cmake/modules/RootNewMacros.cmake
+++ cmake/modules/RootNewMacros.cmake
@@ -700,10 +700,10 @@
   if( ARGN )
     set(dirs ${ARGN})
   else()
-    set(dirs inc)
+    set(dirs inc/)
     if(root7)
       if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/v7/inc)
-        set(dirs inc v7/inc)
+        set(dirs inc/ v7/inc/)
       endif()
     endif()
   endif()
@@ -733,6 +733,7 @@
     install(DIRECTORY ${d} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
                            COMPONENT headers
                            ${options})
+    string(REGEX REPLACE "(.*)/$" "\\1" d ${d})
     ROOT_GLOB_FILES(include_files
       RECURSE
       RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${d}


compat: fixes for old install_header

compat: fixes for old install_header

--- cmake/qibuild/compat/compat.cmake
+++ cmake/qibuild/compat/compat.cmake
@@ -57,10 +57,41 @@
 ######################
 # Install
 ######################
-function(install_header)
+function(install_header _staged_name)
+  # old API:
+  # install_header(STAGED_NAME [SUBFOLDER subfolder] [headers ...])
+  # new API:
+  # qi_install_header(subfolder [headers...])
   qi_deprecated("install_header is deprecated.
-  Use qi_install_header instead")
-  qi_install_header(${ARGN})
+  Use qi_install_header instead
+  Old:
+    install_header(FOO SUBFOLDER foo foo.h)
+  New:
+    qi_install_header(foo foo.h)
+  "
+  )
+  string(TOLOWER ${_staged_name} _targetname)
+  cmake_parse_arguments(ARG "INCLUDEPATHEXPORT" "SUBFOLDER" "" ${ARGN})
+  if(ARG_INCLUDEPATHEXPORT)
+    qi_warning("
+    Using  INCLUDEPATHEXPORT is not longer suppoprted
+    (problematic target: ${_targetname})
+    Old:
+      # include \"bar.h\"
+    New:
+      # include <${_targetname}/bar.h>
+    "
+    )
+  endif()
+
+  if(NOT ARG_SUBFOLDER)
+    qi_error("
+    The SUBFOLDER argument is now mandatory
+    "
+    )
+  endif()
+
+  qi_install_header(${ARG_SUBFOLDER} ${ARG_UNPARSED_ARGUMENTS})
 endfunction()

 function(install_data)


Fix possible build warnings.

Fix possible build warnings.

--HG--
branch : v0-8

--- cmake/CEGUIMacros.cmake
+++ cmake/CEGUIMacros.cmake
@@ -481,7 +481,7 @@

     cegui_gather_files()

-    include_directories(${Boost_INCLUDE_DIR})
+    include_directories(SYSTEM ${Boost_INCLUDE_DIR})

     ###########################################################################
     #                     Statically Linked Executable


Improve the CMake macro "cegui_find_package_handle_standard_args" so that on Windows and OS X, if only release libraries are available we'll always use them (regardless of "CMAKE_CONFIGURATION_TYPES" and "CMAKE_BUILD_TYPE"), and if only debug libraries are available we'll always use them.

--- cmake/CEGUIMacros.cmake
+++ cmake/CEGUIMacros.cmake
@@ -589,7 +589,10 @@
 #
 # NOTE: On platforms where the dependency pack is not intended to be used, the
 # extra library configurations are NOT checked, on those platforms we will use
-# the base library only.
+# the base library only. Also note that on those platforms, if only release
+# libraries are available we'll always use them (regardless of
+# "CMAKE_CONFIGURATION_TYPES" and "CMAKE_BUILD_TYPE"), and if only debug
+# libraries are available we'll always use them.
 #
 # _PKGNAME: The name of package we're checking for.
 # _LIBBASENAMEVAR: name of the library base name variable.  This name will be
@@ -622,27 +625,20 @@
             unset (_WANT_REL_LIBS)
         endif()

-        if (CEGUI_BUILD_SHARED_LIBS_WITH_STATIC_DEPENDENCIES)
-            if (_WANT_REL_LIBS)
+        if (CEGUI_BUILD_SHARED_LIBS_WITH_STATIC_DEPENDENCIES OR CEGUI_BUILD_STATIC_CONFIGURATION)
+            if ((_WANT_REL_LIBS AND ${_LIBBASENAMEVAR}_STATIC) OR NOT ${_LIBBASENAMEVAR}_STATIC_DBG)
                 list(APPEND _FPHSA_LIBS ${_LIBBASENAMEVAR}_STATIC)
             endif()
-            if (_WANT_DBG_LIBS)
+            if ((_WANT_DBG_LIBS AND ${_LIBBASENAMEVAR}_STATIC_DBG) OR NOT ${_LIBBASENAMEVAR}_STATIC)
                 list(APPEND _FPHSA_LIBS ${_LIBBASENAMEVAR}_STATIC_DBG)
             endif()
-        else()
-            if (_WANT_REL_LIBS)
+        endif ()
+        if (NOT CEGUI_BUILD_SHARED_LIBS_WITH_STATIC_DEPENDENCIES)
+            if ((_WANT_REL_LIBS AND ${_LIBBASENAMEVAR}) OR NOT ${_LIBBASENAMEVAR}_DBG)
                 list(APPEND _FPHSA_LIBS ${_LIBBASENAMEVAR})
             endif()
-            if (_WANT_DBG_LIBS)
+            if ((_WANT_DBG_LIBS AND ${_LIBBASENAMEVAR}_DBG) OR NOT ${_LIBBASENAMEVAR})
                 list(APPEND _FPHSA_LIBS ${_LIBBASENAMEVAR}_DBG)
-            endif()
-            if (CEGUI_BUILD_STATIC_CONFIGURATION)
-                if (_WANT_REL_LIBS)
-                    list(APPEND _FPHSA_LIBS ${_LIBBASENAMEVAR}_STATIC)
-                endif()
-                if (_WANT_DBG_LIBS)
-                    list(APPEND _FPHSA_LIBS ${_LIBBASENAMEVAR}_STATIC_DBG)
-                endif()
             endif()
         endif()
     else()


add USE_ALLEGRO to cmake

add USE_ALLEGRO to cmake

--- cmake/FindALLEGRO.cmake
+++ cmake/FindALLEGRO.cmake
@@ -28,7 +28,8 @@

 IF (ALLEGRO_INCLUDE_DIR AND ALLEGRO_LIBRARY)
    SET(ALLEGRO_FOUND TRUE)
-    SET( ALLEGRO_LIBRARIES ${ALLEGRO_LIBRARY} )
+   SET( ALLEGRO_LIBRARIES ${ALLEGRO_LIBRARY} )
+   add_definitions(-DUSE_ALLEGRO)
 ELSE (ALLEGRO_INCLUDE_DIR AND ALLEGRO_LIBRARY)
    SET(ALLEGRO_FOUND FALSE)
    SET( ALLEGRO_LIBRARIES )
@@ -48,4 +49,4 @@
 MARK_AS_ADVANCED(
   ALLEGRO_LIBRARY
   ALLEGRO_INCLUDE_DIR
-  )+  )


remove debug message in FindCholmod.cmake

--- cmake/FindCholmod.cmake
+++ cmake/FindCholmod.cmake
@@ -19,55 +19,49 @@

   get_filename_component(CHOLMOD_LIBDIR ${CHOLMOD_LIBRARIES} PATH)

-  message("found CHOLMOD_LIBRARIES " ${CHOLMOD_LIBRARIES} " in " ${CHOLMOD_LIBDIR})
-
   find_library(AMD_LIBRARY amd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR})
   if (AMD_LIBRARY)
     set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${AMD_LIBRARY})
     message ("AMD_LIBRARY found")
-	else (AMD_LIBRARY)
-    message ("AMD_LIBRARY not found")
-		set(CHOLMOD_LIBRARIES FALSE)
+  else (AMD_LIBRARY)
+    message ("AMD_LIBRARY not found")
+    set(CHOLMOD_LIBRARIES FALSE)
   endif (AMD_LIBRARY)
-
+
 endif(CHOLMOD_LIBRARIES)

 if(CHOLMOD_LIBRARIES)
-  message("CHOLMOD_LIBRARIES still here")

   find_library(COLAMD_LIBRARY colamd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR})
   if (COLAMD_LIBRARY)
     set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${COLAMD_LIBRARY})
-	else (COLAMD_LIBRARY)
-		set(CHOLMOD_LIBRARIES FALSE)
+  else (COLAMD_LIBRARY)
+    set(CHOLMOD_LIBRARIES FALSE)
   endif (COLAMD_LIBRARY)

 endif(CHOLMOD_LIBRARIES)

 if(CHOLMOD_LIBRARIES)
-message("CHOLMOD_LIBRARIES still here")
+
   find_library(CAMD_LIBRARY camd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR})
   if (CAMD_LIBRARY)
     set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${CAMD_LIBRARY})
-	else (CAMD_LIBRARY)
-		set(CHOLMOD_LIBRARIES FALSE)
+  else (CAMD_LIBRARY)
+    set(CHOLMOD_LIBRARIES FALSE)
   endif (CAMD_LIBRARY)
-
+
 endif(CHOLMOD_LIBRARIES)

 if(CHOLMOD_LIBRARIES)
-message("CHOLMOD_LIBRARIES still here (last)")
+
   find_library(CCOLAMD_LIBRARY colamd PATHS ${CHOLMOD_LIBDIR} $ENV{CHOLMODDIR} ${LIB_INSTALL_DIR})
   if (CCOLAMD_LIBRARY)
     set(CHOLMOD_LIBRARIES ${CHOLMOD_LIBRARIES} ${CCOLAMD_LIBRARY})
-	else (CCOLAMD_LIBRARY)
-		set(CHOLMOD_LIBRARIES FALSE)
+  else (CCOLAMD_LIBRARY)
+    set(CHOLMOD_LIBRARIES FALSE)
   endif (CCOLAMD_LIBRARY)

 endif(CHOLMOD_LIBRARIES)
-
-# if(CHOLMOD_LIBRARIES)
-# endif(CHOLMOD_LIBRARIES)

 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(CHOLMOD DEFAULT_MSG


Install Qt5 plugins on windows as well

Install Qt5 plugins on windows as well

--- cmake/InstallFAST.cmake
+++ cmake/InstallFAST.cmake
@@ -23,17 +23,18 @@
 	install(FILES ${SOs}
 		DESTINATION fast/lib
 	)
-	# Install Qt plugins
-	install(DIRECTORY ${PROJECT_BINARY_DIR}/plugins/
-        DESTINATION fast/QtPlugins/
-        FILES_MATCHING PATTERN "*.so"
-    )
-	# Install qt.conf
-    install(FILES ${PROJECT_SOURCE_DIR}/cmake/qt.conf
-        DESTINATION fast/bin
-    )
 endif()

+# Install Qt plugins
+install(DIRECTORY ${PROJECT_BINARY_DIR}/plugins/
+    DESTINATION fast/QtPlugins/
+    FILES_MATCHING PATTERN "*.so"
+)
+
+# Install qt.conf
+install(FILES ${PROJECT_SOURCE_DIR}/cmake/qt.conf
+    DESTINATION fast/bin
+)

 # Install headers
 install(DIRECTORY ${FAST_SOURCE_DIR}


cmake: extra_flags: fix EXTRA_CPPFLAGS being applied as macros

The EXTRA_CPPFLAGS is applied via zephyr_compile_definitions()
instead of zephyr_compile_options(), which makes all specified
options as macros. So fix it.

Signed-off-by: Daniel Leung <d94e04d205b5962d7873a139ef298b03c1717f72@intel.com>

--- cmake/extra_flags.cmake
+++ cmake/extra_flags.cmake
@@ -7,7 +7,7 @@
 separate_arguments(EXTRA_AFLAGS_AS_LIST   UNIX_COMMAND ${EXTRA_AFLAGS})

 if(EXTRA_CPPFLAGS)
-  zephyr_compile_definitions(${EXTRA_CPPFLAGS_AS_LIST})
+  zephyr_compile_options(${EXTRA_CPPFLAGS_AS_LIST})
 endif()
 if(EXTRA_LDFLAGS)
   zephyr_link_libraries(${EXTRA_LDFLAGS_AS_LIST})


update externalErrorMsg.tar.gz md5 value (#36126)

--- cmake/third_party.cmake
+++ cmake/third_party.cmake
@@ -252,7 +252,7 @@
         list(APPEND third_party_deps extern_cub)
     endif()
     set(URL  "https://paddlepaddledeps.bj.bcebos.com/externalErrorMsg.tar.gz" CACHE STRING "" FORCE)
-    file_download_and_uncompress(${URL} "externalError" MD5 c0749523ebb536eb7382487d645d9cd4)   # download file externalErrorMsg.tar.gz
+    file_download_and_uncompress(${URL} "externalError" MD5 061f3b7895aadcbe2c3ed592590f8b10)   # download file externalErrorMsg.tar.gz
     if(WITH_TESTING)
         # copy externalErrorMsg.pb, just for unittest can get error message correctly.
         set(SRC_DIR ${THIRD_PARTY_PATH}/externalError/data)


CMake: Add missing __WIN32__

CMake: Add missing __WIN32__

--- cmake/cpp.cmake
+++ cmake/cpp.cmake
@@ -90,6 +90,7 @@
 	Threads::Threads)
 if(WIN32)
 	target_link_libraries(${PROJECT_NAME} PUBLIC psapi.lib ws2_32.lib)
+target_compile_definitions(${PROJECT_NAME} PUBLIC __WIN32__)
 endif()
 target_compile_definitions(${PROJECT_NAME}
 	PUBLIC	USE_BOP USE_GLOP USE_CBC USE_CLP)


boost includes

boost includes

--- cmake/lib.cmake
+++ cmake/lib.cmake
@@ -3,7 +3,7 @@

 include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/CopyHeaders.cmake)

-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
+include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src)
 include_directories(${JSONCPP_INCLUDE_DIR})

 file(GLOB SOURCES


I'm pretty sure 'CXX_FLAGS' is a typo for 'CMAKE_CXX_FLAGS', and this is the reason why -fno-implicit-templates is removed from the entire build when sourcing this file, rather than just limited to yassl sources.

--- cmake/ssl.cmake
+++ cmake/ssl.cmake
@@ -29,14 +29,14 @@
   CHANGE_SSL_SETTINGS("bundled")
   #Remove -fno-implicit-templates
   #(yassl sources cannot  be compiled with  it)
-  SET(SAVE_CXX_FLAGS ${CXX_FLAGS})
+  SET(SAVE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
   IF(CMAKE_CXX_FLAGS)
   STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS
     ${CMAKE_CXX_FLAGS})
   ENDIF()
   ADD_SUBDIRECTORY(extra/yassl)
   ADD_SUBDIRECTORY(extra/yassl/taocrypt)
-  SET(CXX_FLAGS ${SAVE_CXX_FLAGS})
+  SET(CMAKE_CXX_FLAGS ${SAVE_CXX_FLAGS})
   GET_TARGET_PROPERTY(src yassl SOURCES)
   FOREACH(file ${src})
     SET(SSL_SOURCES ${SSL_SOURCES} ${CMAKE_SOURCE_DIR}/extra/yassl/${file})


added flag that allows setting ispc addressing to 64 bit

--- common/cmake/ispc.cmake
+++ common/cmake/ispc.cmake
@@ -22,6 +22,11 @@
 execute_process(COMMAND which ispc OUTPUT_VARIABLE ISPC_EXECUTABLE)
 execute_process(COMMAND dirname ${ISPC_EXECUTABLE} OUTPUT_VARIABLE ISPC_DIR_TEMP)
 STRING(REGEX REPLACE "\n" "" ISPC_DIR "${ISPC_DIR_TEMP}")
+
+SET(EMBREE_ISPC_ADDRESSING 32 CACHE INT
+	"32vs64 bit addressing in ispc")
+MARK_AS_ADVANCED(EMBREE_ISPC_ADDRESSING)
+

 MACRO (ispc_compile targets)
   IF (__XEON__)
@@ -96,6 +101,7 @@
       -I ${CMAKE_CURRENT_SOURCE_DIR}
       ${ISPC_INCLUDE_DIR_PARMS}
       --arch=${ISPC_ARCHITECTURE}
+			--addressing=${EMBREE_ISPC_ADDRESSING}
       --pic
       -O3
       --target=${ISPC_TARGETS}


Fix broken TBB check

Fix broken TBB check

--- lib/FindTBB.cmake
+++ lib/FindTBB.cmake
@@ -252,6 +252,7 @@

 if (TBB_INCLUDE_DIR)
     if (TBB_LIBRARY)
+    if (EXISTS "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h")
         set (TBB_FOUND "YES")
         set (TBB_LIBRARIES ${TBB_LIBRARY} ${TBB_MALLOC_LIBRARY} ${TBB_LIBRARIES})
         set (TBB_DEBUG_LIBRARIES ${TBB_LIBRARY_DEBUG} ${TBB_MALLOC_LIBRARY_DEBUG} ${TBB_DEBUG_LIBRARIES})
@@ -261,6 +262,7 @@
         set (TBB_DEBUG_LIBRARY_DIRS ${TBB_LIBRARY_DEBUG_DIR} CACHE PATH "TBB debug library directory" FORCE)
         mark_as_advanced(TBB_INCLUDE_DIRS TBB_LIBRARY_DIRS TBB_DEBUG_LIBRARY_DIRS TBB_LIBRARIES TBB_DEBUG_LIBRARIES)
         message(STATUS "Found Intel TBB")
+    endif ()
     endif (TBB_LIBRARY)
 endif (TBB_INCLUDE_DIR)


Detect processor to add "-march=native" and "-mtune=native" to release flag for gcc or clang.

--- CMake/cpp.cmake
+++ CMake/cpp.cmake
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION <%= executable('cmake') ? split(systemlist('cmake --version')[0], ' ')[2] : '3.1' %>)
-project(CMakeProject C CXX)
+project(<+DIR+> C CXX)

 set(CMAKE_C_STANDARD 11)
 set(CMAKE_C_STANDARD_REQUIRED ON)
@@ -29,7 +29,8 @@

 file(GLOB SRCS *.c *.cpp *.cxx *.cc)
-add_executable(<+CURSOR+>
+add_executable(
+  main<+CURSOR+>
   ${SRCS})

 # include_directories(${CMAKE_SOURCE_DIR})
@@ -37,53 +38,53 @@
 # find_package(Threads REQUIRED)
 # target_link_libraries(main m Threads::Threads)

-if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
-  add_definitions(-DNDEBUG)
+if (CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*")
+  set(SYSTEM_PROCESSOR_IS_X86 TRUE)
+endif()
+if (CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
+  set(SYSTEM_PROCESSOR_IS_X64 TRUE)
 endif()

 if(MSVC)
-  set(CMAKE_USE_RELATIVE_PATHS "ON")
-  if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
-    string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
-  else()
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
-  endif()
-  if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
-    string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-  else()
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
-  endif()
-  add_definitions(
-    -DWIN32_LEAN_AND_MEAN
-    -DNOMINMAX
-    -D_USE_MATH_DEFINES
-    -D_CRT_NONSTDC_NO_WARNINGS
-    -D_CRT_SECURE_NO_WARNINGS)
-
-  foreach(FLAG_VAR
-      CMAKE_C_FLAGS
-      CMAKE_C_FLAGS_DEBUG
-      CMAKE_C_FLAGS_RELEASE
-      CMAKE_C_FLAGS_MINSIZEREL
-      CMAKE_C_FLAGS_RELWITHDEBINFO
-      CMAKE_CXX_FLAGS
-      CMAKE_CXX_FLAGS_DEBUG
-      CMAKE_CXX_FLAGS_RELEASE
-      CMAKE_CXX_FLAGS_MINSIZEREL
-      CMAKE_CXX_FLAGS_RELWITHDEBINFO)
-    string(REGEX REPLACE "/RTC[^ ]*" "" ${FLAG_VAR} "${${FLAG_VAR}}")
-  endforeach(FLAG_VAR)
-
-  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Oi /Ot /Ox /Oy")
-  set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /Ot /Ox /Oy /GL")
-  # set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
-  set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /Os")
-
-  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Oi /Ot /Ox /Oy")
-  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /Ot /Ox /Oy /GL")
-  # set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
-  set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /Os")
+  set(USE_RELATIVE_PATHS ON)
+
+  foreach(TARGET_FLAG
+      C_FLAGS
+      C_FLAGS_DEBUG
+      C_FLAGS_RELEASE
+      C_FLAGS_MINSIZEREL
+      C_FLAGS_RELWITHDEBINFO
+      CXX_FLAGS
+      CXX_FLAGS_DEBUG
+      CXX_FLAGS_RELEASE
+      CXX_FLAGS_MINSIZEREL
+      CXX_FLAGS_RELWITHDEBINFO)
+    string(REGEX REPLACE "/RTC[^ ]*" "" ${TARGET_FLAG} "${CMAKE_${TARGET_FLAG}}")
+  endforeach(TARGET_FLAG)
+
+  foreach(
+      TARGET_FLAG
+      C_FLAGS
+      CXX_FLAGS)
+    if(C_FLAGS MATCHES "/W[0-4]")
+      string(REGEX REPLACE "/W[0-4]" "/W4" ${TARGET_FLAG} "${${TARGET_FLAG}}")
+    else()
+      set("${TARGET_FLAG}" "${${TARGET_FLAG}} /W4")
+    endif()
+  endforeach()
+
+  set(DEFLIST "-DWIN32_LEAN_AND_MEAN;-DNOMINMAX;-D_USE_MATH_DEFINES;-D_CRT_NONSTDC_NO_WARNINGS;-D_CRT_SECURE_NO_WARNINGS")
+
+  set(C_FLAGS_DEBUG "${C_FLAGS_DEBUG} /Oi /Oy")
+  set(C_FLAGS_RELEASE "${C_FLAGS_RELEASE} /Ob2 /Oi /Ot /Ox /Oy /GL")
+  set(C_FLAGS_MINSIZEREL "${C_FLAGS_MINSIZEREL} /Os")
+
+  set(CXX_FLAGS_DEBUG "${CXX_FLAGS_DEBUG} /Oi /Oy")
+  set(CXX_FLAGS_RELEASE "${CXX_FLAGS_RELEASE} /Ob2 /Oi /Ot /Ox /Oy /GL")
+  set(CXX_FLAGS_MINSIZEREL "${CXX_FLAGS_MINSIZEREL} /Os")
+
+  set(EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
 else()
   foreach(WARNING_FLAG
       -Wall
@@ -203,6 +204,20 @@
       string(REGEX REPLACE "-Wcast-align" "-Wcast-align=strict" C_WARNING_FLAGS "${C_WARNING_FLAGS}")
       set(C_WARNING_FLAGS "${C_WARNING_FLAGS} -Wsuggest-attribute=malloc")
     endif()
+
+    set(C_FLAGS "${CMAKE_C_FLAGS} -pipe ${C_WARNING_FLAGS}")
+    set(C_FLAGS_DEBUG "-g3 -O0 -ftrapv -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_DEBUG")
+    set(C_FLAGS_RELEASE "-O3 -DNDEBUG")
+    set(C_FLAGS_MINSIZEREL "-s -DNDEBUG")
+    if(SYSTEM_PROCESSOR_IS_X86 OR SYSTEM_PROCESSOR_IS_X64)
+      set(C_FLAGS_RELEASE "${C_FLAGS_RELEASE} -mtune=native -march=native")
+      set(C_FLAGS_MINSIZEREL "${C_FLAGS_MINSIZEREL} -mtune=native -march=native")
+    endif()
+    if(CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8)
+      set(C_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG")
+    else()
+      set(C_FLAGS_RELWITHDEBINFO "-g -Og -DNDEBUG")
+    endif()
   elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
     set(C_WARNING_FLAGS "${CLANG_COMMON_WARNING_FLAGS}")
     foreach(WARNING_FLAG
@@ -224,6 +239,26 @@
       message("-- Add warning flags implemented in clang 5.0")
       set(C_WARNING_FLAGS "${C_WARNING_FLAGS} -Wzero-as-null-pointer-constant")
     endif()
+
+    set(C_FLAGS "${CMAKE_C_FLAGS} -pipe ${C_WARNING_FLAGS}")
+    set(C_FLAGS_DEBUG "-g3 -O0 -ftrapv -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_DEBUG")
+    set(C_FLAGS_RELEASE "-O3 -DNDEBUG")
+    set(C_FLAGS_MINSIZEREL "-s -DNDEBUG")
+    if(SYSTEM_PROCESSOR_IS_X86 OR SYSTEM_PROCESSOR_IS_X64)
+      set(C_FLAGS_RELEASE "${C_FLAGS_RELEASE} -mtune=native -march=native")
+      set(C_FLAGS_MINSIZEREL "${C_FLAGS_MINSIZEREL} -mtune=native -march=native")
+    endif()
+    if(CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0)
+      set(C_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG")
+    else()
+      set(C_FLAGS_RELWITHDEBINFO "-g -Og -DNDEBUG")
+    endif()
+  else()
+    set(C_FLAGS "${CMAKE_C_FLAGS}")
+    set(C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
+    set(C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
+    set(C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
+    set(C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
   endif()

   if(CMAKE_COMPILER_IS_GNUCXX)
@@ -320,7 +355,21 @@
       string(REGEX REPLACE "-Wcast-align" "-Wcast-align=strict" CXX_WARNING_FLAGS "${CXX_WARNING_FLAGS}")
       set(CXX_WARNING_FLAGS "${CXX_WARNING_FLAGS} -Wsuggest-attribute=malloc")
     endif()
-  else()
+
+    set(CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe ${CXX_WARNING_FLAGS}")
+    set(CXX_FLAGS_DEBUG "-g3 -O0 -ftrapv -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_DEBUG")
+    set(CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
+    set(CXX_FLAGS_MINSIZEREL "-s -DNDEBUG")
+    if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
+      set(CXX_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG")
+    else()
+      set(CXX_FLAGS_RELWITHDEBINFO "-g -Og -DNDEBUG")
+    endif()
+    if(SYSTEM_PROCESSOR_IS_X86 OR SYSTEM_PROCESSOR_IS_X64)
+      set(CXX_FLAGS_RELEASE "${CXX_FLAGS_RELEASE} -mtune=native -march=native")
+      set(CXX_FLAGS_MINSIZEREL "${CXX_FLAGS_MINSIZEREL} -mtune=native -march=native")
+    endif()
+  elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
     set(CXX_WARNING_FLAGS "${CLANG_COMMON_WARNING_FLAGS}")
     foreach(WARNING_FLAG
         -Wc++11-compat
@@ -351,27 +400,30 @@
       string(REGEX REPLACE "-Wc\\+\\+1z-compat" "-Wc++17-compat" CXX_WARNING_FLAGS "${CXX_WARNING_FLAGS}")
       set(CXX_WARNING_FLAGS "${CXX_WARNING_FLAGS} -Wzero-as-null-pointer-constant")
     endif()
+
+    set(CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe ${CXX_WARNING_FLAGS}")
+    set(CXX_FLAGS_DEBUG "-g3 -O0 -ftrapv -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_DEBUG")
+    set(CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
+    set(CXX_FLAGS_MINSIZEREL "-s -DNDEBUG")
+    if(SYSTEM_PROCESSOR_IS_X86 OR SYSTEM_PROCESSOR_IS_X64)
+      set(CXX_FLAGS_RELEASE "${CXX_FLAGS_RELEASE} -mtune=native -march=native")
+      set(CXX_FLAGS_MINSIZEREL "${CXX_FLAGS_MINSIZEREL} -mtune=native -march=native")
+    endif()
+    if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0)
+      set(CXX_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG")
+    else()
+      set(CXX_FLAGS_RELWITHDEBINFO "-g -Og -DNDEBUG")
+    endif()
+  else()
+    set(CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+    set(CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
+    set(CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
+    set(CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
+    set(CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
   endif()

-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_WARNING_FLAGS} ${C_WARNING_FLAGS}")
-  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g3 -O0 -ftrapv -fstack-protector-all")
-  set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -mtune=native -march=native")
-  set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -g3 -Og")
-  set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -Os -mtune=native -march=native")
-
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_WARNING_FLAGS} ${CXX_WARNING_FLAGS}")
-  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -O0 -ftrapv -fstack-protector-all")
-  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -mtune=native -march=native")
-  set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g3 -Og")
-  set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -mtune=native -march=native")
-
-  set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s")
-  set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -s")
-
-
-  if(CMAKE_BUILD_TYPE MATCHES Debug)
-    add_definitions(-D_FORTIFY_SOURCE=2 -D_GLIBCXX_DEBUG)
-  endif()
+  set(EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s")
+  set(EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -s")

   install(TARGETS main
     RUNTIME DESTINATION bin
@@ -381,9 +433,30 @@
   add_custom_target(uninstall xargs rm < install_manifest.txt)
 endif()

-
-string(REGEX REPLACE "^ +" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
-string(REGEX REPLACE "^ +" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+if(DEFLIST)
+  foreach(DEF "${DEFLIST}")
+    add_definitions(${DEF})
+  endforeach(DEF)
+endif()
+
+foreach(TARGET_FLAG
+    C_FLAGS
+    C_FLAGS_DEBUG
+    C_FLAGS_RELEASE C_FLAGS_RELWITHDEBINFO
+    C_FLAGS_MINSIZEREL
+    CXX_FLAGS
+    CXX_FLAGS_DEBUG
+    CXX_FLAGS_RELEASE
+    CXX_FLAGS_RELWITHDEBINFO
+    CXX_FLAGS_MINSIZEREL
+    EXE_LINKER_FLAGS
+    EXE_LINKER_FLAGS_DEBUG
+    EXE_LINKER_FLAGS_RELEASE
+    EXE_LINKER_FLAGS_RELWITHDEBINFO
+    EXE_LINKER_FLAGS_MINSIZEREL)
+  string(REGEX REPLACE "^ +" "" "${TARGET_FLAG}" "${${TARGET_FLAG}}")
+  string(REGEX REPLACE "  +" " " "CMAKE_${TARGET_FLAG}" "${${TARGET_FLAG}}")
+endforeach(TARGET_FLAG)

 option(ENABLE_TESTING "Enable testing with Google Test." OFF)
@@ -404,17 +477,20 @@

 foreach(VARNAME
     CMAKE_SYSTEM_NAME
+    CMAKE_SYSTEM_PROCESSOR
     CMAKE_SOURCE_DIR
     CMAKE_BINARY_DIR
     CMAKE_BUILD_TYPE
     CMAKE_CONFIGURATION_TYPES
     CMAKE_COMPILER_IS_GNUCC
     CMAKE_COMPILER_IS_GNUCXX
+    CMAKE_C_COMPILER
     CMAKE_C_FLAGS
     CMAKE_C_FLAGS_DEBUG
     CMAKE_C_FLAGS_RELEASE
     CMAKE_C_FLAGS_RELWITHDEBINFO
     CMAKE_C_FLAGS_MINSIZEREL
+    CMAKE_CXX_COMPILER
     CMAKE_CXX_FLAGS
     CMAKE_CXX_FLAGS_DEBUG
     CMAKE_CXX_FLAGS_RELEASE


Spacify matcher messages

Spacify matcher messages

--- CMakeUnit.cmake
+++ CMakeUnit.cmake
@@ -1752,8 +1752,11 @@
                                           ARGN_VAR REMAINING_ARGN
                                           ARGN ${CALLER_ARGN})

+    cmake_spacify_list (REMAINING_ARGN_SPACIFIED
+                        LIST ${REMAINING_ARGN}
+                        NO_QUOTES)
     set (${RESULT_VARIABLE}
-         "contents of ${FILE} to match ${MATCHER} ${REMAINING_ARGN}"
+         "contents of ${FILE} to match ${MATCHER} ${REMAINING_ARGN_SPACIFIED}"
          PARENT_SCOPE)

     file (READ "${FILE}" FILE_CONTENTS)
@@ -1811,8 +1814,11 @@
                                           ARGN_VAR REMAINING_ARGN
                                           ARGN ${CALLER_ARGN})

+    cmake_spacify_list (REMAINING_ARGN_SPACIFIED
+                        LIST ${REMAINING_ARGN}
+                        NO_QUOTES)
     set (${RESULT_VARIABLE}
-         "any line of contents to match ${MATCHER} ${REMAINING_ARGN}"
+         "any line of contents to match ${MATCHER} ${REMAINING_ARGN_SPACIFIED}"
          PARENT_SCOPE)

     # Split the string into individual lines


update FindGflags.cmake to work on CentOS 8.x (#1409)

Summary:
Update FindGflags.cmake to work on recent CentOS and RedHat distributions.

On these distributions the CMake package configuration installed by the
gflags-devel RPM is slightly broken, and sets `gflags_INCLUDE_DIR` to a
directory that does not exist.  This happens because `/lib64` is symlinked to
`/usr/lib64`, and CMake ends up searching `/lib64` before `/usr/lib64` by
default when searching for packages.  Therefore it finds `gflags-config.cmake`
via the `/lib64` symlink.  However, `gflags-config.cmake` computes the include
directory relative to where its config file was found, and this relative path
computation only works when using the actual `/usr/lib64` path where it was
installed.  When found via `/lib64` it returns a bogus `//include` path that
does not exist.

This updates `FindGflags.cmake` to verify if the `gflags_INCLUDE_DIR` path
actually exists, and set it to a sane location instead.

This also updates the code to use the `gflags-shared` target that is exported
by the default gflags package configuration if it was only built as a shared
library.

Pull Request resolved: https://github.com/facebook/folly/pull/1409

Reviewed By: yfeldblum

Differential Revision: D23588288

fbshipit-source-id: b68a717953ae0521f568d7bcfd05ca33cd6dc578

--- build/fbcode_builder/CMake/FindGflags.cmake
+++ build/fbcode_builder/CMake/FindGflags.cmake
@@ -41,6 +41,16 @@
   # Re-export the config-specified libs with our local names
   set(LIBGFLAGS_LIBRARY ${gflags_LIBRARIES})
   set(LIBGFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIR})
+  if(NOT EXISTS "${gflags_INCLUDE_DIR}")
+    # The gflags-devel RPM on recent RedHat-based systems is somewhat broken.
+    # RedHat symlinks /lib64 to /usr/lib64, and this breaks some of the
+    # relative path computation performed in gflags-config.cmake.  The package
+    # config file ends up being found via /lib64, but the relative path
+    # computation it does only works if it was found in /usr/lib64.
+    # If gflags_INCLUDE_DIR does not actually exist, simply default it to
+    # /usr/include on these systems.
+    set(LIBGFLAGS_INCLUDE_DIR "/usr/include")
+  endif()
   set(LIBGFLAGS_FOUND ${gflags_FOUND})
   # cmake module compat
   set(GFLAGS_FOUND ${gflags_FOUND})
@@ -76,6 +86,20 @@
 # Compat with the gflags CONFIG based detection
 if (LIBGFLAGS_FOUND AND NOT TARGET gflags)
   add_library(gflags UNKNOWN IMPORTED)
-  set_target_properties(gflags PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBGFLAGS_INCLUDE_DIR}")
-  set_target_properties(gflags PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${LIBGFLAGS_LIBRARY}")
+  if(TARGET gflags-shared)
+    # If the installed gflags CMake package config defines a gflags-shared
+    # target but not gflags, just make the gflags target that we define
+    # depend on the gflags-shared target.
+    target_link_libraries(gflags INTERFACE gflags-shared)
+    # Export LIBGFLAGS_LIBRARY as the gflags-shared target in this case.
+    set(LIBGFLAGS_LIBRARY gflags-shared)
+  else()
+    set_target_properties(
+      gflags
+      PROPERTIES
+        IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+        IMPORTED_LOCATION "${LIBGFLAGS_LIBRARY}"
+        INTERFACE_INCLUDE_DIRECTORIES "${LIBGFLAGS_INCLUDE_DIR}"
+    )
+  endif()
 endif()


not using openblas

not using openblas

--- cmake/External/eigen.cmake
+++ cmake/External/eigen.cmake
@@ -5,7 +5,7 @@

 set( Eigen3_VERSION "3.3.3" )

-#add_definitions(-DEIGEN_USE_BLAS -DEIGEN_USE_LAPACKE)
+add_definitions(-DEIGEN_USE_BLAS -DEIGEN_USE_LAPACKE)
 find_package(BLAS REQUIRED)
 ExternalProject_Add(eigen
     PREFIX ${EIGEN_PREFIX}


Version information marked as advanced

Version information marked as advanced

--- cmake/MyPackageStart.cmake
+++ cmake/MyPackageStart.cmake
@@ -9,6 +9,12 @@
   SET (${_PROJECTNAME}_VERSION_MINOR ${versionMinor})
   SET (${_PROJECTNAME}_VERSION_PATCH ${versionPatch})
   SET (${_PROJECTNAME}_VERSION "${${_PROJECTNAME}_VERSION_MAJOR}.${${_PROJECTNAME}_VERSION_MINOR}.${${_PROJECTNAME}_VERSION_PATCH}")
+  MARK_AS_ADVANCED(
+    ${_PROJECTNAME}_VERSION_MAJOR
+    ${_PROJECTNAME}_VERSION_MINOR
+    ${_PROJECTNAME}_VERSION_PATH
+    ${_PROJECTNAME}_VERSION
+    )
   #
   # Options
   #


bugfix: cxxabi.h was not found

bugfix: cxxabi.h was not found

--- configure.cmake
+++ configure.cmake
@@ -178,6 +178,7 @@
 # Tests for header files
 #
 INCLUDE (CheckIncludeFiles)
+INCLUDE (CheckIncludeFileCXX)

 CHECK_INCLUDE_FILES ("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
 CHECK_INCLUDE_FILES (sys/types.h HAVE_SYS_TYPES_H)
@@ -185,7 +186,7 @@
 CHECK_INCLUDE_FILES (aio.h HAVE_AIO_H)
 CHECK_INCLUDE_FILES (arpa/inet.h HAVE_ARPA_INET_H)
 CHECK_INCLUDE_FILES (crypt.h HAVE_CRYPT_H)
-CHECK_INCLUDE_FILES (cxxabi.h HAVE_CXXABI_H)
+CHECK_INCLUDE_FILE_CXX (cxxabi.h HAVE_CXXABI_H)
 CHECK_INCLUDE_FILES (bfd.h HAVE_BFD_H)
 CHECK_INCLUDE_FILES (dirent.h HAVE_DIRENT_H)
 CHECK_INCLUDE_FILES (dlfcn.h HAVE_DLFCN_H)


Remove Findtinyxml2.cmake

Remove Findtinyxml2.cmake

--- cmake/Modules/Findtinyxml2.cmake
+++ cmake/Modules/Findtinyxml2.cmake
@@ -1,28 +0,0 @@
-# - Find TinyXML
-# Find the native TinyXML includes and library
-#
-# TINYXML2_FOUND - True if TinyXML found.
-# TINYXML2_INCLUDE_DIR - where to find tinyxml.h, etc.
-# TINYXML2_LIBRARIES - List of libraries when using TinyXML.
-#
-
-IF( TINYXML2_INCLUDE_DIR )
-# Already in cache, be silent
-SET( TinyXML2_FIND_QUIETLY TRUE )
-ENDIF( TINYXML2_INCLUDE_DIR )
-
-FIND_PATH( TINYXML2_INCLUDE_DIR "tinyxml2.h"
-HINTS "thirdparty/tinyxml2/"
-PATH_SUFFIXES "tinyxml" "tinyxml2")
-
-FIND_LIBRARY( TINYXML2_LIBRARIES
-NAMES "tinyxml2"
-PATH_SUFFIXES "tinyxml"
-HINTS /usr/lib64 thirdparty/tinyxml2/lib)
-
-# handle the QUIETLY and REQUIRED arguments and set TINYXML_FOUND to TRUE if
-# all listed variables are TRUE
-INCLUDE( "FindPackageHandleStandardArgs" )
-FIND_PACKAGE_HANDLE_STANDARD_ARGS( "TinyXML2" DEFAULT_MSG TINYXML2_INCLUDE_DIR TINYXML2_LIBRARIES )
-
-MARK_AS_ADVANCED( TINYXML2_INCLUDE_DIR TINYXML2_LIBRARIES )


Add Plugin: Reformat CMake code

Add Plugin: Reformat CMake code

--- cmake/Modules/LibAddPlugin.cmake
+++ cmake/Modules/LibAddPlugin.cmake
@@ -1,6 +1,7 @@
-include(LibAddMacros)
+include (LibAddMacros)
 include (LibAddTest)

+# ~~~
 # Add a test for a plugin
 #
 # Will include the common tests.h file + its source file
@@ -20,26 +21,38 @@
 #
 # links the executable (only if build_static or build_full)
 # and adds a test
+# ~~~
 function (add_plugintest testname)
 	if (NOT ADDTESTING_PHASE)
 		return ()
 	endif ()

 	if (BUILD_TESTING)
+		set (MULTI_VALUE_KEYWORDS
+		     COMPILE_DEFINITIONS
+		     INCLUDE_DIRECTORIES
+		     LINK_LIBRARIES
+		     LINK_ELEKTRA
+		     TEST_LINK_LIBRARIES
+		     TEST_LINK_ELEKTRA
+		     LINK_PLUGIN
+		     WORKING_DIRECTORY)
+
 		cmake_parse_arguments (ARG
-			"MEMLEAK;INSTALL_TEST_DATA" # optional keywords
-			"INCLUDE_SYSTEM_DIRECTORIES"        # one value keywords
-			"COMPILE_DEFINITIONS;INCLUDE_DIRECTORIES;LINK_LIBRARIES;LINK_ELEKTRA;TEST_LINK_LIBRARIES;TEST_LINK_ELEKTRA;LINK_PLUGIN;WORKING_DIRECTORY" # multi value keywords
-			${ARGN}
-		)
+				       "MEMLEAK;INSTALL_TEST_DATA" # optional keywords
+				       "INCLUDE_SYSTEM_DIRECTORIES" # one value keywords
+				       "${MULTI_VALUE_KEYWORDS}" # multi value keywords
+				       ${ARGN})

 		list (FIND ADDED_PLUGINS "${testname}" FOUND_NAME)
 		if (FOUND_NAME EQUAL -1)
 			if (NOT ARG_LINK_PLUGIN)
-				message (FATAL_ERROR "Trying to add plugintest ${testname} but no such plugin was added (try to use LINK_PLUGIN)")
+				message (
+					FATAL_ERROR
+						"Trying to add plugintest ${testname} but no such plugin was added (try to use LINK_PLUGIN)"
+					)
 			endif ()
 		endif ()
-

 		set (PLUGIN_NAME elektra-${testname})
 		restore_variable (${PLUGIN_NAME} ARG_LINK_LIBRARIES)
@@ -53,10 +66,7 @@
 		restore_variable (${PLUGIN_NAME} ARG_TEST_LINK_LIBRARIES)
 		restore_variable (${PLUGIN_NAME} ARG_TEST_LINK_ELEKTRA)

-		set (TEST_SOURCES
-				$<TARGET_OBJECTS:cframework>
-				${ARG_OBJECT_SOURCES}
-				)
+		set (TEST_SOURCES $<TARGET_OBJECTS:cframework> ${ARG_OBJECT_SOURCES})

 		foreach (A ${ARG_UNPARSED_ARGUMENTS})
 			if (EXISTS "${A}")
@@ -66,8 +76,8 @@
 			endif ()
 		endforeach ()

-		add_headers(TEST_SOURCES)
-		add_testheaders(TEST_SOURCES)
+		add_headers (TEST_SOURCES)
+		add_testheaders (TEST_SOURCES)
 		include_directories ("${CMAKE_SOURCE_DIR}/tests/cframework")
 		list (APPEND TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/testmod_${testname}.c")
 		if (BUILD_SHARED)
@@ -77,8 +87,8 @@
 					set (PLUGIN_TARGET_OBJS "$<TARGET_OBJECTS:elektra-${ARG_LINK_PLUGIN}-objects>")
 				endif ()
 			else ()
-				#assume that testcase+plugin to be tested have same name:
-				set (PLUGIN_TARGET_OBJS "$<TARGET_OBJECTS:elektra-${testname}-objects>")
+				set (PLUGIN_TARGET_OBJS "$<TARGET_OBJECTS:elektra-${testname}-objects>") # assume that testcase+plugin to be
+													 # tested have same name:
 			endif ()
 			list (APPEND TEST_SOURCES "${PLUGIN_TARGET_OBJS}")
 		endif ()
@@ -87,30 +97,28 @@
 		add_dependencies (${testexename} kdberrors_generated)

 		# alternative approach to restore_variable
-		#get_target_property(TARGET_COMPILE_DEFINITIONS PLUGIN_TARGET_OBJS COMPILE_DEFINITIONS)
+		# get_target_property(TARGET_COMPILE_DEFINITIONS PLUGIN_TARGET_OBJS COMPILE_DEFINITIONS)

 		if (INSTALL_TESTING)
-			install (TARGETS ${testexename}
-				DESTINATION "${TARGET_TOOL_EXEC_FOLDER}")
+			install (TARGETS ${testexename} DESTINATION "${TARGET_TOOL_EXEC_FOLDER}")
 			if (ARG_INSTALL_TEST_DATA)
 				install (DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${testname}" DESTINATION "${TARGET_TEST_DATA_FOLDER}")
 			endif ()
 		endif (INSTALL_TESTING)

-		target_link_elektra(${testexename} elektra-kdb elektra-plugin ${ARG_LINK_ELEKTRA} ${ARG_TEST_LINK_ELEKTRA})
+		target_link_elektra (${testexename} elektra-kdb elektra-plugin ${ARG_LINK_ELEKTRA} ${ARG_TEST_LINK_ELEKTRA})

 		target_link_libraries (${testexename} ${ARG_LINK_LIBRARIES} ${ARG_TEST_LINK_LIBRARIES})
-		set_target_properties (${testexename} PROPERTIES
-				COMPILE_DEFINITIONS "HAVE_KDBCONFIG_H;ELEKTRA_PLUGIN_TEST;${ARG_COMPILE_DEFINITIONS}")
-		set_property(TARGET ${testexename}
-				APPEND PROPERTY INCLUDE_DIRECTORIES
-				${ARG_INCLUDE_DIRECTORIES})
+		set_target_properties (${testexename}
+				       PROPERTIES COMPILE_DEFINITIONS
+						  "HAVE_KDBCONFIG_H;ELEKTRA_PLUGIN_TEST;${ARG_COMPILE_DEFINITIONS}")
+		set_property (TARGET ${testexename} APPEND PROPERTY INCLUDE_DIRECTORIES ${ARG_INCLUDE_DIRECTORIES})
 		if (ARG_INCLUDE_SYSTEM_DIRECTORIES AND NOT ARG_INCLUDE_SYSTEM_DIRECTORIES STREQUAL "/usr/include")
-			set_property(TARGET ${testexename}
-					APPEND PROPERTY COMPILE_FLAGS
-					"${CMAKE_INCLUDE_SYSTEM_FLAG_CXX} ${ARG_INCLUDE_SYSTEM_DIRECTORIES}")
-		endif ()
-
+			set_property (TARGET ${testexename}
+				      APPEND
+				      PROPERTY COMPILE_FLAGS
+					       "${CMAKE_INCLUDE_SYSTEM_FLAG_CXX} ${ARG_INCLUDE_SYSTEM_DIRECTORIES}")
+		endif ()

 		if (ARG_WORKING_DIRECTORY)
 			set (WORKING_DIRECTORY "${ARG_WORKING_DIRECTORY}")
@@ -119,50 +127,45 @@
 		endif ()

 		add_test (NAME ${testexename}
-				COMMAND "${CMAKE_BINARY_DIR}/bin/${testexename}" "${CMAKE_CURRENT_SOURCE_DIR}"
-				WORKING_DIRECTORY "${WORKING_DIRECTORY}"
-				)
-		set_property(TEST ${testexename} PROPERTY
-				ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib")
+			  COMMAND "${CMAKE_BINARY_DIR}/bin/${testexename}" "${CMAKE_CURRENT_SOURCE_DIR}"
+			  WORKING_DIRECTORY "${WORKING_DIRECTORY}")
+		set_property (TEST ${testexename} PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib")
 		if (ARG_MEMLEAK)
-			set_property(TEST ${testexename} PROPERTY
-				LABELS memleak)
+			set_property (TEST ${testexename} PROPERTY LABELS memleak)
 		endif (ARG_MEMLEAK)
 	endif ()
 endfunction (add_plugintest)
-

 function (plugin_check_if_included PLUGIN_SHORT_NAME)
 	list (FIND PLUGINS "-${PLUGIN_SHORT_NAME}" FOUND_EXCLUDE_NAME)
 	if (FOUND_EXCLUDE_NAME GREATER -1)
-		set (NOT_INCLUDED "explicitly excluded" PARENT_SCOPE)
-		# let explicit exclusion win
+		set (NOT_INCLUDED "explicitly excluded" PARENT_SCOPE) # let explicit exclusion win
+
 		return ()
 	endif ()

 	list (FIND PLUGINS "${PLUGIN_SHORT_NAME}" FOUND_NAME)
 	if (FOUND_NAME EQUAL -1)
-		set (NOT_INCLUDED "silent" PARENT_SCOPE)
-		# maybe it is included by category
+		set (NOT_INCLUDED "silent" PARENT_SCOPE) # maybe it is included by category
+
 	else ()
-		# plugin is given explicit
-		return ()
-	endif ()
-
-	FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/README.md contents)
-	STRING (REGEX MATCH "- +infos/status *= *([-a-zA-Z0-9 ]*)" CATEGORIES "${contents}")
-	STRING (REGEX REPLACE "- +infos/status *= *([-a-zA-Z0-9 ]*)" "\\1" CATEGORIES "${CATEGORIES}")
-	STRING (REGEX REPLACE " " ";" CATEGORIES "${CATEGORIES}")
-
-	STRING (REGEX MATCH "- +infos/provides *= *([a-zA-Z0-9/ ]*)" PROVIDES "${contents}")
-	STRING (REGEX REPLACE "- +infos/provides *= *([a-zA-Z0-9/ ]*)" "\\1" PROVIDES "${PROVIDES}")
-	STRING (REGEX REPLACE " " ";" PROVIDES "${PROVIDES}")
+
+		return () # plugin is given explicit
+	endif ()
+
+	file (READ ${CMAKE_CURRENT_SOURCE_DIR}/README.md contents)
+	string (REGEX MATCH "- +infos/status *= *([-a-zA-Z0-9 ]*)" CATEGORIES "${contents}")
+	string (REGEX REPLACE "- +infos/status *= *([-a-zA-Z0-9 ]*)" "\\1" CATEGORIES "${CATEGORIES}")
+	string (REGEX REPLACE " " ";" CATEGORIES "${CATEGORIES}")
+
+	string (REGEX MATCH "- +infos/provides *= *([a-zA-Z0-9/ ]*)" PROVIDES "${contents}")
+	string (REGEX REPLACE "- +infos/provides *= *([a-zA-Z0-9/ ]*)" "\\1" PROVIDES "${PROVIDES}")
+	string (REGEX REPLACE " " ";" PROVIDES "${PROVIDES}")
 	list (APPEND CATEGORIES "ALL" "${PROVIDES}")

 	split_plugin_providers (CATEGORIES)

-	STRING (TOUPPER "${CATEGORIES}" CATEGORIES)
-	#message (STATUS "CATEGORIES ${CATEGORIES}")
+	string (TOUPPER "${CATEGORIES}" CATEGORIES) # message (STATUS "CATEGORIES ${CATEGORIES}")

 	foreach (CAT ${CATEGORIES})
 		list (FIND PLUGINS "-${CAT}" FOUND_EXCLUDE_CATEGORY)
@@ -186,24 +189,30 @@
 	get_property (VAR GLOBAL PROPERTY "${PROP_NAME}")
 	if (VAR)
 		if (DEFINED ${VARIABLE})
+
 			# both stored and given by user: do consistency check
-			#message (STATUS "consistency check, plugin ${PLUGIN_NAME} got ${VARIABLE} reset to ${VAR}")
+			# message (STATUS "consistency check, plugin ${PLUGIN_NAME} got ${VARIABLE} reset to ${VAR}")
 			if (NOT ${VARIABLE} STREQUAL "${VAR}")
-				message (FATAL_ERROR "Internally inconsistency, plugin ${PLUGIN_NAME} got different values for variable ${VARIABLE}: '${${VARIABLE}}' != '${VAR}'")
+				message (
+					FATAL_ERROR
+						"Internally inconsistency, plugin ${PLUGIN_NAME} got different values for variable ${VARIABLE}: '${${VARIABLE}}' != '${VAR}'"
+					)
 			endif ()
 		else ()
+
 			# stored, but not given by user, use what was stored
 			set (${VARIABLE} ${VAR} PARENT_SCOPE)
 		endif ()
 	else ()
 		if (DEFINED ${VARIABLE})
+
 			# given by user, but not stored: store it
 			set_property (GLOBAL PROPERTY "${PROP_NAME}" "${${VARIABLE}}")
 		endif ()
 	endif ()
 endfunction ()

-
+# ~~~
 # add_plugin: register and potentially add a plugin
 #
 # SOURCES:
@@ -250,15 +259,23 @@
 #
 # TEST_LINK_ELEKTRA:
 #   like LINK_ELEKTRA but only applies to plugin tests
-#
+# ~~~
 function (add_plugin PLUGIN_SHORT_NAME)
+	set (MULTI_VALUE_KEYWORDS
+	     SOURCES
+	     OBJECT_SOURCES
+	     LINK_LIBRARIES
+	     COMPILE_DEFINITIONS
+	     INCLUDE_DIRECTORIES
+	     LINK_ELEKTRA
+	     DEPENDS
+	     TEST_ENVIRONMENT
+	     TEST_REQUIRED_PLUGINS)
 	cmake_parse_arguments (ARG
-		"CPP;ADD_TEST;TEST_README;INSTALL_TEST_DATA" # optional keywords
-		"INCLUDE_SYSTEM_DIRECTORIES" # one value keywords
-		# multi value keywords
-		"SOURCES;OBJECT_SOURCES;LINK_LIBRARIES;COMPILE_DEFINITIONS;INCLUDE_DIRECTORIES;LINK_ELEKTRA;DEPENDS;TEST_ENVIRONMENT;TEST_REQUIRED_PLUGINS"
-		${ARGN}
-	)
+			       "CPP;ADD_TEST;TEST_README;INSTALL_TEST_DATA" # optional keywords
+			       "INCLUDE_SYSTEM_DIRECTORIES" # one value keywords
+			       "${MULTI_VALUE_KEYWORDS}" # multi value keywords
+			       ${ARGN})

 	set (PLUGIN_NAME elektra-${PLUGIN_SHORT_NAME})
 	set (PLUGIN_OBJS ${PLUGIN_NAME}-objects)
@@ -284,7 +301,9 @@
 	if (ADDTESTING_PHASE)
 		if (ARG_INSTALL_TEST_DATA AND NOT ARG_ADD_TEST)
 			if (INSTALL_TESTING)
-				install (DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN_SHORT_NAME}" DESTINATION "${TARGET_TEST_DATA_FOLDER}")
+				install (DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN_SHORT_NAME}"
+						   DESTINATION
+						   "${TARGET_TEST_DATA_FOLDER}")
 			endif (INSTALL_TESTING)
 		endif ()

@@ -301,21 +320,18 @@
 					INCLUDE_DIRECTORIES "${ARG_INCLUDE_DIRECTORIES}"
 					INCLUDE_SYSTEM_DIRECTORIES "${ARG_INCLUDE_SYSTEM_DIRECTORIES}"
 					LINK_ELEKTRA "${ARG_LINK_ELEKTRA}"
-					"${HAS_INSTALL_TEST_DATA}"
-					)
+						     "${HAS_INSTALL_TEST_DATA}")
 		endif ()

 		if (ARG_TEST_README)
-			add_msr_test_plugin (${PLUGIN_SHORT_NAME}
-				ENVIRONMENT ${ARG_TEST_ENVIRONMENT}
-				REQUIRED_PLUGINS ${ARG_TEST_REQUIRED_PLUGINS})
+			add_msr_test_plugin (
+				${PLUGIN_SHORT_NAME} ENVIRONMENT ${ARG_TEST_ENVIRONMENT} REQUIRED_PLUGINS ${ARG_TEST_REQUIRED_PLUGINS})
 		endif (ARG_TEST_README)

 		return ()
 	endif ()

-
-	#message (STATUS "enter add_plugin ${PLUGIN_SHORT_NAME}")
+	# message (STATUS "enter add_plugin ${PLUGIN_SHORT_NAME}")

 	if (COLLECTION_PHASE)
 		set (NOT_INCLUDED "")
@@ -336,7 +352,7 @@
 		endif ()

 		# needed for variants where PLUGIN_SHORT_NAME != PLUGIN_FOLDER_NAME
-		get_filename_component(PLUGIN_FOLDER_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
+		get_filename_component (PLUGIN_FOLDER_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
 		if (ADDED_DIRECTORIES)
 			set (TMP "${ADDED_DIRECTORIES};${PLUGIN_FOLDER_NAME}")
 			list (SORT TMP)
@@ -346,17 +362,18 @@
 			set (ADDED_DIRECTORIES "${PLUGIN_FOLDER_NAME}" CACHE STRING "${ADDED_DIRECTORIES_DOC}" FORCE)
 		endif ()

-		return()
-	endif ()
-
+		return ()
+	endif ()

 	list (FIND ADDED_PLUGINS "${PLUGIN_SHORT_NAME}" FOUND_NAME)
 	if (FOUND_NAME EQUAL -1)
 		list (FIND REMOVED_PLUGINS "${PLUGIN_SHORT_NAME}" FOUND_NAME)
 		if (FOUND_NAME EQUAL -1)
-			message (FATAL_ERROR "Internally inconsistency, plugin ${PLUGIN_SHORT_NAME} is not there, but was not removed: ${REMOVED_PLUGINS}")
-		endif ()
-		# plugin was not added in previous phase or removed because of missing deps, exit quietly
+			message (
+				FATAL_ERROR
+					"Internally inconsistency, plugin ${PLUGIN_SHORT_NAME} is not there, but was not removed: ${REMOVED_PLUGINS}"
+				)
+		endif () # plugin was not added in previous phase or removed because of missing deps, exit quietly
 		return ()
 	endif ()

@@ -364,19 +381,19 @@
 		message (FATAL_ERROR "Assert failed, should be in dependency phase")
 	endif ()

-	#message (STATUS "name: ${PLUGIN_NAME}")
-	#message (STATUS "srcs are: ${ARG_SOURCES}")
-	#message (STATUS "deps are: ${ARG_LINK_LIBRARIES}")
-	#message (STATUS "comp are: ${ARG_COMPILE_DEFINITIONS}")
-	#message (STATUS "incl are: ${ARG_INCLUDE_DIRECTORIES}")
-	#message (STATUS "system incl are: ${ARG_INCLUDE_SYSTEM_DIRECTORIES}")
-	#message (STATUS "current bin ${CMAKE_CURRENT_BINARY_DIR}")
+	# message (STATUS "name: ${PLUGIN_NAME}")
+	# message (STATUS "srcs are: ${ARG_SOURCES}")
+	# message (STATUS "deps are: ${ARG_LINK_LIBRARIES}")
+	# message (STATUS "comp are: ${ARG_COMPILE_DEFINITIONS}")
+	# message (STATUS "incl are: ${ARG_INCLUDE_DIRECTORIES}")
+	# message (STATUS "system incl are: ${ARG_INCLUDE_SYSTEM_DIRECTORIES}")
+	# message (STATUS "current bin ${CMAKE_CURRENT_BINARY_DIR}")

 	message (STATUS "Include Plugin ${PLUGIN_SHORT_NAME}")

-	add_headers(ARG_SOURCES)
+	add_headers (ARG_SOURCES)
 	if (ARG_CPP)
-		add_cppheaders(ARG_SOURCES)
+		add_cppheaders (ARG_SOURCES)
 	endif (ARG_CPP)

 	add_library (${PLUGIN_OBJS} OBJECT ${ARG_SOURCES})
@@ -387,31 +404,33 @@

 	generate_readme (${PLUGIN_SHORT_NAME})

-	set_property(TARGET ${PLUGIN_OBJS}
-		APPEND PROPERTY COMPILE_DEFINITIONS
-		${ARG_COMPILE_DEFINITIONS}
-		"ELEKTRA_STATIC"
-		"HAVE_KDBCONFIG_H"
-		"PLUGIN_SHORT_NAME=${PLUGIN_SHORT_NAME}"
-		"README=readme_${PLUGIN_SHORT_NAME}.c"
-		)
-
-	set_property(TARGET ${PLUGIN_OBJS}
-		APPEND PROPERTY INCLUDE_DIRECTORIES
-		${ARG_INCLUDE_DIRECTORIES}
-		${CMAKE_CURRENT_BINARY_DIR} #for readme
-		)
+	set_property (TARGET ${PLUGIN_OBJS}
+		      APPEND
+		      PROPERTY COMPILE_DEFINITIONS
+			       ${ARG_COMPILE_DEFINITIONS}
+			       "ELEKTRA_STATIC"
+			       "HAVE_KDBCONFIG_H"
+			       "PLUGIN_SHORT_NAME=${PLUGIN_SHORT_NAME}"
+			       "README=readme_${PLUGIN_SHORT_NAME}.c")
+
+	set_property (TARGET ${PLUGIN_OBJS}
+		      APPEND
+		      PROPERTY INCLUDE_DIRECTORIES
+			       ${ARG_INCLUDE_DIRECTORIES}
+			       ${CMAKE_CURRENT_BINARY_DIR} # for readme
+		      )

 	if (ARG_INCLUDE_SYSTEM_DIRECTORIES AND NOT ARG_INCLUDE_SYSTEM_DIRECTORIES STREQUAL "/usr/include")
-		set_property(TARGET ${PLUGIN_OBJS}
-			APPEND PROPERTY COMPILE_FLAGS
-			"${CMAKE_INCLUDE_SYSTEM_FLAG_CXX} ${ARG_INCLUDE_SYSTEM_DIRECTORIES} ${CMAKE_PIC_FLAGS}"
-			)
+		set_property (TARGET ${PLUGIN_OBJS}
+			      APPEND
+			      PROPERTY COMPILE_FLAGS
+				       "${CMAKE_INCLUDE_SYSTEM_FLAG_CXX} ${ARG_INCLUDE_SYSTEM_DIRECTORIES} ${CMAKE_PIC_FLAGS}")
 	else ()
-		set_property(TARGET ${PLUGIN_OBJS}
-			APPEND PROPERTY COMPILE_FLAGS
-			${CMAKE_PIC_FLAGS} # needed for shared libraries
-			)
+		set_property (TARGET ${PLUGIN_OBJS}
+			      APPEND
+			      PROPERTY COMPILE_FLAGS
+				       ${CMAKE_PIC_FLAGS} # needed for shared libraries
+			      )
 	endif ()

 	set_property (TARGET ${PLUGIN_OBJS} PROPERTY CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -424,47 +443,40 @@
 		endif ()
 		if (ARG_LINK_ELEKTRA)
 			target_link_libraries (${PLUGIN_NAME} elektra-plugin ${ARG_LINK_ELEKTRA})
-		else()
+		else ()
 			target_link_libraries (${PLUGIN_NAME} elektra-plugin)
 		endif ()
-		target_link_libraries (${PLUGIN_NAME}
-			${ARG_LINK_LIBRARIES})
-		install (TARGETS ${PLUGIN_NAME} DESTINATION
-			lib${LIB_SUFFIX}/${TARGET_PLUGIN_FOLDER})
-		set_property(TARGET ${PLUGIN_NAME}
-			APPEND PROPERTY
-			COMPILE_DEFINITIONS
-			${ARG_COMPILE_DEFINITIONS}
-			"HAVE_KDBCONFIG_H"
-			"PLUGIN_SHORT_NAME=${PLUGIN_SHORT_NAME}"
-			"README=readme_${PLUGIN_SHORT_NAME}.c"
-			)
-		set_property(TARGET ${PLUGIN_NAME}
-			APPEND PROPERTY INCLUDE_DIRECTORIES
-			${ARG_INCLUDE_DIRECTORIES}
-			${CMAKE_CURRENT_BINARY_DIR} #for readme
-			)
+		target_link_libraries (${PLUGIN_NAME} ${ARG_LINK_LIBRARIES})
+		install (TARGETS ${PLUGIN_NAME} DESTINATION lib${LIB_SUFFIX}/${TARGET_PLUGIN_FOLDER})
+		set_property (TARGET ${PLUGIN_NAME}
+			      APPEND
+			      PROPERTY COMPILE_DEFINITIONS
+				       ${ARG_COMPILE_DEFINITIONS}
+				       "HAVE_KDBCONFIG_H"
+				       "PLUGIN_SHORT_NAME=${PLUGIN_SHORT_NAME}"
+				       "README=readme_${PLUGIN_SHORT_NAME}.c")
+		set_property (TARGET ${PLUGIN_NAME}
+			      APPEND
+			      PROPERTY INCLUDE_DIRECTORIES
+				       ${ARG_INCLUDE_DIRECTORIES}
+				       ${CMAKE_CURRENT_BINARY_DIR} # for readme
+			      )
 		if (ARG_INCLUDE_SYSTEM_DIRECTORIES AND NOT ARG_INCLUDE_SYSTEM_DIRECTORIES STREQUAL "/usr/include")
-			set_property(TARGET ${PLUGIN_NAME}
-				APPEND PROPERTY COMPILE_FLAGS
-				"${CMAKE_INCLUDE_SYSTEM_FLAG_CXX} ${ARG_INCLUDE_SYSTEM_DIRECTORIES}"
-				)
+			set_property (TARGET ${PLUGIN_NAME}
+				      APPEND
+				      PROPERTY COMPILE_FLAGS
+					       "${CMAKE_INCLUDE_SYSTEM_FLAG_CXX} ${ARG_INCLUDE_SYSTEM_DIRECTORIES}")
 		endif ()
 		if (${LD_ACCEPTS_VERSION_SCRIPT})
-			set_property(TARGET ${PLUGIN_NAME}
-				APPEND PROPERTY LINK_FLAGS
-				"-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/plugins/plugin-symbols.map"
-				)
-		endif ()
-	endif()
-
-	#message (STATUS "added ${PLUGIN_TARGET_OBJS}")
-	set_property (GLOBAL APPEND PROPERTY "elektra-full_SRCS"
-		${PLUGIN_TARGET_OBJS}
-		${ARG_OBJECT_SOURCES}
-		)
-
-	set_property (GLOBAL APPEND PROPERTY "elektra-full_LIBRARIES"
-		"${ARG_LINK_LIBRARIES}"
-		)
-endfunction(add_plugin)
+			set_property (TARGET ${PLUGIN_NAME}
+				      APPEND
+				      PROPERTY LINK_FLAGS
+					       "-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/plugins/plugin-symbols.map")
+		endif ()
+	endif ()
+
+	# message (STATUS "added ${PLUGIN_TARGET_OBJS}")
+	set_property (GLOBAL APPEND PROPERTY "elektra-full_SRCS" ${PLUGIN_TARGET_OBJS} ${ARG_OBJECT_SOURCES})
+
+	set_property (GLOBAL APPEND PROPERTY "elektra-full_LIBRARIES" "${ARG_LINK_LIBRARIES}")
+endfunction (add_plugin)


Revert 834172 so that automoc4 is found at the correct place.

svn path=/trunk/kdesupport/akonadi/; revision=834451

--- cmake/modules/FindAutomoc4.cmake
+++ cmake/modules/FindAutomoc4.cmake
@@ -20,7 +20,7 @@
 # check if we are inside KDESupport and automoc is enabled
 if("${KDESupport_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
    # when building this project as part of kdesupport
-   set(AUTOMOC4_CONFIG_FILE "${KDESupport_BINARY_DIR}/automoc/Automoc4Config.cmake")
+   set(AUTOMOC4_CONFIG_FILE "${KDESupport_SOURCE_DIR}/automoc/Automoc4Config.cmake")
 else("${KDESupport_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
    # when building this project outside kdesupport


win: Adding additional hints to Kerberos

--- cmake/modules/FindKerberos.cmake
+++ cmake/modules/FindKerberos.cmake
@@ -16,7 +16,8 @@
 else()
   # Setup the hints and patch for the Kerberos SDK location
   set(_KERBEROS_ROOT_PATHS "${PROJECT_SOURCE_DIR}/lib/kerberos/")
-  set(_KERBEROS_ROOT_HINTS ${KERBEROS_ROOT_DIR} $ENV{KERBEROS_ROOT_DIR})
+  set(_KERBEROS_ROOT_HINTS ${KERBEROS_ROOT_DIR} $ENV{KERBEROS_ROOT_DIR}
+                           $ENV{KERBEROS_ROOT_DIR}/MIT/Kerberos)
   if(WIN32)
     if(CMAKE_CL_64)
       set(_KERBEROS_SDK_PROGRAMFILES "$ENV{PROGRAMW6432}")


CMake: Simplify and streamline FindSUNDIALS.cmake

--- cmake/modules/FindSUNDIALS.cmake
+++ cmake/modules/FindSUNDIALS.cmake
@@ -18,12 +18,9 @@
 #
 # This module exports
 #
-#   SUNDIALS_LIB_IDA(S)
-#   SUNDIALS_LIB_ARKODE
-#   SUNDIALS_LIB_KINSOL
-#   SUNDIALS_LIB_PAR
-#   SUNDIALS_LIB_SER
+#   SUNDIALS_LIBRARIES
 #   SUNDIALS_INCLUDE_DIR
+#   SUNDIALS_WITH_IDAS
 #
 # Note that sundials headers are typically installed in several directories,
 # e.g.,
@@ -43,16 +40,10 @@
   PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib
   )

-IF(SUNDIALS_LIB_IDAS MATCHES "-NOTFOUND")
-  DEAL_II_FIND_LIBRARY(SUNDIALS_LIB_IDA NAMES sundials_ida
-    HINTS ${SUNDIALS_DIR}
-    PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib
-    )
-  SET(SUNDIALS_IDA_TYPE "IDA")
-ELSE()
-  ADD_DEFINITIONS(-DDEAL_II_WITH_SUNDIALS_IDAS)
-  SET(SUNDIALS_IDA_TYPE "IDAS")
-ENDIF()
+DEAL_II_FIND_LIBRARY(SUNDIALS_LIB_IDA NAMES sundials_ida
+  HINTS ${SUNDIALS_DIR}
+  PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib
+  )

 DEAL_II_FIND_LIBRARY(SUNDIALS_LIB_ARKODE NAMES sundials_arkode
   HINTS ${SUNDIALS_DIR}
@@ -69,48 +60,42 @@
   PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib
   )

-#
-# only define the extra hint if ${SUNDIALS_DIR} is nonempty so that we do not
-# try to search through the top-level '/include/' directory, should it happen to
-# exist
-#
-STRING(COMPARE EQUAL "${SUNDIALS_DIR}" "" _sundials_dir_is_empty)
-IF(NOT ${_sundials_dir_is_empty})
-  SET(_sundials_include_hint_dir "${SUNDIALS_DIR}/include/")
-ENDIF()
-
 DEAL_II_FIND_PATH(SUNDIALS_INCLUDE_DIR sundials/sundials_nvector.h
-  HINTS ${SUNDIALS_DIR} "${_sundials_include_hint_dir}"
+  HINTS ${SUNDIALS_DIR}
+  PATH_SUFFIXES include
 )

-SET(_sundials_additional_libs)
+SET(_sundials_lib_par)
 IF(DEAL_II_WITH_MPI)
   DEAL_II_FIND_LIBRARY(SUNDIALS_LIB_PAR NAMES sundials_nvecparallel
     HINTS ${SUNDIALS_DIR}
     PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib
     )
-  SET(_sundials_additional_libs SUNDIALS_LIB_PAR)
+  SET(_sundials_lib_par "SUNDIALS_LIB_PAR")
+ENDIF()
+
+#
+# If IDAS is available, we prefer said library over IDA. We have to make
+# sure to only link one of the two library variants:
+#
+IF(NOT SUNDIALS_LIB_IDAS MATCHES "-NOTFOUND")
+  SET(_sundials_lib_ida "SUNDIALS_LIB_IDAS")
+  SET(SUNDIALS_WITH_IDAS TRUE)
+ELSE()
+  SET(_sundials_lib_ida "SUNDIALS_LIB_IDA")
+  SET(SUNDIALS_WITH_IDAS FALSE)
+ENDIF()
+
+
 DEAL_II_PACKAGE_HANDLE(SUNDIALS
   LIBRARIES REQUIRED
-    SUNDIALS_LIB_${SUNDIALS_IDA_TYPE} SUNDIALS_LIB_ARKODE SUNDIALS_LIB_KINSOL SUNDIALS_LIB_SER SUNDIALS_LIB_PAR
-    ${_sundials_additional_libs}
-  INCLUDE_DIRS REQUIRED SUNDIALS_INCLUDE_DIR
-  USER_INCLUDE_DIRS REQUIRED SUNDIALS_INCLUDE_DIR
+    ${_sundials_lib_ida} SUNDIALS_LIB_ARKODE
+    SUNDIALS_LIB_KINSOL SUNDIALS_LIB_SER ${_sundials_lib_par}
+  INCLUDE_DIRS REQUIRED
+    SUNDIALS_INCLUDE_DIR
+  USER_INCLUDE_DIRS REQUIRED
+    SUNDIALS_INCLUDE_DIR
   CLEAR
-    SUNDIALS_LIB_${SUNDIALS_IDA_TYPE} SUNDIALS_LIB_ARKODE SUNDIALS_LIB_KINSOL
-    SUNDIALS_LIB_SER SUNDIALS_LIB_PAR
+    SUNDIALS_LIB_IDA SUNDIALS_LIB_IDAS SUNDIALS_LIB_ARKODE
+    SUNDIALS_LIB_KINSOL SUNDIALS_LIB_SER ${_sundials_lib_par}
   )
-ELSE()
-DEAL_II_PACKAGE_HANDLE(SUNDIALS
-  LIBRARIES REQUIRED
-    SUNDIALS_LIB_${SUNDIALS_IDA_TYPE} SUNDIALS_LIB_ARKODE SUNDIALS_LIB_KINSOL SUNDIALS_LIB_SER
-    ${_sundials_additional_libs}
-  INCLUDE_DIRS REQUIRED SUNDIALS_INCLUDE_DIR
-  USER_INCLUDE_DIRS REQUIRED SUNDIALS_INCLUDE_DIR
-  CLEAR
-    SUNDIALS_LIB_${SUNDIALS_IDA_TYPE} SUNDIALS_LIB_ARKODE SUNDIALS_LIB_KINSOL
-    SUNDIALS_LIB_SER
-  )
-
-ENDIF()
-


add arm64 support for M1 Mac

add arm64 support for M1 Mac

--- cmake/modules/SwiftSupport.cmake
+++ cmake/modules/SwiftSupport.cmake
@@ -8,6 +8,8 @@
 function(get_swift_host_arch result_var_name)
   if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
     set("${result_var_name}" "x86_64" PARENT_SCOPE)
+  elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
+    set("${result_var_name}" "arm64" PARENT_SCOPE)
   elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
     set("${result_var_name}" "aarch64" PARENT_SCOPE)
   elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64")


Added header dir.

Added header dir.

--- cmake/modules/cpp_resource.cmake
+++ cmake/modules/cpp_resource.cmake
@@ -45,6 +45,7 @@
   set_property(TARGET ${name} PROPERTY _AR_RSC_FILE ${RSC_FILE_NAME})
   set_property(TARGET ${name} PROPERTY _AR_H_FILE   ${RSC_OUT_H})
   set_property(TARGET ${name} PROPERTY _AR_SRC_FILE ${RSC_OUT_CPP})
+  set_property(TARGET ${name} PROPERTY _AR_H_DIR ${CMAKE_CURRENT_BINARY_DIR})

   message(STATUS ${RSC_OUT_H})


Disable autostart for now so usb works.

Disable autostart for now so usb works.

--- cmake/nuttx/px4_impl_nuttx.cmake
+++ cmake/nuttx/px4_impl_nuttx.cmake
@@ -291,21 +291,23 @@
 	set(romfs_pruner ${CMAKE_SOURCE_DIR}/Tools/px_romfs_pruner.py)
 	set(bin_to_obj ${CMAKE_SOURCE_DIR}/cmake/nuttx/bin_to_obj.py)

-
 	#message(STATUS "temp_dir: ${romfs_temp_dir}")
 	#message(STATUS "src_dir: ${romfs_src_dir}")

 	add_custom_command(OUTPUT rc.autostart
 		COMMAND ${PYTHON_EXECUTABLE} ${romfs_autostart}
-			-a ${romfs_src_dir}/init.d/
+			-a ${romfs_src_dir}/init.d
 			-s rc.autostart
 		)

 	add_custom_command(OUTPUT romfs.bin
 		COMMAND cmake -E remove_directory ${romfs_temp_dir}
 		COMMAND cmake -E copy_directory ${romfs_src_dir} ${romfs_temp_dir}
-		COMMAND cmake -E copy rc.autostart ${romfs_temp_dir}/init.d
-		#TODO add romfs cleanup and pruning
+		# TODO XXX hack to get nsh to work, copying real
+	    # autostart in currently makes nsh fail over usb
+		COMMAND cmake -E touch ${romfs_temp_dir}/init.d/rc.autostart
+		#COMMAND cmake -E copy rc.autostart ${romfs_temp_dir}/init.d
+		#TODO add romfs cleanup of temp file .~, .swp etc
 		COMMAND ${PYTHON_EXECUTABLE} ${romfs_pruner}
 			--folder ${romfs_temp_dir}
 		COMMAND ${GENROMFS} -f ${CMAKE_CURRENT_BINARY_DIR}/romfs.bin


Fix FindTBB for win32 and for MSVC10/11

Fix FindTBB for win32 and for MSVC10/11

--- common/cmake/FindTBB.cmake
+++ common/cmake/FindTBB.cmake
@@ -15,21 +15,32 @@
 ## ======================================================================== ##

 IF (WIN32)
-  FIND_PATH(TBB_ROOT_PARENT tbb PATHS "${PROJECT_SOURCE_DIR}" "C:/Program Files (x86)/Intel/Composer XE")
-  SET(TBB_ROOT ${TBB_ROOT_PARENT}/tbb CACHE STRING "Root of TBB installation")
+  FIND_PATH(TBB_ROOT include/tbb/task_scheduler_init.h
+    DOC "Root of TBB installation"
+    PATHS ${PROJECT_SOURCE_DIR}/tbb "C:/Program Files (x86)/Intel/Composer XE/tbb"
+  )

-  IF (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
-    SET(TBB_SUBDIR intel64)
+  IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
+    SET(TBB_ARCH intel64)
   ELSE()
-    SET(TBB_SUBDIR ia32)
+    SET(TBB_ARCH ia32)
   ENDIF()
-
+
+  IF (MSVC10)
+    SET(TBB_VCVER vc10)
+  ELSEIF (MSVC11)
+    SET(TBB_VCVER vc11)
+  ELSE()
+    SET(TBB_VCVER vc12)
+  ENDIF()
+
+  SET(TBB_LIBDIR ${TBB_ROOT}/lib/${TBB_ARCH}/${TBB_VCVER})
+
   FIND_PATH(TBB_INCLUDE_DIR tbb/task_scheduler_init.h PATHS ${TBB_ROOT}/include)
-  FIND_LIBRARY(TBB_LIBRARY tbb PATHS ${TBB_ROOT}/lib/${TBB_SUBDIR}/vc12)
-  FIND_LIBRARY(TBB_LIBRARY_MALLOC tbbmalloc PATHS ${TBB_ROOT}/lib/${TBB_SUBDIR}/vc12)
-
+  FIND_LIBRARY(TBB_LIBRARY tbb PATHS ${TBB_LIBDIR} NO_SYSTEM_ENVIRONMENT_PATH)
+  FIND_LIBRARY(TBB_LIBRARY_MALLOC tbbmalloc PATHS ${TBB_LIBDIR} NO_SYSTEM_ENVIRONMENT_PATH)
 ELSE ()
-  SET(TBB_ROOT /opt/intel/composerxe/tbb/ CACHE STRING "Root of TBB installation")
+  SET(TBB_ROOT /opt/intel/composerxe/tbb/ CACHE PATH "Root of TBB installation")

   FIND_PATH(TBB_INCLUDE_DIR tbb/task_scheduler_init.h PATHS ${TBB_ROOT}/include)
   IF (APPLE)
@@ -43,6 +54,10 @@
   FIND_PATH(TBB_INCLUDE_DIR_MIC tbb/task_scheduler_init.h NO_DEFAULT_PATH PATHS ${TBB_ROOT}/include)
   FIND_LIBRARY(TBB_LIBRARY_MIC tbb NO_DEFAULT_PATH PATHS ${TBB_ROOT}/lib/mic)
   FIND_LIBRARY(TBB_LIBRARY_MALLOC_MIC tbbmalloc NO_DEFAULT_PATH PATHS ${TBB_ROOT}/lib/mic)
+
+  MARK_AS_ADVANCED(TBB_INCLUDE_DIR_MIC)
+  MARK_AS_ADVANCED(TBB_LIBRARY_MIC)
+  MARK_AS_ADVANCED(TBB_LIBRARY_MALLOC_MIC)
 ENDIF()

 INCLUDE(FindPackageHandleStandardArgs)
@@ -51,7 +66,7 @@
 IF (TBB_FOUND)
   SET(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
   SET(TBB_LIBRARIES ${TBB_LIBRARY} ${TBB_LIBRARY_MALLOC})
-ENDIF ()
+ENDIF()

 IF (TBB_INCLUDE_DIR AND TBB_LIBRARY_MIC AND TBB_LIBRARY_MALLOC_MIC)
   SET(TBB_FOUND_MIC TRUE)
@@ -59,13 +74,6 @@
   SET(TBB_LIBRARIES_MIC ${TBB_LIBRARY_MIC} ${TBB_LIBRARY_MALLOC_MIC})
 ENDIF()

-MARK_AS_ADVANCED(TBB_ROOT_PARENT)
-
 MARK_AS_ADVANCED(TBB_INCLUDE_DIR)
 MARK_AS_ADVANCED(TBB_LIBRARY)
 MARK_AS_ADVANCED(TBB_LIBRARY_MALLOC)
-
-MARK_AS_ADVANCED(TBB_INCLUDE_DIR_MIC)
-MARK_AS_ADVANCED(TBB_LIBRARY_MIC)
-MARK_AS_ADVANCED(TBB_LIBRARY_MALLOC_MIC)
-


mindpx-v2: build topic_listener, sd_bench, tests, motor_ramp.

--- cmake/configs/nuttx_mindpx-v2_default.cmake
+++ cmake/configs/nuttx_mindpx-v2_default.cmake
@@ -64,13 +64,16 @@
 	systemcmds/pwm
 	systemcmds/esc_calib
 	systemcmds/reboot
-	#systemcmds/topic_listener
+	systemcmds/topic_listener
 	systemcmds/top
 	systemcmds/config
 	systemcmds/nshterm
 	systemcmds/mtd
 	systemcmds/dumpfile
 	systemcmds/ver
+	systemcmds/sd_bench
+	systemcmds/tests
+	systemcmds/motor_ramp

 	#
 	# General system control
@@ -95,7 +98,6 @@
 	#
 	# Vehicle Control
 	#
-	# modules/segway # XXX Needs GCC 4.7 fix
 	modules/fw_pos_control_l1
 	modules/fw_att_control
 	modules/mc_att_control


[CMake] Add interface includes for gtest and gmock targets.

When linking against gtest/gmock, the include directories are not added
to the newly created targets. This adds INTERFACE includes to these
targets, so includes for all subsequent targets will fall into place.

--- cmake/modules/SearchInstalledSoftware.cmake
+++ cmake/modules/SearchInstalledSoftware.cmake
@@ -1598,6 +1598,8 @@
   ExternalProject_Get_Property(googletest source_dir)
   set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include)
   set(GMOCK_INCLUDE_DIR ${source_dir}/googlemock/include)
+  # Create the directories. Prevents bug https://gitlab.kitware.com/cmake/cmake/issues/15052
+  file(MAKE_DIRECTORY ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR})

   # Libraries
   ExternalProject_Get_Property(googletest binary_dir)
@@ -1612,6 +1614,9 @@
       target_compile_options(${lib} INTERFACE -Wno-deprecated-copy)
     endif()
   endforeach()
+  target_include_directories(gtest INTERFACE ${GTEST_INCLUDE_DIR})
+  target_include_directories(gmock INTERFACE ${GMOCK_INCLUDE_DIR})
+
   set_property(TARGET gtest PROPERTY IMPORTED_LOCATION ${_G_LIBRARY_PATH}/gtest/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX})
   set_property(TARGET gtest_main PROPERTY IMPORTED_LOCATION ${_G_LIBRARY_PATH}/gtest/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX})
   set_property(TARGET gmock PROPERTY IMPORTED_LOCATION ${_G_LIBRARY_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX})


Quote variable to avoid CMake syntax warning

CMake Warning (dev) at
googletest-prefix/src/googletest-stamp/googletest-configure-RelWithDebInfo.cmake:3:
  Syntax Warning in cmake code at column 471

  Argument not separated from preceding token by whitespace.
This warning is for project developers.  Use -Wno-dev to suppress it.

Warning introduced by f892e5e99c0e92326fd54eab059fc5a801762210.

--- cmake/modules/SearchInstalledSoftware.cmake
+++ cmake/modules/SearchInstalledSoftware.cmake
@@ -1593,6 +1593,12 @@
     ${_gtest_byproduct_binary_dir}/libgmock_main.a
     )

+  if(MSVC)
+    set(EXTRA_GTEST_OPTS
+      -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=\\\"\\\"
+      -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=\\\"\\\")
+  endif()
+
   ExternalProject_Add(
     googletest
     GIT_REPOSITORY https://github.com/google/googletest.git
@@ -1611,8 +1617,7 @@
                   -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
                   -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
                   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-                  -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=""
-                  -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=""
+                  ${EXTRA_GTEST_OPTS}
     # Disable install step
     INSTALL_COMMAND ""
     BUILD_BYPRODUCTS ${_gtest_byproducts}


From Pere: pass -DLLVM_FORCE_USE_OLD_TOOLCHAIN=ON to llvm.

--- cmake/modules/SearchInstalledSoftware.cmake
+++ cmake/modules/SearchInstalledSoftware.cmake
@@ -591,6 +591,7 @@
                  -DLLVM_INCLUDE_EXAMPLES=OFF
                  -DLLVM_BUILD_TOOLS=OFF
                  -DLLVM_TARGETS_TO_BUILD=X86
+                 -DLLVM_FORCE_USE_OLD_TOOLCHAIN=ON
                  -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
                  -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
                  -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}


Do not warn about needing builtin_veccore when it's already enabled

--- cmake/modules/SearchInstalledSoftware.cmake
+++ cmake/modules/SearchInstalledSoftware.cmake
@@ -1317,7 +1317,7 @@
 endif()

 #---Check for VecCore--------------------------------------------------------------------
-if(veccore AND builtin_vc)
+if(veccore AND NOT builtin_veccore AND builtin_vc)
   message(WARNING "Vc is not relocatable, so 'builtin_vc' requires 'builtin_veccore' to set up Vc properly.")
   set(builtin_veccore ON CACHE BOOL "" FORCE)
 endif()


cmake: Remove `QUIET` flag of BLAS `find_package` call and search only if `imt` is activated

--- cmake/modules/SearchInstalledSoftware.cmake
+++ cmake/modules/SearchInstalledSoftware.cmake
@@ -1309,9 +1309,9 @@
   endif()
 endif()

-if(tmva)
+if(tmva AND imt)
   message(STATUS "Looking for BLAS for optional parts of TMVA")
-  find_package(BLAS QUIET)
+  find_package(BLAS)
 endif()

 #---Report non implemented options---------------------------------------------------