Adds a basic support to add external platforms

fixes #41

Adds a new functions register_hardware_platform(). This functions takes
a path to the hardware platform such as
${ARDUINO_SDK_PATH}/hardware/${PLATFORM} and creates the varibles:

${PLATFORM}_CORES_PATH if cores exists
${PLATFORM}_BOARDS_PATH if boards.txt exists
${PLATFORM}_BOARDS if boards.txt exists
${PLATFORM}_PROGRAMMERS_PATH if programmers exists
${PLATFORM}_VARIENTS if varients exists

${PLATFORM} is the uppercase of the last directory name and so is
compatable with the previous variable names (ie hardware/arduino will
create ARDUINO_CORES_PATHS...)

Removes the now unused load boards and programmers methods for the
arduino platforms as this is now handeled by the new function.

Adds some new varibles;
  PLATFORMS lists all the registered platforms.
  VARIANTS  lists all the registared variants.
  ${variant}.path the path of the pins header file for the variant this
    is now used instead as the include path rather then
    ${ARDUINO_VARIANTS_PATH}/${variant}

Modifies the print boards and programmers to list all the platform
boards and programmers.

--- cmake/Platform/Arduino.cmake
+++ cmake/Platform/Arduino.cmake
@@ -187,9 +187,13 @@
 # see documentation at top
 #=============================================================================#
 function(PRINT_BOARD_LIST)
-    message(STATUS "Arduino Boards:")
-    print_list(ARDUINO_BOARDS)
-    message(STATUS "")
+    foreach(PLATFORM ${PLATFORMS})
+        if(${PLATFORM}_BOARDS)
+            message(STATUS "${PLATFORM} Boards:")
+            print_list(${PLATFORM}_BOARDS)
+            message(STATUS "")
+        endif()
+    endforeach()
 endfunction()

 #=============================================================================#
@@ -200,9 +204,13 @@
 # see documentation at top
 #=============================================================================#
 function(PRINT_PROGRAMMER_LIST)
-    message(STATUS "Arduino Programmers:")
-    print_list(ARDUINO_PROGRAMMERS)
-    message(STATUS "")
+    foreach(PLATFORM ${PLATFORMS})
+        if(${PLATFORM}_PROGRAMMERS)
+            message(STATUS "${PLATFORM} Programmers:")
+            print_list(${PLATFORM}_PROGRAMMERS)
+        endif()
+        message(STATUS "")
+    endforeach()
 endfunction()

 #=============================================================================#
@@ -414,6 +422,67 @@
 endfunction()

 #=============================================================================#
+# [PUBLIC/USER]
+# see documentation at top
+#=============================================================================#
+function(REGISTER_HARDWARE_PLATFORM PLATFORM_PATH)
+    string(REGEX REPLACE "/$" "" PLATFORM_PATH ${PLATFORM_PATH})
+    message(STATUS "Loading hardware path: ${PLATFORM_PATH}")
+    GET_FILENAME_COMPONENT(PLATFORM ${PLATFORM_PATH} NAME)
+
+    if(PLATFORM) # TODO only load a platform once
+        string(TOUPPER ${PLATFORM} PLATFORM)
+        set(${PLATFORM}_PLATFORM_PATH ${PLATFORM_PATH} CACHE INTERNAL "The path to ${PLATFORM}")
+        set(PLATFORMS ${PLATFORMS} ${PLATFORM} CACHE INTERNAL "A list of registered platforms")
+
+        find_file(${PLATFORM}_CORES_PATH
+              NAMES cores
+              PATHS ${PLATFORM_PATH}
+              DOC "Path to directory containing the Arduino core sources.")
+
+        find_file(${PLATFORM}_VARIANTS_PATH
+              NAMES variants
+              PATHS ${PLATFORM_PATH}
+              DOC "Path to directory containing the Arduino variant sources.")
+
+        find_file(${PLATFORM}_BOOTLOADERS_PATH
+              NAMES bootloaders
+              PATHS ${PLATFORM_PATH}
+              DOC "Path to directory containing the Arduino bootloader images and sources.")
+
+        find_file(${PLATFORM}_PROGRAMMERS_PATH
+            NAMES programmers.txt
+            PATHS ${PLATFORM_PATH}
+            DOC "Path to Arduino programmers definition file.")
+
+        find_file(${PLATFORM}_BOARDS_PATH
+            NAMES boards.txt
+            PATHS ${PLATFORM_PATH}
+            DOC "Path to Arduino boards definition file.")
+
+        if(${PLATFORM}_BOARDS_PATH)
+            load_arduino_style_settings(${PLATFORM}_BOARDS "${PLATFORM_PATH}/boards.txt")
+        endif()
+
+        if(${PLATFORM}_PROGRAMMERS_PATH)
+            load_arduino_style_settings(${PLATFORM}_PROGRAMMERS "${ARDUINO_PROGRAMMERS_PATH}")
+        endif()
+
+        if(${PLATFORM}_VARIANTS_PATH)
+            file(GLOB sub-dir ${${PLATFORM}_VARIANTS_PATH}/*)
+            foreach(dir ${sub-dir})
+                if(IS_DIRECTORY ${dir})
+                    get_filename_component(variant ${dir} NAME)
+                    set(VARIANTS ${list_of_dirs} ${variant} CACHE INTERNAL "A list of registered variant boards")
+                    set(${variant}.path ${dir} CACHE INTERNAL "The path to the variant ${variant}")
+                endif()
+            endforeach()
+        endif()
+    endif()
+
+endfunction()
+
+#=============================================================================#
 #                        Internal Functions
 #=============================================================================#

@@ -445,17 +514,17 @@
 # Load the Arduino SDK board settings from the boards.txt file.
 #
 #=============================================================================#
-function(LOAD_BOARD_SETTINGS)
-    load_arduino_style_settings(ARDUINO_BOARDS "${ARDUINO_BOARDS_PATH}")
-endfunction()
-
-#=============================================================================#
-# [PRIVATE/INTERNAL]
-#
-#=============================================================================#
-function(LOAD_PROGRAMMERS_SETTINGS)
-    load_arduino_style_settings(ARDUINO_PROGRAMMERS "${ARDUINO_PROGRAMMERS_PATH}")
-endfunction()
+#function(LOAD_BOARD_SETTINGS)
+#    load_arduino_style_settings(ARDUINO_BOARDS "${ARDUINO_BOARDS_PATH}")
+#endfunction()
+
+#=============================================================================#
+# [PRIVATE/INTERNAL]
+#
+#=============================================================================#
+#function(LOAD_PROGRAMMERS_SETTINGS)
+#    load_arduino_style_settings(ARDUINO_PROGRAMMERS "${ARDUINO_PROGRAMMERS_PATH}")
+#endfunction()

 #=============================================================================#
 # [PRIVATE/INTERNAL]
@@ -534,9 +603,9 @@
         endif()
         set(LINK_FLAGS "-mmcu=${${BOARD_ID}.build.mcu}")
         if(ARDUINO_SDK_VERSION VERSION_GREATER 1.0 OR ARDUINO_SDK_VERSION VERSION_EQUAL 1.0)
-            set(PIN_HEADER ${${BOARD_ID}.build.variant})
             if(NOT MANUAL)
-              set(COMPILE_FLAGS "${COMPILE_FLAGS} -I\"${ARDUINO_VARIANTS_PATH}/${PIN_HEADER}\"")
+                set(PIN_HEADER ${${${BOARD_ID}.build.variant}.path})
+                set(COMPILE_FLAGS "${COMPILE_FLAGS} -I\"${PIN_HEADER}\"")
             endif()
         endif()

@@ -1734,40 +1803,12 @@
 #                          Initialization
 #=============================================================================#
 if(NOT ARDUINO_FOUND AND ARDUINO_SDK_PATH)
-    find_file(ARDUINO_CORES_PATH
-              NAMES cores
-              PATHS ${ARDUINO_SDK_PATH}
-              PATH_SUFFIXES hardware/arduino
-              DOC "Path to directory containing the Arduino core sources.")
-
-    find_file(ARDUINO_VARIANTS_PATH
-              NAMES variants
-              PATHS ${ARDUINO_SDK_PATH}
-              PATH_SUFFIXES hardware/arduino
-              DOC "Path to directory containing the Arduino variant sources.")
-
-    find_file(ARDUINO_BOOTLOADERS_PATH
-              NAMES bootloaders
-              PATHS ${ARDUINO_SDK_PATH}
-              PATH_SUFFIXES hardware/arduino
-              DOC "Path to directory containing the Arduino bootloader images and sources.")
+    register_hardware_platform(${ARDUINO_SDK_PATH}/hardware/arduino/)

     find_file(ARDUINO_LIBRARIES_PATH
-              NAMES libraries
-              PATHS ${ARDUINO_SDK_PATH}
-              DOC "Path to directory containing the Arduino libraries.")
-
-    find_file(ARDUINO_BOARDS_PATH
-              NAMES boards.txt
-              PATHS ${ARDUINO_SDK_PATH}
-              PATH_SUFFIXES hardware/arduino
-              DOC "Path to Arduino boards definition file.")
-
-    find_file(ARDUINO_PROGRAMMERS_PATH
-        NAMES programmers.txt
+        NAMES libraries
         PATHS ${ARDUINO_SDK_PATH}
-        PATH_SUFFIXES hardware/arduino
-        DOC "Path to Arduino programmers definition file.")
+        DOC "Path to directory containing the Arduino libraries.")

     find_file(ARDUINO_VERSION_PATH
         NAMES lib/version.txt
@@ -1800,7 +1841,8 @@
     set(ARDUINO_DEFAULT_PROGRAMMER CACHE STRING "Default Arduino Programmer ID when not specified.")

     # Ensure that all required paths are found
-    required_variables(VARS
+    required_variables(VARS
+        PLATFORMS
         ARDUINO_CORES_PATH
         ARDUINO_BOOTLOADERS_PATH
         ARDUINO_LIBRARIES_PATH
@@ -1827,9 +1869,6 @@

     setup_arduino_size_script(ARDUINO_SIZE_SCRIPT)
     set(ARDUINO_SIZE_SCRIPT ${ARDUINO_SIZE_SCRIPT} CACHE INTERNAL "Arduino Size Script")
-
-    load_board_settings()
-    load_programmers_settings()

     #print_board_list()
     #print_programmer_list()


OpenSSL depends on Threads

OpenSSL depends on Threads

--- cmake/find/FindOpenSSL.cmake
+++ cmake/find/FindOpenSSL.cmake
@@ -362,8 +362,9 @@
     add_library(OpenSSL::Crypto UNKNOWN IMPORTED)
     set_target_properties(OpenSSL::Crypto PROPERTIES
       INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
+    find_package(Threads REQUIRED)
     set_target_properties(OpenSSL::Crypto PROPERTIES
-        INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}")
+        INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS};Threads::Threads")
     if(EXISTS "${OPENSSL_CRYPTO_LIBRARY}")
       set_target_properties(OpenSSL::Crypto PROPERTIES
         IMPORTED_LINK_INTERFACE_LANGUAGES "C"


cmake/modules/FindNOSE.cmake: Remove search for `nose`.

--- cmake/modules/FindNOSE.cmake
+++ cmake/modules/FindNOSE.cmake
@@ -1,37 +0,0 @@
-#adapted from vigra source code
-
-
-IF(PYTHONINTERP_FOUND)
-    IF(NOT PYTHON_NOSE_CORE)
-        execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c
-                            "import nose.core; print(nose.core.__file__)"
-                            RESULT_VARIABLE PYTHON_NOSE_NOT_FOUND
-                            OUTPUT_VARIABLE PYTHON_NOSE_CORE
-                            OUTPUT_STRIP_TRAILING_WHITESPACE)
-        IF(NOT PYTHON_NOSE_NOT_FOUND)
-            FILE(TO_CMAKE_PATH ${PYTHON_NOSE_CORE} PYTHON_NOSE_CORE)
-        ELSE()
-            SET(PYTHON_NOSE_CORE "PYTHON_NOSE_CORE-NOTFOUND")
-        ENDIF()
-    ENDIF()
-ELSE()
-    SET(PYTHON_NOSE_CORE "PYTHON_NOSE_CORE-NOTFOUND")
-ENDIF()
-
-SET(PYTHON_NOSE_CORE ${PYTHON_NOSE_CORE}
-    CACHE PATH "Path to nose.core" FORCE)
-
-IF(PYTHON_NOSE_CORE)
-    SET(NOSE_FOUND TRUE)
-
-    IF (NOT NOSE_FIND_QUIETLY)
-        MESSAGE(STATUS "Found Nose")
-        MESSAGE(STATUS "  > nose.core:      ${PYTHON_NOSE_CORE}")
-    ENDIF()
-ELSE()
-    IF(NOSE_FIND_REQUIRED)
-        MESSAGE(FATAL_ERROR "Could not find Nose")
-    ELSEIF(NOT NOSE_FIND_QUIETLY)
-        MESSAGE(STATUS "Unable to fine Nose")
-    ENDIF()
-ENDIF()


Remove CMake-Xcode hack that symlinked llvm-config into a common place.

When building Clang separately from LLVM with CMake, one should set
the path of llvm-config via the cache variable LLVM_CONFIG.

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

--- cmake/modules/TableGen.cmake
+++ cmake/modules/TableGen.cmake
@@ -84,16 +84,6 @@
   add_llvm_utility(${target} ${ARGN})
   set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS})

-  # For Xcode builds, symlink bin/<target> to bin/<Config>/<target> so that
-  # a separately-configured Clang project can still find llvm-tblgen.
-  if (XCODE)
-    add_custom_target(${target}-top ALL
-      ${CMAKE_COMMAND} -E create_symlink
-        ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}
-        ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}${CMAKE_EXECUTABLE_SUFFIX}
-      DEPENDS ${target})
-  endif ()
-
   set(${project}_TABLEGEN "${target}" CACHE
       STRING "Native TableGen executable. Saves building one when cross-compiling.")


Only do try_compile concerning HAVE_SAHOOKS if the information is not
cached already.

This is supposed to happen in any case according to CMake
documentation, but does not.  So for the --debug-trycompile case
(which explicitly does not clean up CMakeFiles/CMakeTmp after each
try_compile) cannot follow documentation suggestion to simply remove
from the cache the try_compile result you want to debug.  Therefore,
have to put in an explicit if statement checking the existence of the
cache value for all try_compiles to make that suggestion work.

--- cmake/modules/shapelib.cmake
+++ cmake/modules/shapelib.cmake
@@ -43,7 +43,7 @@
   endif(SHAPELIB_FOUND)
 endif(HAVE_SHAPELIB)

-if(HAVE_SHAPELIB)
+if(HAVE_SHAPELIB AND NOT DEFINED HAVE_SAHOOKS)
   # See if shapelib is a modern version with access to SAHooks type.
   file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_SAHooks.c
     "#include <shapefil.h>
@@ -61,4 +61,4 @@
    for specified shapefiles will not be quieted."
       )
   endif(NOT HAVE_SAHOOKS)
-endif(HAVE_SHAPELIB)
+endif(HAVE_SHAPELIB AND NOT DEFINED HAVE_SAHOOKS)


Update src-dependencies.cmake

Update src-dependencies.cmake

fixes OSX Build error #226

--- cmake/src-dependencies.cmake
+++ cmake/src-dependencies.cmake
@@ -67,7 +67,8 @@

   if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
       CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) OR
-     (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
+     (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND
+      CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0.3
       # XCode 10 is broken. Maybe XCode 11 will be ok?
      ))
     # See https://bugs.llvm.org/show_bug.cgi?id=35873


Begin removing barriers to compiling Stout tests on Windows.

Currently the CMake files are designed primarily to build CMake on
various flavors of non-Windows OSs.

This commit will introduce a variety of small fixes to the CMake Stout
test configuration logic to help pave the way towards CMake-based
build system that builds on Windows two. This includes things like
adding the correct dependency targets to the stout build targets, as
well as disabling package finding logic that only works on *nix
flavors.

Review: https://reviews.apache.org/r/36967

--- 3rdparty/libprocess/3rdparty/stout/cmake/StoutTestsConfigure.cmake
+++ 3rdparty/libprocess/3rdparty/stout/cmake/StoutTestsConfigure.cmake
@@ -14,22 +14,42 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.

-find_package(Apr REQUIRED)
-find_package(Svn REQUIRED)
+if (NOT WIN32)
+  # TODO(hausdorff): (cf. MESOS-3181) Add support for attempting to find these
+  # packages on Windows, and then if that fails, use CMake macros/functions to
+  # download, configure, and build them.
+  #
+  # WHY: Windows does not have a good package manager, so getting some of our
+  # dependencies can be really annoying in some circumstances. For this reason,
+  # we should support a CMake-based "distribution channel", even though this
+  # way is sure to be more hackish.
+  find_package(Apr REQUIRED)
+  find_package(Svn REQUIRED)
+endif (NOT WIN32)

 # COMPILER CONFIGURATION.
 #########################
-if (APPLE)
+if (WIN32)
+  # Used to #ifdef out (e.g.) some platform-specific parts of Stout. We choose
+  # to define a new flag rather than using an existing flag (e.g., `_WIN32`)
+  # because we want to give the build system fine-grained control over how what
+  # code is #ifdef'd out in the future, and using only flags defined by our
+  # build system to control this logic is the clearest and stablest way of
+  # doing this.
+  add_definitions(-D__WINDOWS__)
+elseif (APPLE)
   # GTEST on OSX needs its own tr1 tuple.
   # TODO(dhamon): Update to gmock 1.7 and pass GTEST_LANG_CXX11 when
   # in C++11 mode.
   add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1)
-endif (APPLE)
+endif (WIN32)

 # DEFINE PROCESS LIBRARY DEPENDENCIES. Tells the process library build targets
 # download/configure/build all third-party libraries before attempting to build.
 ################################################################################
 set(STOUT_TEST_DEPENDENCIES
+  ${BOOST_TARGET}
+  ${GLOG_TARGET}
   ${GMOCK_TARGET}
   ${GTEST_TARGET}
   ${PROTOBUF_TARGET}
@@ -69,13 +89,31 @@
 ########################################################################
 set(STOUT_TEST_LIB_DIRS
   ${STOUT_TEST_LIB_DIRS}
-  ${GLOG_LIB}/lib
   ${APR_LIBS}
   ${SVN_LIBS}
   ${GMOCK_ROOT}-build/lib/.libs
   ${GMOCK_ROOT}-build/gtest/lib/.libs
-  ${PROTOBUF_LIB}/lib
   )
+
+if (WIN32)
+  # TODO(hausdorff): currently these dependencies have to be built out-of-band
+  # by opening Visual Studio, building the project, and then building Mesos. We
+  # should write batch scripts that will build these dependencies from the
+  # command line. (This is one reason why we're linking to the Debug/ folders,
+  # which is not a good idea for release builds anyway.)
+  set(STOUT_TEST_LIB_DIRS
+    ${STOUT_TEST_LIB_DIRS}
+    ${GLOG_ROOT}/Debug
+    ${GMOCK_ROOT}/msvc/2010/Debug
+    ${PROTOBUF_ROOT}/vsprojects/Debug
+    )
+else (WIN32)
+  set(STOUT_TEST_LIB_DIRS
+    ${STOUT_TEST_LIB_DIRS}
+    ${GLOG_LIB}/lib
+    ${PROTOBUF_LIB}/lib
+    )
+endif (WIN32)

 # DEFINE THIRD-PARTY LIBS. Used to generate flags that the linker uses to
 # include our third-party libs (e.g., -lglog on Linux).
@@ -83,14 +121,31 @@
 set(STOUT_TEST_LIBS
   ${STOUT_TEST_LIBS}
   ${CMAKE_THREAD_LIBS_INIT}
-  glog
-  dl
-  apr-1
-  protobuf
-  gtest
   gmock
   ${SVN_LIBS}
   )
+
+if (WIN32)
+  # Necessary because the lib names for glog and protobuf are generated
+  # incorrectly on Windows. That is, on *nix, the glog binary should be (e.g.)
+  # libglog.so, and on Windows it should be glog.lib. But on Windows, it's
+  # actually libglog.lib. Hence, we have to special case it here because CMake
+  # assumes the library names are generated correctly.
+  set(STOUT_TEST_LIBS
+    ${STOUT_TEST_LIBS}
+    libglog
+    libprotobuf
+    )
+else (WIN32)
+  set(STOUT_TEST_LIBS
+    ${STOUT_TEST_LIBS}
+    glog
+    gtest
+    protobuf
+    dl
+    apr-1
+    )
+endif (WIN32)

 # TODO(hausdorff): The `LINUX` flag comes from MesosConfigure; when we
 # port the bootstrap script to CMake, we should also copy this logic


fix wrong conditon in deps/luajit.cmake

fix wrong conditon in deps/luajit.cmake

bug report in https://github.com/luvit/luvi/issues/264

--- deps/luajit.cmake
+++ deps/luajit.cmake
@@ -226,11 +226,11 @@
     # code can't use it (at least without modifying the test code)
     execute_process(COMMAND "${CMAKE_C_COMPILER}" -c -x c "${TMPUNWIND_DIR}/tmpunwind.c" -o "${TMPUNWIND_DIR}/tmpunwind.o"
       RESULT_VARIABLE UNWIND_TEST_ERRORED)
-    IF(NOT UNWIND_TEST_ERRORED)
+    IF(UNWIND_TEST_ERRORED EQUAL 0)
       file(READ "${TMPUNWIND_DIR}/tmpunwind.o" TMPUNWIND_O)
       string(FIND "${TMPUNWIND_O}" "eh_frame" EH_FRAME_FOUND)
       string(FIND "${TMPUNWIND_O}" "__unwind_info" UNWIND_INFO_FOUND)
-      IF(EH_FRAME_FOUND OR UNWIND_INFO_FOUND)
+      IF(EH_FRAME_FOUND GREATER -1 OR UNWIND_INFO_FOUND GREATER -1)
         SET(TOOLCHAIN_GENERATES_UNWIND_TABLES 1)
       ENDIF()
     ENDIF()


support build dirs for devs in glow-config

--- glow-config.cmake
+++ glow-config.cmake
@@ -12,11 +12,14 @@
 # GLOW_WINDOW_LIBRARY_DEBUG
 # GLOW_WINDOW_LIBRARIES

+if(CMAKE_CURRENT_LIST_FILE)
+	get_filename_component(GLOW_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+endif()
+
 find_path(GLOW_INCLUDE_DIR glow/glow.h
 	$ENV{GLOW_DIR}/include
 	${GLOW_DIR}/include
 	$ENV{PROGRAMFILES}/GLOW/include
-	/include
 	/usr/include
 	/usr/local/include
 	/sw/include
@@ -24,9 +27,13 @@
 	DOC "The directory where glow/glow.h resides")

 set(LIB_PATHS
+	${GLOW_DIR}/build
+	${GLOW_DIR}/build/Release
+	${GLOW_DIR}/build/Debug
+	${GLOW_DIR}/build-release
+	${GLOW_DIR}/build-debug
 	$ENV{GLOW_DIR}/lib
 	${GLOW_DIR}/lib
-	/lib
 	/usr/lib
 	/usr/local/lib
 	/sw/lib
@@ -37,7 +44,8 @@
 	/opt/local/lib64
 )

-macro (find LIB_NAME HINT_PATHS)
+macro (find LIB_NAME)
+	set(HINT_PATHS ${ARGN})

 	if (${LIB_NAME} STREQUAL "glow")
 		set(LIB_NAME_UPPER GLOW)
@@ -69,11 +77,5 @@
 find(utils ${LIB_PATHS})
 #find(window ${LIB_PATHS})

-if(GLOW_INCLUDE_DIR AND (GLOW_LIBRARY OR GLOW_LIBRARY_DEBUG))
-    set(GLOW_FOUND 1 CACHE STRING "Set to 1 if glow is found, 0 otherwise")
-else()
-    set(GLOW_FOUND 0 CACHE STRING "Set to 1 if glow is found, 0 otherwise")
-    message(WARNING "Note: an envvar like GLOW_DIR assists this script to locate glow.")
-endif()
-
+find_package_handle_standard_args(GLOW DEFAULT_MSG GLOW_LIBRARIES GLOW_INCLUDE_DIR)
 mark_as_advanced(GLOW_FOUND)


Syntax fix

Syntax fix

--- android-ndk-r10e-api-16-armeabi-v7a-neon-clang-35-hid-sections.cmake
+++ android-ndk-r10e-api-16-armeabi-v7a-neon-clang-35-hid-sections.cmake
@@ -22,7 +22,7 @@
 polly_init(
     "Android NDK ${ANDROID_NDK_VERSION} / \
 API ${CMAKE_SYSTEM_VERSION} / ${CMAKE_ANDROID_ARCH_ABI} / \
-NEON / 32-bit ARM / Clang 3.5 / c++11 support / data-sections / function-sections \
+NEON / 32-bit ARM / Clang 3.5 / c++11 support / data-sections / function-sections"
     "Unix Makefiles"
 )


- новые пути для плагинов

 - новые пути для плагинов

git-svn-id: 41bd7e47c31e4d43f97241d7529f6785d233c6d8@12578 23f926e6-80f1-49ca-85a0-60d4a27bb3ac

--- rdo/packages/cmake/trunk/win32.install.iss.cmake
+++ rdo/packages/cmake/trunk/win32.install.iss.cmake
@@ -41,8 +41,8 @@
 Source: "Qt5Gui.dll";     DestDir: "{app}"
 Source: "Qt5Widgets.dll"; DestDir: "{app}"

-Source: "qminimal.dll"; DestDir: "{app}/platforms"
-Source: "qwindows.dll"; DestDir: "{app}/platforms"
+Source: "plugins/platforms/qminimal.dll"; DestDir: "{app}/plugins/platforms"
+Source: "plugins/platforms/qwindows.dll"; DestDir: "{app}/plugins/platforms"

 Source: "libGLESv2.dll";      DestDir: "{app}"
 Source: "libEGL.dll";         DestDir: "{app}"


From Hady Zalek: fix dictionary dependencies (which were piling up for each directory)

git-svn-id: ecbadac9c76e8cf640a0bca86f6bd796c98521e3@33029 27541ba8-7e3a-0410-8455-c3a389f83636

--- cint/reflex/cmake/modules/ReflexMacros.cmake
+++ cint/reflex/cmake/modules/ReflexMacros.cmake
@@ -115,6 +115,8 @@

 MACRO (REFLEX_GENERATE_DICTIONARIES outfiles)

+   SET(${outfiles} "")
+
    # extract the includes and defintions for reuse by genreflex
    _REFLEX_GET_GENREFLEX_INCLUDES(genreflex_includes)
    _REFLEX_GET_GENREFLEX_DEFINITIONS(genreflex_definitions)


- Add environment fetch for ANDROID_CPP_FEATURES

--- cmake/Toolchains/all-android.toolchain.cmake
+++ cmake/Toolchains/all-android.toolchain.cmake
@@ -55,6 +55,7 @@
 retrieve_env(ANDROID_STL)
 retrieve_env(ANDROID_ARM_NEON)
 retrieve_env(ANDROID_DISABLE_FORMAT_STRING_CHECKS)
+retrieve_env(ANDROID_CPP_FEATURES)

 message("PROPS: ${ANDROID_NDK} ${ANDROID_STL} ${ANDROID_TOOLCHAIN} ${ANDROID_ABI} ${ANDROID_PLATFORM}")


[numerics] fix PATH stuff

[numerics] fix PATH stuff

--- numerics/numerics_tests.cmake
+++ numerics/numerics_tests.cmake
@@ -56,7 +56,7 @@
   # PSOR is not working :(
   SET(SICONOS_LCP_SOLVERS
    "ENUM;LEMKE;CPG;PGS;RPGS;LATIN;LATIN_W;QP;NSQP;AVI_CAOFERRIS;NEWTONMIN;NEWTON_FBLSA;NEWTON_MINFBLSA;BARD;MURTY;PIVOT;PIVOT_LUMOD;PATHSEARCH")
-  IF(PATHFERRIS_FOUND)
+  IF(HAVE_PATHFERRIS)
    LIST(APPEND SICONOS_LCP_SOLVERS "PATH")
   ENDIF()
   IF(HAVE_GAMS_C_API)
@@ -132,9 +132,9 @@
    #   SET(test-LCP_PIVOT_LUMOD-lcp_tobenna_PROPERTIES WILL_FAIL FALSE)
   ENDIF(DEV_MODE)

-  IF(PATHFERRIS_FOUND)
+  IF(HAVE_PATHFERRIS)
    NEW_LCP_TEST(SICONOS_LCP_PATH lcp_tobenna.dat)
-  ENDIF(PATHFERRIS_FOUND)
+  ENDIF(HAVE_PATHFERRIS)
   IF(HAVE_GAMS_C_API)
    NEW_LCP_TEST(SICONOS_LCP_GAMS lcp_tobenna.dat)
   ENDIF(HAVE_GAMS_C_API)
@@ -158,7 +158,7 @@
    LIST(APPEND SICONOS_RELAY_SOLVERS "AVI_CAOFERRIS_TEST")
   ENDIF()

-  IF(PATHFERRIS_FOUND)
+  IF(HAVE_PATHFERRIS)
    LIST(APPEND SICONOS_RELAY_SOLVERS "PATH")
   ENDIF()
   FOREACH(_DS ${DATA_SET})
@@ -173,9 +173,9 @@
   NEW_TEST(Relaytest1 relay_test1.c)
   NEW_TEST(Relaytest2 relay_test2.c)

-  IF(PATHFERRIS_FOUND)
+  IF(HAVE_PATHFERRIS)
     NEW_TEST(Relaytest3 relay_test3.c)
-  ENDIF(PATHFERRIS_FOUND)
+  ENDIF(HAVE_PATHFERRIS)

   NEW_TEST(Relaytest10 relay_test10.c)
   NEW_TEST(Relaytest11 relay_test11.c)
@@ -206,9 +206,9 @@

   BEGIN_TEST(src/NCP/test)
   SET(SICONOS_NCP_SOLVERS "NEWTON_FBLSA;NEWTON_MINFBLSA;PATHSEARCH")
-  IF(PATHFERRIS_FOUND)
+  IF(HAVE_PATHFERRIS)
     LIST(APPEND SICONOS_NCP_SOLVERS "PATH")
-  ENDIF(PATHFERRIS_FOUND)
+  ENDIF(HAVE_PATHFERRIS)

   SET(SICONOS_NCP_TEST_PROBLEMS "NCP_ZI1")
   IF(DEV_MODE)
@@ -241,10 +241,10 @@
   SET(FC3Dtest5_PROPERTIES WILL_FAIL TRUE)
   NEW_TEST(FC3Dtest5 fc3d_test5.c)

-  IF(PATHFERRIS_FOUND)
+  IF(HAVE_PATHFERRIS)
     NEW_TEST(FC3Dtest6 fc3d_test6.c)
     SET(FC3Dtest6_PROPERTIES WILL_FAIL TRUE)
-  ENDIF(PATHFERRIS_FOUND)
+  ENDIF(HAVE_PATHFERRIS)

   SET(FC3Dtest7_PROPERTIES WILL_FAIL TRUE)
   NEW_TEST(FC3Dtest7 fc3d_test7.c)
@@ -648,9 +648,9 @@

   SET(SICONOS_VI_SOLVERS "BOX_QI;BOX_AVI_LSA")
-  IF(PATHFERRIS_FOUND)
+  IF(HAVE_PATHFERRIS)
    LIST(APPEND SICONOS_VI_SOLVERS "BOX_PATH")
-  ENDIF(PATHFERRIS_FOUND)
+  ENDIF(HAVE_PATHFERRIS)

   IF(DEV_MODE)
    SET(SICONOS_VI_TEST_PROBLEMS "VI_ZI1;VI_ZIT1")


Restrict find_program llvm to given path

LLVM can be installed on a system without clang.
So if LLVM_DIRECTORY pointed to a locally installed llvm/clang version
but the system had llvm without clang installed, until now the script would
find the system LLVM without clang and the build would fail.
And since LLVM is globally searched for if the hinted version failed,
it should not hurt to only search in the hinted paths.

--- src/cmake/externalpackages.cmake
+++ src/cmake/externalpackages.cmake
@@ -180,9 +180,9 @@

 # try to find llvm-config, with a specific version if specified
 if(LLVM_DIRECTORY)
-  FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS "${LLVM_DIRECTORY}/bin" NO_CMAKE_PATH)
+  FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS "${LLVM_DIRECTORY}/bin" NO_DEFAULT_PATH)
   if(NOT LLVM_CONFIG)
-    FIND_PROGRAM(LLVM_CONFIG llvm-config HINTS "${LLVM_DIRECTORY}/bin" NO_CMAKE_PATH)
+    FIND_PROGRAM(LLVM_CONFIG llvm-config HINTS "${LLVM_DIRECTORY}/bin" NO_DEFAULT_PATH)
   endif()
 else()
   FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION})


add definition APR_DECLARE_STATIC to apr use script

--- projects/use/usexp-apr-config.cmake
+++ projects/use/usexp-apr-config.cmake
@@ -11,6 +11,9 @@
 unset(${PRJ}_INCLUDE_DIR CACHE)
 find_path(${PRJ}_INCLUDE_DIR apr.h PATHS ${XP_ROOTDIR}/include/apr NO_DEFAULT_PATH)
 set(${PRJ}_LIBRARIES apr-1)
+if(WIN32)
+  add_definitions(-DAPR_DECLARE_STATIC)
+endif()
 set(reqVars ${PRJ}_INCLUDE_DIR ${PRJ}_LIBRARIES)
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(${prj} REQUIRED_VARS ${reqVars})


Revert "Set -Wno-newline-eof globally for gcc and clang"

This was a mistake

This reverts commit 04c37f688a401740aceb4d9515b257d2fc3ee535.

git-svn-id: fbbf69ba8011aca0e74e1c67904b11cccbdbe66b@27563 0785d39b-7218-0410-832d-ea1e28bc413d

--- deal.II/cmake/setup_compiler_flags_gnu.cmake
+++ deal.II/cmake/setup_compiler_flags_gnu.cmake
@@ -71,12 +71,6 @@
 #
 ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused-local-typedefs")

-#
-# Silence the -Wnewline-eof warning. We trigger this in various 3rd party
-# headers...
-#
-ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-newline-eof")
-

 IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
   #
@@ -87,6 +81,7 @@
   #
   ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-delete-non-virtual-dtor") # not harmless but needed for boost <1.50.0
   ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-long-long")
+  ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-newline-eof")
   ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused-function")
   ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused-variable")
 ENDIF()


update flatbuffer to 1.6.0

update flatbuffer to 1.6.0

--- 3rd_party/flatbuffers/flatbuffers.cmake
+++ 3rd_party/flatbuffers/flatbuffers.cmake
@@ -5,7 +5,7 @@
 endif()

 set (3RD_PARTY_FLATBUFFER_REPO_DIR "${3RD_PARTY_FLATBUFFER_BASE_DIR}/repo")
-set (3RD_PARTY_FLATBUFFER_VERSION v1.5.0)
+set (3RD_PARTY_FLATBUFFER_VERSION v1.6.0)
 set (3RD_PARTY_FLATBUFFER_HEADER "${3RD_PARTY_FLATBUFFER_REPO_DIR}/include/flatbuffers/flatbuffers.h")

 if(NOT EXISTS ${3RD_PARTY_FLATBUFFER_REPO_DIR} OR NOT EXISTS ${3RD_PARTY_FLATBUFFER_HEADER})


COMP: ctkMacroCompilePythonScript - Remove extra target  - Added COMMENT argument to CUSTOM_COMMAND

Having this extra target was causing problem in parallel build.

Here is the explanation of Brad king:

"The copy rules end up in Copy${kit_name}PythonFiles as dependencies
of the byte compiling custom command.
Since the two targets do not depend on one another they
can build in parallel and try to copy the same file at the same time.
Removing the unnecessary target should solve the problem."

--- CMake/ctkMacroCompilePythonScript.cmake
+++ CMake/ctkMacroCompilePythonScript.cmake
@@ -19,12 +19,8 @@
     ADD_CUSTOM_COMMAND(DEPENDS ${src}
                         COMMAND ${CMAKE_COMMAND} -E copy ${src} ${tgt}
                         OUTPUT ${tgt}
-                        COMMENT "source copy")
+                        COMMENT "Copying ${file_we}")
   ENDFOREACH()
-
-  ADD_CUSTOM_TARGET(Copy${kit_name}PythonFiles
-                  ALL
-                  DEPENDS ${copied_python_files})

   # Byte compile the Python files.
   SET(compile_all_script "${CMAKE_CURRENT_BINARY_DIR}/compile_all_${kit_name}.py")
@@ -39,10 +35,10 @@
 ")

   ADD_CUSTOM_COMMAND(
-    COMMAND ${PYTHON_EXECUTABLE}
-    ARGS  "${compile_all_script}"
+    COMMAND ${PYTHON_EXECUTABLE} ${compile_all_script}
     DEPENDS ${copied_python_files}  ${compile_all_script}
     OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${kit_name}_python_compile_complete"
+    COMMENT "Compiling ${kit_name} python files"
     )

   ADD_CUSTOM_TARGET(${kit_name}_pyc ALL


Update FindLHAPDF.cmake

Update FindLHAPDF.cmake

--- ndsim/build/FindLHAPDF.cmake
+++ ndsim/build/FindLHAPDF.cmake
@@ -15,7 +15,7 @@
                                                              $ENV{LHAPDF_INSTALL_DIR}/include/
                                                              NO_DEFAULT_PATH)

-FIND_PATH(LHAPDF_LIBRARY_DIR NAMES   libLHAPDF.so            PATHS
+FIND_PATH(LHAPDF_LIBRARY_DIR NAMES   libLHAPDF.so libLHAPDF.dylib           PATHS
                                                              $ENV{LHAPDF_INSTALL_DIR}/lib/
                                                              NO_DEFAULT_PATH)


transitively carry thrift dependencies forward

Summary: eden.thrift includes fb303_core.thrift, so any cmake target that depends on eden.thrift should pull in fb303_core.thrift's include directories and libraries. Implement that machinery in CppThriftLibrary.cmake.

Reviewed By: wez

Differential Revision: D16062657

fbshipit-source-id: d5d962960e767a138a9b634a12aebccf72d6ef43

--- build/fbcode_builder/CMake/ThriftCppLibrary.cmake
+++ build/fbcode_builder/CMake/ThriftCppLibrary.cmake
@@ -37,7 +37,13 @@
     DIRECTORY
   )

-  list(APPEND GEN_ARGS "include_prefix=${output_dir}")
+  # Generate relative paths in #includes
+  file(RELATIVE_PATH include_prefix ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${THRIFT_FILE})
+  get_filename_component(include_prefix ${include_prefix} DIRECTORY)
+
+  if (NOT "${include_prefix}" STREQUAL "")
+    list(APPEND GEN_ARGS "include_prefix=${include_prefix}")
+  endif()
   # CMake 3.12 is finally getting a list(JOIN) function, but until then
   # treating the list as a string and replacing the semicolons is good enough.
   string(REPLACE ";" "," GEN_ARG_STR "${GEN_ARGS}")
@@ -70,6 +76,24 @@
     )
   endforeach()

+  list(APPEND thrift_include_options -I ${CMAKE_SOURCE_DIR})
+  foreach(depends IN LISTS DEPENDS)
+    get_property(thrift_include_directory
+      TARGET ${depends}
+      PROPERTY THRIFT_INCLUDE_DIRECTORY)
+
+    if (thrift_include_directory STREQUAL "")
+      message(STATUS "No thrift dependency found for ${depends}")
+    else()
+      list(APPEND thrift_include_options -I
+        ${thrift_include_directory})
+    endif()
+  endforeach()
+
+  file(
+    GLOB_RECURSE THRIFT_TEMPLATE_FILES
+    FOLLOW_SYMLINKS ${FBTHRIFT_TEMPLATES_DIR}/*.mustache)
+
   # Emit the rule to run the thrift compiler
   add_custom_command(
     OUTPUT
@@ -82,7 +106,7 @@
       --strict
       --templates ${FBTHRIFT_TEMPLATES_DIR}
       --gen "mstch_cpp2:${GEN_ARG_STR}"
-      -I ${CMAKE_SOURCE_DIR}
+      ${thrift_include_options}
       -o ${output_dir}
       ${CMAKE_CURRENT_SOURCE_DIR}/${THRIFT_FILE}
     WORKING_DIRECTORY
@@ -97,16 +121,18 @@
   add_library(${LIB_NAME} STATIC
     ${generated_sources}
   )
-  set_property(
-    TARGET ${LIB_NAME}
-    PROPERTY PUBLIC_HEADER
-      ${generated_headers}
+
+  install(
+    FILES ${generated_headers}
+    DESTINATION $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/gen-cpp2
   )
+
   target_include_directories(
     ${LIB_NAME}
+    PRIVATE
+      ${CMAKE_SOURCE_DIR}
+      ${CMAKE_BINARY_DIR}
     PUBLIC
-      $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
-      $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
       ${FOLLY_INCLUDE_DIR}
       ${FBTHRIFT_INCLUDE_DIR}
   )
@@ -117,4 +143,15 @@
       FBThrift::thriftcpp2
       Folly::folly
   )
+
+  set_target_properties(
+    ${LIB_NAME}
+    PROPERTIES
+      EXPORT_PROPERTIES "THRIFT_INCLUDE_DIRECTORY"
+      THRIFT_INCLUDE_DIRECTORY ${CMAKE_SOURCE_DIR}
+  )
+
+  get_property(thrift_include_directory
+    TARGET ${LIB_NAME}
+    PROPERTY THRIFT_INCLUDE_DIRECTORY)
 endfunction()


Remove install prefix for portable installs

--- packages/pack-template.cmake
+++ packages/pack-template.cmake
@@ -152,7 +152,7 @@
     set(CPACK_INSTALL_CMAKE_PROJECTS        "${CMAKE_BINARY_DIR};${project_root};ALL;/")
     set(CPACK_PACKAGE_INSTALL_DIRECTORY     "${package_name}")
     set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY  "${package_name}")
-    if(NOT WIN32)
+    if(NOT WIN32 AND NOT OPTION_PORTABLE_INSTALL)
         set(CPACK_INSTALL_PREFIX            "/usr/")
     endif()


Emscripten: call llvm-ar directly.

Emscripten: call llvm-ar directly.

This calls the llvm-ar of emscripten's fastcomp directly without
going through the emar wrapper. See if this changes anything
under windows (missing path separators on Windows)

--- cmake-toolchains/emscripten.toolchain.cmake
+++ cmake-toolchains/emscripten.toolchain.cmake
@@ -35,9 +35,11 @@

 # find the emscripten SDK
 find_emscripten_sdk()
+set(EMSCRIPTEN_LLVM_ROOT "${EMSCRIPTEN_ROOT_PATH}/../../clang/fastcomp/build_${FIPS_EMSCRIPTEN_SDK_VERSION}_64/bin")

 # Normalize, convert Windows backslashes to forward slashes or CMake will crash.
 get_filename_component(EMSCRIPTEN_ROOT_PATH "${EMSCRIPTEN_ROOT_PATH}" ABSOLUTE)
+get_filename_component(EMSCRIPTEN_LLVM_ROOT "${EMSCRIPTEN_LLVM_ROOT}" ABSOLUTE)

 set(FIPS_PLATFORM EMSCRIPTEN)
 set(FIPS_PLATFORM_NAME "emsc")
@@ -145,7 +147,8 @@
 endif()
 if (EXISTS "${EMSCRIPTEN_DOT_FILE}")
     set(EMSC_COMMON_FLAGS "${EMSC_COMMON_FLAGS} --em-config ${EMSCRIPTEN_DOT_FILE} --cache ${EMSCRIPTEN_CACHE}")
-    set(EMSC_AR_FLAGS "${EMSC_AR_FLAGS} --em-config ${EMSCRIPTEN_DOT_FILE}")
+    # FIXME: if calling llvm-ar directory works everywhere, the following line can be removed
+    #    set(EMSC_AR_FLAGS "${EMSC_AR_FLAGS} --em-config ${EMSCRIPTEN_DOT_FILE}")
 else()
     # no sdk-embedded config found, use the default (~/.emscripten and ~/.emscripten_cache)
     message(WARNING "Using global emscripten config and cache in '~'!")
@@ -164,9 +167,9 @@
 # specify cross-compilers
 set(CMAKE_C_COMPILER "${EMSCRIPTEN_ROOT_PATH}/emcc${EMCC_SUFFIX}" CACHE PATH "gcc" FORCE)
 set(CMAKE_CXX_COMPILER "${EMSCRIPTEN_ROOT_PATH}/em++${EMCC_SUFFIX}" CACHE PATH "g++" FORCE)
-set(CMAKE_AR "${EMSCRIPTEN_ROOT_PATH}/emar${EMCC_SUFFIX}" CACHE PATH "archive" FORCE)
+set(CMAKE_AR "${EMSCRIPTEN_LLVM_ROOT}/llvm-ar" CACHE PATH "archive" FORCE)
 set(CMAKE_LINKER "${EMSCRIPTEN_ROOT_PATH}/emcc${EMCC_SUFFIX}" CACHE PATH "linker" FORCE)
-set(CMAKE_RANLIB "${EMSCRIPTEN_ROOT_PATH}/emranlib${EMCC_SUFFIX}" CACHE PATH "ranlib" FORCE)
+set(CMAKE_RANLIB "${EMSCRIPTEN_LLVM_ROOT}/llvm-ranlib" CACHE PATH "ranlib" FORCE)

 # only search for libraries and includes in the toolchain
 set(CMAKE_FIND_ROOT_PATH ${EMSCRIPTEN_ROOT_PATH})


Cleaned up command line options in emscripten toolchain file

--- cmake-toolchains/emscripten.toolchain.cmake
+++ cmake-toolchains/emscripten.toolchain.cmake
@@ -62,97 +62,70 @@
 set(FIPS_EMSCRIPTEN_MEM_INIT_METHOD 1 CACHE STRING "emscripten: how to represent initial memory content (0..2)")
 set(FIPS_EMSCRIPTEN_EXPORTED_FUNCTIONS "['_main','_enter_fullscreen','_enter_soft_fullscreen']" CACHE STRING "emscripten: exported C function names")
 set(FIPS_EMSCRIPTEN_SHELL_HTML "${EMSCRIPTEN_ROOT_PATH}/src/shell_minimal.html" CACHE STRING "emscripten: path to shell html file")
-
-# memory-init-method also needs the --memory-init-file option
-if (${FIPS_EMSCRIPTEN_MEM_INIT_METHOD} STREQUAL 1)
-    set(EMSCRIPTEN_MEMORY_INIT_FLAG 1)
-else()
-    set(EMSCRIPTEN_MEMORY_INIT_FLAG 0)
-endif()
+set(EMSCRIPTEN_TOTAL_MEMORY_WORKER 16777216)
+
+set(EMSC_COMMON_FLAGS)
+set(EMSC_CXX_FLAGS)
+set(EMSC_LINKER_FLAGS)
+set(EMSC_LINKER_FLAGS_RELEASE)
+set(EMSC_EXE_LINKER_FLAGS)
+set(EMSC_AR_FLAGS)
+
+set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} --memory-init-file ${FIPS_EMSCRIPTEN_MEM_INIT_METHOD}")
+set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s TOTAL_MEMORY=${FIPS_EMSCRIPTEN_TOTAL_MEMORY}")
+set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=1")
+set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s EXPORTED_FUNCTIONS=\"${FIPS_EMSCRIPTEN_EXPORTED_FUNCTIONS}\"")
+set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s NO_EXIT_RUNTIME=1")

 # enable the emscripten tracer if profiling is enabled
 if (FIPS_PROFILING)
-    set(EMSCRIPTEN_TRACING 1)
-    set(EMSCRIPTEN_TRACING_OPTION "--tracing")
-else()
-    set(EMSCRIPTEN_TRACING 0)
-    set(EMSCRIPTEN_TRACING_OPTION "")
+    set(EMSC_TRACING 1)
+    set(EMSC_COMMON_FLAGS "${EMSC_COMMON_FLAGS} --tracing")
+else()
+    set(EMSC_TRACING 0)
 endif()
 if (FIPS_EMSCRIPTEN_USE_SAFE_HEAP)
-    set(EMSCRIPTEN_SAFE_HEAP 1)
-else()
-    set(EMSCRIPTEN_SAFE_HEAP 0)
-endif()
-
-set(EMSCRIPTEN_TOTAL_MEMORY_WORKER 16777216)
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s SAFE_HEAP=1")
+else()
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s SAFE_HEAP=0")
+endif()
+if (FIPS_EMSCRIPTEN_USE_FS)
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s NO_FILESYSTEM=0")
+else()
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s NO_FILESYSTEM=1")
+endif()
+if (FIPS_EMSCRIPTEN_USE_DFE)
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s ELIMINATE_DUPLICATE_FUNCTIONS=1")
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s ELIMINATE_DUPLICATE_FUNCTIONS_DUMP_EQUIVALENT_FUNCTIONS=1")
+else()
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s ELIMINATE_DUPLICATE_FUNCTIONS=0")
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s ELIMINATE_DUPLICATE_FUNCTIONS_DUMP_EQUIVALENT_FUNCTIONS=0")
+endif()
+if (FIPS_COMPILE_VERBOSE)
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s VERBOSE=1")
+else()
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s VERBOSE=0")
+endif()
 set(EMSCRIPTEN_OPT "-O3")
-if (FIPS_EMSCRIPTEN_USE_FS)
-    set(EMSCRIPTEN_NO_FILESYSTEM 0)
-else()
-    set(EMSCRIPTEN_NO_FILESYSTEM 1)
-endif()
-if (FIPS_EMSCRIPTEN_USE_DFE)
-    set(EMSCRIPTEN_DFE 1)
-    set(EMSCRIPTEN_DFE_DUMP 1)
-else()
-    set(EMSCRIPTEN_DFE 0)
-    set(EMSCRIPTEN_DFE_DUMP 0)
-endif()
-
-# disable closure for now, as long as ANGLE_instanced_array support is not fully supported in emscripten
-set(EMSCRIPTEN_USE_CLOSURE 0)
-set(EMSCRIPTEN_ASSERTIONS 0)
-
-if (FIPS_COMPILE_VERBOSE)
-    set(EMSCRIPTEN_BUILD_VERBOSE 1)
-else()
-    set(EMSCRIPTEN_BUILD_VERBOSE 0)
-endif()
-
-# exceptions on/off?
 if (FIPS_EXCEPTIONS)
-    set(FIPS_EMSC_EXCEPTION_FLAGS "")
-    set(EMSCRIPTEN_DISABLE_EXCEPTION_CATCHING 0)
-else()
-    set(FIPS_EMSC_EXCEPTION_FLAGS "-fno-exceptions")
-    set(EMSCRIPTEN_DISABLE_EXCEPTION_CATCHING 1)
-endif()
-
-# RTTI on/off?
-if (FIPS_RTTI)
-    set(FIPS_EMSC_RTTI_FLAGS "")
-else()
-    set(FIPS_EMSC_RTTI_FLAGS "-fno-rtti")
-endif()
-
-# WebAssembly on/off?
-if (FIPS_EMSCRIPTEN_USE_WASM)
-    set(EMSCRIPTEN_WASM_FLAGS "-s BINARYEN=1 -s 'BINARYEN_METHOD=\"native-wasm\"' -s 'BINARYEN_SCRIPTS=\"spidermonkify.py\"' -s GLOBAL_BASE=1000 -s ALIASING_FUNCTION_POINTERS=0")
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s DISABLE_EXCEPTION_CATCHING=0")
+else()
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s DISABLE_EXCEPTION_CATCHING=1")
+    set(EMSC_CXX_FLAGS "${EMSC_CXX_FLAGS} -fno-exceptions")
+endif()
+if (NOT FIPS_RTTI)
+    set(EMSC_CXX_FLAGS "${EMSC_CXX_FLAGS} -fno-rtti")
+endif()
+set(EMSC_LINKER_FLAGS_RELEASE "${EMSC_LINKER_FLAGS_RELEASE} --llvm-lto ${FIPS_EMSCRIPTEN_LTO_LEVEL}")
+set(EMSC_LINKER_FLAGS_RELEASE "${EMSC_LINKER_FLAGS_RELEASE} -s OUTLINING_LIMIT=${FIPS_EMSCRIPTEN_OUTLINING_LIMIT}")
+set(EMSC_LINKER_FLAGS_RELEASE "${EMSC_LINKER_FLAGS_RELEASE} --closure 0")
+set(EMSC_LINKER_FLAGS_RELEASE "${EMSC_LINKER_FLAGS_RELEASE} -s ASSERTIONS=0")
+if (FIPS_EMSCRIPTEN_USE_WASM)
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s BINARYEN=1 -s 'BINARYEN_METHOD=\"native-wasm\"' -s 'BINARYEN_SCRIPTS=\"spidermonkify.py\"' -s GLOBAL_BASE=1000 -s ALIASING_FUNCTION_POINTERS=0")
 elseif(FIPS_EMSCRIPTEN_USE_WASM_ASMJS)
-    set(EMSCRIPTEN_WASM_FLAGS "-s BINARYEN=1 -s 'BINARYEN_METHOD=\"native-wasm,asmjs\"' -s 'BINARYEN_SCRIPTS=\"spidermonkify.py\"' -s GLOBAL_BASE=1000 -s ALIASING_FUNCTION_POINTERS=0")
-else()
-    set(EMSCRIPTEN_WASM_FLAGS "")
-endif()
-
-# shell.html file
-set(EMSCRIPTEN_SHELL_FLAGS "--shell-file ${FIPS_EMSCRIPTEN_SHELL_HTML}")
-
-# message("FIPS_EMSCRIPTEN_TOTAL_MEMORY: ${FIPS_EMSCRIPTEN_TOTAL_MEMORY}")
-# message("FIPS_EMSCRIPTEN_LTO_LEVEL: ${FIPS_EMSCRIPTEN_LTO_LEVEL}")
-# message("FIPS_EMSCRIPTEN_OUTLINING_LIMIT: ${FIPS_EMSCRIPTEN_OUTLINING_LIMIT}")
-# message("FIPS_EMSCRIPTEN_MEM_INIT_METHOD: ${FIPS_EMSCRIPTEN_MEM_INIT_METHOD}")
-# message("FIPS_EMSCRIPTEN_USE_WASM: ${FIPS_EMSCRIPTEN_USE_WASM}")
-# message("FIPS_EMSCRIPTEN_USE_WASM_ASMJS: ${FIPS_EMSCRIPTEN_USE_WASM_ASMJS}")
-# message("FIPS_EMSCRIPTEN_EXPORTED_FUNCTIONS: ${FIPS_EMSCRIPTEN_EXPORTED_FUNCTIONS}")
-# message("FIPS_EMSCRIPTEN_SHELL_HTML: ${FIPS_EMSCRIPTEN_SHELL_HTML}")
-# message("EMSCRIPTEN_TOTAL_MEMORY_WORKER: ${EMSCRIPTEN_TOTAL_MEMORY_WORKER}")
-# message("EMSCRIPTEN_USE_CLOSURE: ${EMSCRIPTEN_USE_CLOSURE}")
-# message("EMSCRIPTEN_ASSERTIONS: ${EMSCRIPTEN_ASSERTIONS}")
-# message("EMSCRIPTEN_DISABLE_EXCEPTION_CATCHING: ${EMSCRIPTEN_DISABLE_EXCEPTION_CATCHING}")
-# message("EMSCRIPTEN_NO_FILESYSTEM: ${EMSCRIPTEN_NO_FILESYSTEM}")
-# message("EMSCRIPTEN_DFE: ${EMSCRIPTEN_DFE}")
-# message("EMSCRIPTEN_TRACING: ${EMSCRIPTEN_TRACING}")
-# message("EMSCRIPTEN_SAFE_HEAP: ${EMSCRIPTEN_SAFE_HEAP}")
+    set(EMSC_LINKER_FLAGS "${EMSC_LINKER_FLAGS} -s BINARYEN=1 -s 'BINARYEN_METHOD=\"native-wasm,asmjs\"' -s 'BINARYEN_SCRIPTS=\"spidermonkify.py\"' -s GLOBAL_BASE=1000 -s ALIASING_FUNCTION_POINTERS=0")
+endif()
+set(EMSCRIPTEN_EXE_LINKER_FLAGS "${EMSC_EXE_LINKER_FLAGS} --shell-file ${FIPS_EMSCRIPTEN_SHELL_HTML}")

 set(CMAKE_SYSTEM_NAME Linux)
 set(CMAKE_SYSTEM_VERSION 1)
@@ -172,16 +145,11 @@
     get_filename_component(EMSCRIPTEN_CACHE "${EMSCRIPTEN_ROOT_PATH}/../../.emscripten_cache" ABSOLUTE)
 endif()
 if (EXISTS "${EMSCRIPTEN_DOT_FILE}")
-    set(EMSCRIPTEN_CONFIG_OPTION "--em-config ${EMSCRIPTEN_DOT_FILE}")
-    set(EMSCRIPTEN_CACHE_OPTION "--cache ${EMSCRIPTEN_CACHE}")
-    # message("Using local emscripten config at: ${EMSCRIPTEN_DOT_FILE}")
-    # message("Using local emscripten cache at: ${EMSCRIPTEN_CACHE}")
+    set(EMSC_COMMON_FLAGS "${EMSC_COMMON_FLAGS} --em-config ${EMSCRIPTEN_DOT_FILE} --cache ${EMSCRIPTEN_CACHE}")
+    set(EMSC_AR_FLAGS "${EMSC_AR_FLAGS} --em-config ${EMSCRIPTEN_DOT_FILE}")
 else()
     # no sdk-embedded config found, use the default (~/.emscripten and ~/.emscripten_cache)
-    set(EMSCRIPTEN_CONFIG_OPTION "")
-    set(EMSCRIPTEN_CACHE_OPTION "")
-    # message("Using global emscripten config at ~/.emscripten")
-    # message("Using global emscripten cache at ~/.emscripten_cache")
+    message(WARNING "Using global emscripten config and cache in '~'!")
 endif()

 # tool suffic (.bat on windows)
@@ -211,31 +179,31 @@
 set(CMAKE_SYSTEM_INCLUDE_PATH "${EMSCRIPTEN_ROOT_PATH}/system/include")

 # c++ compiler flags
-set(CMAKE_CXX_FLAGS "${EMSCRIPTEN_CONFIG_OPTION} ${EMSCRIPTEN_CACHE_OPTION} ${EMSCRIPTEN_TRACING_OPTION} -std=c++11 -stdlib=libc++ ${FIPS_EMSC_EXCEPTION_FLAGS} ${FIPS_EMSC_RTTI_FLAGS} -fstrict-aliasing -Wall -Wno-multichar -Wextra -Wno-unused-parameter -Wno-unknown-pragmas -Wno-ignored-qualifiers -Wno-long-long -Wno-overloaded-virtual -Wno-deprecated-writable-strings -Wno-unused-volatile-lvalue -Wno-inconsistent-missing-override -Wno-warn-absolute-paths")
+set(CMAKE_CXX_FLAGS "${EMSC_COMMON_FLAGS} ${EMSC_CXX_FLAGS} -std=c++11 -stdlib=libc++ -fstrict-aliasing -Wall -Wno-multichar -Wextra -Wno-unused-parameter -Wno-unknown-pragmas -Wno-ignored-qualifiers -Wno-long-long -Wno-overloaded-virtual -Wno-deprecated-writable-strings -Wno-unused-volatile-lvalue -Wno-inconsistent-missing-override -Wno-warn-absolute-paths")
 set(CMAKE_CXX_FLAGS_RELEASE "${EMSCRIPTEN_OPT} -DNDEBUG")
 set(CMAKE_CXX_FLAGS_DEBUG "${EMSCRIPTEN_OPT} -g -D_DEBUG_ -D_DEBUG -DFIPS_DEBUG=1")
 set(CMAKE_CXX_FLAGS_PROFILING "${EMSCRIPTEN_OPT} -DNDEBUG --profiling")

 # c compiler flags
-set(CMAKE_C_FLAGS "${EMSCRIPTEN_CONFIG_OPTION} ${EMSCRIPTEN_CACHE_OPTION} ${EMSCRIPTEN_TRACING_OPTION} -fstrict-aliasing -Wall -Wextra -Wno-multichar -Wno-unused-parameter -Wno-unknown-pragmas -Wno-ignored-qualifiers -Wno-long-long -Wno-overloaded-virtual -Wno-deprecated-writable-strings -Wno-unused-volatile-lvalue -Wno-warn-absolute-paths")
+set(CMAKE_C_FLAGS "${EMSC_COMMON_FLAGS} -fstrict-aliasing -Wall -Wextra -Wno-multichar -Wno-unused-parameter -Wno-unknown-pragmas -Wno-ignored-qualifiers -Wno-long-long -Wno-overloaded-virtual -Wno-deprecated-writable-strings -Wno-unused-volatile-lvalue -Wno-warn-absolute-paths")
 set(CMAKE_C_FLAGS_RELEASE "${EMSCRIPTEN_OPT} -DNDEBUG")
 set(CMAKE_C_FLAGS_DEBUG "${EMSCRIPTEN_OPT} -g -D_DEBUG_ -D_DEBUG -DFIPS_DEBUG=1")
 set(CMAKE_C_FLAGS_PROFILING "${EMSCRIPTEN_OPT} -DNDEBUG --profiling")

 # linker flags
-set(CMAKE_EXE_LINKER_FLAGS "${EMSCRIPTEN_CONFIG_OPTION} ${EMSCRIPTEN_CACHE_OPTION} ${EMSCRIPTEN_TRACING_OPTION} --memory-init-file ${EMSCRIPTEN_MEMORY_INIT_FLAG} -s MEM_INIT_METHOD=${FIPS_EMSCRIPTEN_MEM_INIT_METHOD} -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s TOTAL_MEMORY=${FIPS_EMSCRIPTEN_TOTAL_MEMORY} -s EXPORTED_FUNCTIONS=\"${FIPS_EMSCRIPTEN_EXPORTED_FUNCTIONS}\" -s DISABLE_EXCEPTION_CATCHING=${EMSCRIPTEN_DISABLE_EXCEPTION_CATCHING} -s NO_FILESYSTEM=${EMSCRIPTEN_NO_FILESYSTEM} -s ELIMINATE_DUPLICATE_FUNCTIONS=${EMSCRIPTEN_DFE} -s ELIMINATE_DUPLICATE_FUNCTIONS_DUMP_EQUIVALENT_FUNCTIONS=${EMSCRIPTEN_DFE_DUMP} -s SAFE_HEAP=${EMSCRIPTEN_SAFE_HEAP} -s NO_EXIT_RUNTIME=1 ${EMSCRIPTEN_WASM_FLAGS} ${EMSCRIPTEN_SHELL_FLAGS}")
-set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${EMSCRIPTEN_OPT} --llvm-lto ${FIPS_EMSCRIPTEN_LTO_LEVEL} -s VERBOSE=${EMSCRIPTEN_BUILD_VERBOSE} -s ASSERTIONS=${EMSCRIPTEN_ASSERTIONS} -s OUTLINING_LIMIT=${FIPS_EMSCRIPTEN_OUTLINING_LIMIT} --closure ${EMSCRIPTEN_USE_CLOSURE}")
-set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${EMSCRIPTEN_OPT} -g -s VERBOSE=${EMSCRIPTEN_BUILD_VERBOSE}")
-set(CMAKE_EXE_LINKER_FLAGS_PROFILING "--profiling ${EMSCRIPTEN_OPT} --llvm-lto ${FIPS_EMSCRIPTEN_LTO_LEVEL} -s VERBOSE=${EMSCRIPTEN_BUILD_VERBOSE} -s ASSERTIONS=${EMSCRIPTEN_ASSERTIONS} -s OUTLINING_LIMIT=${FIPS_EMSCRIPTEN_OUTLINING_LIMIT}")
+set(CMAKE_EXE_LINKER_FLAGS "${EMSC_COMMON_FLAGS} ${EMSC_LINKER_FLAGS} ${EMSC_EXE_LINKER_FLAGS}")
+set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${EMSCRIPTEN_OPT} ${EMSC_LINKER_FLAGS_RELEASE}")
+set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${EMSCRIPTEN_OPT} -g")
+set(CMAKE_EXE_LINKER_FLAGS_PROFILING "--profiling ${EMSCRIPTEN_OPT} ${EMSC_LINKER_FLAGS_RELEASE}")

 # static library flags (for CMAKE_AR)
-set(CMAKE_STATIC_LINKER_FLAGS "${EMSCRIPTEN_CONFIG_OPTION}")
+set(CMAKE_STATIC_LINKER_FLAGS "${EMSC_AR_FLAGS}")

 # dynamic lib linker flags
-set(CMAKE_SHARED_LINKER_FLAGS "-shared ${EMSCRIPTEN_CONFIG_OPTIONS} ${EMSCRIPTEN_CACHE_OPTION} ${EMSCRIPTEN_TRACING_OPTION} --memory-init-file 0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s TOTAL_MEMORY=${FIPS_EMSCRIPTEN_TOTAL_MEMORY_WORKER} -s BUILD_AS_WORKER=1 -s EXPORTED_FUNCTIONS=\"${FIPS_EMSCRIPTEN_EXPORTED_FUNCTIONS}\" -s DISABLE_EXCEPTION_CATCHING=${EMSCRIPTEN_DISABLE_EXCEPTION_CATCHING} -s NO_FILESYSTEM=${EMSCRIPTEN_NO_FILESYSTEM} -s ELIMINATE_DUPLICATE_FUNCTIONS=${EMSCRIPTEN_DFE} -s ELIMINATE_DUPLICATE_FUNCTIONS_DUMP_EQUIVALENT_FUNCTIONS=${EMSCRIPTEN_DFE_DUMP} -s SAFE_HEAP=${EMSCRIPTEN_SAFE_HEAP} -s NO_EXIT_RUNTIME=1 ${EMSCRIPTEN_WASM_FLAGS}")
-set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${EMSCRIPTEN_OPT} --llvm-lto ${FIPS_EMSCRIPTEN_LTO_LEVEL} -s VERBOSE=${EMSCRIPTEN_BUILD_VERBOSE} -s ASSERTIONS=${EMSCRIPTEN_ASSERTIONS} -s OUTLINING_LIMIT=${FIPS_EMSCRIPTEN_OUTLINING_LIMIT} --closure ${EMSCRIPTEN_USE_CLOSURE}")
-set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${EMSCRIPTEN_OPT} -g -s VERBOSE=${EMSCRIPTEN_BUILD_VERBOSE} --closure 0")
-set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "--profiling ${EMSCRIPTEN_OPT} --llvm-lto ${FIPS_EMSCRIPTEN_LTO_LEVEL} -s VERBOSE=${EMSCRIPTEN_BUILD_VERBOSE} -s ASSERTIONS=${EMSCRIPTEN_ASSERTIONS} -s OUTLINING_LIMIT=${FIPS_EMSCRIPTEN_OUTLINING_LIMIT}")
+set(CMAKE_SHARED_LINKER_FLAGS "-shared ${EMSC_COMMON_FLAGS} ${EMSC_LINKER_FLAGS} -s BUILD_AS_WORKER=1 ")
+set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${EMSCRIPTEN_OPT} ${EMSC_LINKER_FLAGS_RELEASE}")
+set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${EMSCRIPTEN_OPT} -g")
+set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "--profiling ${EMSCRIPTEN_OPT} ${EMSC_LINKER_FLAGS_RELEASE}")

 # update cache variables for cmake gui
 set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Config Type" FORCE)


Silence warnings when building builtin XROOTD

--- cmake/modules/SearchInstalledSoftware.cmake
+++ cmake/modules/SearchInstalledSoftware.cmake
@@ -619,6 +619,8 @@
   set(xrootd_version 4.2.2)
   set(xrootd_versionnum 400020002)
   message(STATUS "Downloading and building XROOTD version ${xrootd_version}")
+  string(REPLACE "-Wall " "" __cxxflags "${CMAKE_CXX_FLAGS}")  # Otherwise it produces many warnings
+  string(REPLACE "-W " "" __cxxflags "${__cxxflags}")          # Otherwise it produces many warnings
   ExternalProject_Add(
     XROOTD
     # http://xrootd.org/download/v${xrootd_version}/xrootd-${xrootd_version}.tar.gz
@@ -628,7 +630,7 @@
                -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
                -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
                -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-               -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
+               -DCMAKE_CXX_FLAGS=${__cxxflags}
                -DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
                -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
   )


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

--- cmake/modules/SearchInstalledSoftware.cmake
+++ cmake/modules/SearchInstalledSoftware.cmake
@@ -61,10 +61,14 @@
 #---Check for Unuran ------------------------------------------------------------------
 if(unuran AND NOT builtin_unuran)
   message(STATUS "Looking for Unuran")
-  find_Package(Unuran)
-  if(NOT UNURAN_FOUND)
-    message(STATUS "Unuran not found. Switching on builtin_unuran option")
-    set(builtin_unuran ON CACHE BOOL "Enabled because Unuran not found (${builtin_unuran_description})" FORCE)
+  if(fail-on-missing)
+    find_Package(Unuran REQUIRED)
+  else()
+    find_Package(Unuran)
+    if(NOT UNURAN_FOUND)
+      message(STATUS "Unuran not found. Switching on builtin_unuran option")
+      set(builtin_unuran ON CACHE BOOL "Enabled because Unuran not found (${builtin_unuran_description})" FORCE)
+    endif()
   endif()
 endif()


ARROW-6462: [C++] Fix build error on CentOS 6 x86_64 with bundled double-conversion

Because ${prefix}/lib64 is used on CentOS 6 x86_64.

Closes #5289 from kou/cpp-double-conversion-bundled-centos-6 and squashes the following commits:

a6b5fdfde <Sutou Kouhei>  Fix build error on CentOS 6 x86_64 with bundled double-conversion

Authored-by: Sutou Kouhei <73218711cdd5d5c30ac66da3cc4d9d9204caf34b@clear-code.com>
Signed-off-by: Krisztián Szűcs <6bab32dc957a05a87930e779f272342e159326fa@gmail.com>

--- cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -628,14 +628,16 @@
   message(STATUS "Building double-conversion from source")
   set(DOUBLE_CONVERSION_PREFIX
       "${CMAKE_CURRENT_BINARY_DIR}/double-conversion_ep/src/double-conversion_ep")
+  set(DOUBLE_CONVERSION_LIB_DIR "lib")
   set(double-conversion_INCLUDE_DIRS "${DOUBLE_CONVERSION_PREFIX}/include")
   set(
     DOUBLE_CONVERSION_STATIC_LIB
-    "${DOUBLE_CONVERSION_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}double-conversion${CMAKE_STATIC_LIBRARY_SUFFIX}"
+    "${DOUBLE_CONVERSION_PREFIX}/${DOUBLE_CONVERSION_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}double-conversion${CMAKE_STATIC_LIBRARY_SUFFIX}"
     )

   set(DOUBLE_CONVERSION_CMAKE_ARGS ${EP_COMMON_CMAKE_ARGS}
-                                   "-DCMAKE_INSTALL_PREFIX=${DOUBLE_CONVERSION_PREFIX}")
+                                   "-DCMAKE_INSTALL_PREFIX=${DOUBLE_CONVERSION_PREFIX}"
+                                   "-DCMAKE_INSTALL_LIBDIR=${DOUBLE_CONVERSION_LIB_DIR}")

   externalproject_add(double-conversion_ep
                       ${EP_LOG_OPTIONS}
@@ -865,7 +867,7 @@
     "${BROTLI_PREFIX}/${BROTLI_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}brotlicommon-static${CMAKE_STATIC_LIBRARY_SUFFIX}"
     )
   set(BROTLI_CMAKE_ARGS ${EP_COMMON_CMAKE_ARGS} "-DCMAKE_INSTALL_PREFIX=${BROTLI_PREFIX}"
-                        -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_SHARED_LIBS=OFF)
+                        -DCMAKE_INSTALL_LIBDIR=${BROTLI_LIB_DIR} -DBUILD_SHARED_LIBS=OFF)

   externalproject_add(brotli_ep
                       URL ${BROTLI_SOURCE_URL}


Use -O4 for CUDA compilations & cleanup.

--- runtime/hipacc_cu.hpp.cmake
+++ runtime/hipacc_cu.hpp.cmake
@@ -128,11 +128,11 @@

 std::string getCUDAErrorCodeStrDrv(CUresult errorCode) {
-    const char *errorName;
-    const char *errorString;
-    cuGetErrorName(errorCode, &errorName);
-    cuGetErrorString(errorCode, &errorString);
-    return std::string(errorName) + ": " + std::string(errorString);
+    const char *error_name;
+    const char *error_string;
+    cuGetErrorName(errorCode, &error_name);
+    cuGetErrorString(errorCode, &error_string);
+    return std::string(error_name) + ": " + std::string(error_string);
 }

@@ -584,20 +584,19 @@
 void hipaccCreateModule(CUmodule &module, const void *ptx, int cc) {
     CUresult err = CUDA_SUCCESS;
     CUjit_target target_cc = (CUjit_target) cc;
-
-
-    const int errorLogSize = 10240;
-    char errorLogBuffer[errorLogSize] = {0};
-
-    int num_options = 2;
-    CUjit_option options[] = { CU_JIT_ERROR_LOG_BUFFER, CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES, CU_JIT_TARGET };
-    void *optionValues[] = { (void *)errorLogBuffer, (void *)errorLogSize, (void *)target_cc };
+    const unsigned opt_level = 3;
+    const int error_log_size = 10240;
+    const int num_options = 4;
+    char error_log_buffer[error_log_size] = { 0 };
+
+    CUjit_option options[] = { CU_JIT_ERROR_LOG_BUFFER, CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES, CU_JIT_TARGET, CU_JIT_OPTIMIZATION_LEVEL };
+    void *option_values[]  = { (void *)error_log_buffer, (void *)(size_t)error_log_size, (void *)target_cc, (void*)(size_t)opt_level };

     // load ptx source
-    err = cuModuleLoadDataEx(&module, ptx, num_options, options, optionValues);
+    err = cuModuleLoadDataEx(&module, ptx, num_options, options, option_values);

     if (err != CUDA_SUCCESS) {
-        std::cerr << "Error log: " << errorLogBuffer << std::endl;
+        std::cerr << "Error log: " << error_log_buffer << std::endl;
     }
     checkErrDrv(err, "cuModuleLoadDataEx()");
 }
@@ -659,7 +658,7 @@
 }
 #else
 void hipaccCompileCUDAToModule(CUmodule &module, std::string file_name, int cc, std::vector<std::string> &build_options) {
-    std::string command = "${NVCC} -ptx -arch=compute_" + std::to_string(cc) + " ";
+    std::string command = "${NVCC} -O4 -ptx -arch=compute_" + std::to_string(cc) + " ";
     for (auto option : build_options) command += option + " ";
     command += file_name + " -o " + file_name + ".ptx 2>&1";

@@ -687,8 +686,8 @@
     }

     std::string ptx_string(std::istreambuf_iterator<char>(ptx_file), (std::istreambuf_iterator<char>()));
-
     const char *ptx = (const char *)ptx_string.c_str();
+
     // compile ptx
     hipaccCreateModule(module, ptx, cc);
 }


cmake fix ctest output on failure for coverage (#8112)

--- src/firmware/posix/sitl_tests.cmake
+++ src/firmware/posix/sitl_tests.cmake
@@ -94,7 +94,7 @@
 set_target_properties(test_results PROPERTIES EXCLUDE_FROM_ALL TRUE)

 if (CMAKE_BUILD_TYPE STREQUAL Coverage)
-	setup_target_for_coverage(test_coverage ${CMAKE_CTEST_COMMAND} coverage.info "--output-on-failure -T Test")
+	setup_target_for_coverage(test_coverage "${CMAKE_CTEST_COMMAND} --output-on-failure -T Test" coverage.info)
 endif()

 add_custom_target(test_results_junit


Trim output result when searching python packages

Avoids a bug with older cmake. Older cmake cannot  read from CMakeCache.txt file with an unexpected
'\n' value.

--- scripts/PythonPackage.cmake
+++ scripts/PythonPackage.cmake
@@ -72,7 +72,7 @@
             OUTPUT_VARIABLE OUTPUT
         )
         if("${LOCATION_WAS_FOUND}" STREQUAL "0")
-            set(${PACKAGE}_LOCATION ${OUTPUT})
+            string(STRIP "${OUTPUT}" ${PACKAGE}_LOCATION)
         endif()
     endif()
     find_package_handle_standard_args(${PACKAGE}


fixed: verbosity

fixed: verbosity

--- share/hugh/cmake/SetupCompilerDefaults.cmake
+++ share/hugh/cmake/SetupCompilerDefaults.cmake
@@ -28,8 +28,10 @@
 string(REPLACE ";" " " CMAKE_CXX_FLAGS           "${CMAKE_CXX_FLAGS}")
 string(REPLACE ";" " " CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")

-#cma_print_variable(CMAKE_CXX_FLAGS)
-#cma_print_variable(CMAKE_SHARED_LINKER_FLAGS)
+if(VERBOSE)
+  cma_print_variable(CMAKE_CXX_FLAGS)
+  cma_print_variable(CMAKE_SHARED_LINKER_FLAGS)
+endif()

 if(NOT VERBOSE)
   # disable "Performing Test VARIABLE" message from 'Check*Source*.cmake'


Add libpthread to DynLibDep exclude list.

	* build-aux/cmake/modules/DynLibDep.cmake: here.

Signed-off-by: Vincent Ordy <d26676a94649632b1c477e78d16c5a762a0d6fbf@gostai.com>

--- build-aux/cmake/modules/DynLibDep.cmake
+++ build-aux/cmake/modules/DynLibDep.cmake
@@ -11,9 +11,10 @@
   set(DLDEP_UNIX_EXCLUSION_LIST
     "^libc.so"
     "^libdl.so"
+    "^libpthread*"      # Fedora 9
     )

-  # The list of excluded Unix libraries.
+  # The list of excluded Windows libraries.
   set(DLDEP_WIN32_EXCLUSION_LIST
     "^KERNEL32.dll"
     "^ntdll.dll"


Check for error.

Check for error.

	* build-aux/cmake/modules/UnrtfFile.cmake: Do that and display stderr.

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

--- build-aux/cmake/modules/UnrtfFile.cmake
+++ build-aux/cmake/modules/UnrtfFile.cmake
@@ -19,6 +19,11 @@
     OUTPUT_FILE ${tmpout}
     OUTPUT_STRIP_TRAILING_WHITESPACE
     )
+  if(ret)
+    message(SEND_ERROR
+      "'${UNRTF_EXECUTABLE}' failed to build '${input}' to '${output}'")
+    message(STATUS "Unrtf error begins:\n${err}\nUnrtf error ends.")
+  endif(ret)
   # Remove the header.
   file(READ ${tmpout} inbuf)
   string(REGEX REPLACE "^.*-----------------\n" "" outbuf ${inbuf})


Don't force the CMAKE_BUILD_TYPE or we can't overwrite it.

git-svn-id: b1dee0d48e635e16c3b356ce77271b225d4db9f7@758 7dcaeef0-15fb-0310-b436-a5af3365683c

--- cmake/Modules/DefineCMakeDefaults.cmake
+++ cmake/Modules/DefineCMakeDefaults.cmake
@@ -23,6 +23,5 @@
   set(CMAKE_BUILD_TYPE RelWithDebInfo
     CACHE STRING
       "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
-    FORCE
   )
 endif (NOT CMAKE_BUILD_TYPE)


host-tools.cmake: Corrected sdk download url

Corrected sdk download url for 0.10.0

Signed-off-by: Arun Joshi <384b63a396d676e8475469d4ebb06878676dc400@intel.com>

--- cmake/toolchain/zephyr/host-tools.cmake
+++ cmake/toolchain/zephyr/host-tools.cmake
@@ -37,7 +37,7 @@
 You need at least SDK version ${REQUIRED_SDK_VER}.
 You have version ${SDK_VERSION} (${ZEPHYR_SDK_INSTALL_DIR}).
 The new version of the SDK can be downloaded from:
-https://github.com/zephyrproject-rtos/meta-zephyr-sdk/releases/download/${REQUIRED_SDK_VER}/zephyr-sdk-${REQUIRED_SDK_VER}-setup.run
+https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${REQUIRED_SDK_VER}/zephyr-sdk-${REQUIRED_SDK_VER}-setup.run
 ")
 endif()


Prepare MUnit for intentional failures

Prepare MUnit for intentional failures

Change the ReportUnitTestResult function in the CommonFunctions.cmake file
to account for intentionally failing checks in an MUnit test output.

Add a check to the section that prints the failure line, which attempts to
match the line to the regex "[Ii]ntentional"  If it finds a match, that
error does not cause the test to fail.

Remove  the failure condition that checks for the error number in the
summary.

OSEHRA-Id: http://issues.osehra.org/browse/OAT-150
Change-Id: I5c0bb477111c0a816d87382ab6baeef9bece34d0

--- CMake/CommonFunctions.cmake
+++ CMake/CommonFunctions.cmake
@@ -83,11 +83,9 @@
      # Captures and prints the failure message
      elseif(line MATCHES "^ ?[^\\^]+\\^${routine_name}+")
        message("${routine_name}: ${line}")
-       set(test_passed FALSE)
-     # Matches the first part of the results line, checking for test failures
-     elseif(line MATCHES "^ ?Checked.*, with [1-9]+ failure")
-       message("${routine_name} in package ${PACKAGE_NAME}:\n${line}")
-       set(test_passed FALSE)
+       if(NOT ${line} MATCHES [iI]ntentional)
+         set(test_passed FALSE)
+       endif()
      # Matches the second part of the results line, checking for errors
      elseif(line MATCHES "encountered [1-9]+ error")
        message("M Error(s) encountered in ${routine_name} in package ${PACKAGE_NAME}")


ENH: Teach ITK module macros to support independent header-only modules

Allow an empty <mod>_LIBRARIES list, so long as the variable is defined.
This is needed to allow header-only modules with no dependencies on
modules with actual libraries.

Change-Id: Ic2ea8620ff599c000fadaa54688cb0ead622f52f

--- CMake/ITKModuleMacros.cmake
+++ CMake/ITKModuleMacros.cmake
@@ -305,9 +305,9 @@
 macro(itk_module_link_dependencies)
   # link to public dependencies
   foreach(dep IN LISTS ITK_MODULE_${itk-module}_PUBLIC_DEPENDS)
-    if(${dep}_LIBRARIES)
+    if(DEFINED ${dep}_LIBRARIES)
       target_link_libraries(${itk-module} LINK_PUBLIC ${${dep}_LIBRARIES})
-    elseif(${dep})
+    elseif(DEFINED ${dep})
       target_link_libraries(${itk-module} LINK_PUBLIC ${${dep}})
     else()
       message(FATAL_ERROR "Dependency \"${dep}\" not found: could not find [${dep}] or [${dep}_LIBRARIES]")
@@ -316,9 +316,9 @@

   # link to private dependencies
   foreach(dep IN LISTS ITK_MODULE_${itk-module}_PRIVATE_DEPENDS)
-    if(${dep}_LIBRARIES)
+    if(DEFINED ${dep}_LIBRARIES)
       target_link_libraries(${itk-module} LINK_PRIVATE ${${dep}_LIBRARIES})
-    elseif(${dep})
+    elseif(DEFINED ${dep})
       target_link_libraries(${itk-module} LINK_PRIVATE ${${dep}})
     else()
       message(FATAL_ERROR "Dependency \"${dep}\" not found: could not find [${dep}] or [${dep}_LIBRARIES]")


fix bundling

fix bundling

--- superbuild/Projects/nuclearRGG.bundle.common.cmake
+++ superbuild/Projects/nuclearRGG.bundle.common.cmake
@@ -47,7 +47,7 @@

 #set the programs we want to install
 set(rgg_programs_to_install
-     CMBNuclear
+     RGGNuclear
     )


Use target_link_options directly.

Use target_link_options directly.

--- functions.cmake
+++ functions.cmake
@@ -221,7 +221,7 @@
     endif()

     if(NOT ARG_OBJECT AND NOT ARG_STATIC AND NOT ARG_INTERFACE AND NOT ARG_ALLOW_UNRESOLVED_SYMBOLS AND DEFINED VESPA_DISALLOW_UNRESOLVED_SYMBOLS_IN_SHARED_LIBRARIES)
-        __add_private_target_link_option(${TARGET} ${VESPA_DISALLOW_UNRESOLVED_SYMBOLS_IN_SHARED_LIBRARIES})
+        target_link_options(${TARGET} PRIVATE ${VESPA_DISALLOW_UNRESOLVED_SYMBOLS_IN_SHARED_LIBRARIES})
     endif()

     __add_target_to_module(${TARGET})
@@ -779,17 +779,3 @@
     set_source_files_properties(${ARG_SOURCES} PROPERTIES COMPILE_FLAGS "-Wno-array-bounds -Wno-suggest-override -Wno-inline ${VESPA_DISABLE_UNUSED_WARNING}")
   endif()
 endfunction()
-
-function(__add_private_target_link_option TARGET TARGET_LINK_OPTION)
-  if(COMMAND target_link_options)
-    target_link_options(${TARGET} PRIVATE ${TARGET_LINK_OPTION})
-  else()
-    get_target_property(TARGET_LINK_FLAGS ${TARGET} LINK_FLAGS)
-    if (NOT DEFINED TARGET_LINK_FLAGS OR ${TARGET_LINK_FLAGS} STREQUAL "" OR ${TARGET_LINK_FLAGS} STREQUAL "TARGET_LINK_FLAGS-NOTFOUND")
-      set(TARGET_LINK_FLAGS ${TARGET_LINK_OPTION})
-    else()
-      set(TARGET_LINK_FLAGS "${TARGET_LINK_FLAGS} ${TARGET_LINK_OPTION}")
-    endif()
-    set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "${TARGET_LINK_FLAGS}")
-  endif()
-endfunction()


de-screamify ospcommon provided macro file

--- components/ospcommon/cmake/macros.cmake
+++ components/ospcommon/cmake/macros.cmake
@@ -15,18 +15,18 @@
 ## ======================================================================== ##

 ## Macro for printing CMake variables ##
-MACRO(PRINT var)
-  MESSAGE("${var} = ${${var}}")
-ENDMACRO()
+macro(print var)
+  message("${var} = ${${var}}")
+endmacro()

 ## Macro to print a warning message that only appears once ##
-MACRO(OSPRAY_WARN_ONCE identifier message)
-  SET(INTERNAL_WARNING "OSPRAY_WARNED_${identifier}")
-  IF(NOT ${INTERNAL_WARNING})
-    MESSAGE(WARNING ${message})
-    SET(${INTERNAL_WARNING} ON CACHE INTERNAL "Warned about '${message}'")
-  ENDIF()
-ENDMACRO()
+macro(ospray_warn_once IDENTIFIER MESSAGE)
+  set(INTERNAL_WARNING "OSPRAY_WARNED_${IDENTIFIER}")
+  if(NOT ${INTERNAL_WARNING})
+    message(WARNING ${MESSAGE})
+    set(${INTERNAL_WARNING} ON CACHE INTERNAL "Warned about '${MESSAGE}'")
+  endif()
+endmacro()

 # workaround link issues to Embree ISPC exports
@@ -34,154 +34,153 @@
 # code) when compiling for multiple targets. Thus, when only one OSPRay ISA is
 # selected, but Embree was compiled for multiple ISAs, we need to add a
 # second, different, supported dummy target.
-MACRO(OSPRAY_FIX_ISPC_TARGET_LIST)
-  LIST(LENGTH OSPRAY_ISPC_TARGET_LIST NUM_TARGETS)
-  IF (NUM_TARGETS EQUAL 1)
-    IF (EMBREE_ISA_SUPPORTS_SSE2)
-      LIST(APPEND OSPRAY_ISPC_TARGET_LIST sse2)
-    ELSEIF (EMBREE_ISA_SUPPORTS_SSE4 AND
+macro(ospray_fix_ispc_target_list)
+  list(LENGTH OSPRAY_ISPC_TARGET_LIST NUM_TARGETS)
+  if (NUM_TARGETS EQUAL 1)
+    if (EMBREE_ISA_SUPPORTS_SSE2)
+      list(APPEND OSPRAY_ISPC_TARGET_LIST sse2)
+    elseif (EMBREE_ISA_SUPPORTS_SSE4 AND
             NOT OSPRAY_ISPC_TARGET_LIST STREQUAL "sse4")
-      LIST(APPEND OSPRAY_ISPC_TARGET_LIST sse4)
-    ELSEIF (EMBREE_ISA_SUPPORTS_AVX AND
+      list(APPEND OSPRAY_ISPC_TARGET_LIST sse4)
+    elseif (EMBREE_ISA_SUPPORTS_AVX AND
             NOT OSPRAY_ISPC_TARGET_LIST STREQUAL "avx")
-      LIST(APPEND OSPRAY_ISPC_TARGET_LIST avx)
-    ELSEIF (EMBREE_ISA_SUPPORTS_AVX2 AND
+      list(APPEND OSPRAY_ISPC_TARGET_LIST avx)
+    elseif (EMBREE_ISA_SUPPORTS_AVX2 AND
             NOT OSPRAY_ISPC_TARGET_LIST STREQUAL "avx2")
-      LIST(APPEND OSPRAY_ISPC_TARGET_LIST avx2)
-    ELSEIF (EMBREE_ISA_SUPPORTS_AVX512KNL AND
+      list(APPEND OSPRAY_ISPC_TARGET_LIST avx2)
+    elseif (EMBREE_ISA_SUPPORTS_AVX512KNL AND
             NOT OSPRAY_ISPC_TARGET_LIST STREQUAL "avx512knl-i32x16")
-      LIST(APPEND OSPRAY_ISPC_TARGET_LIST avx512knl-i32x16)
-    ELSEIF (EMBREE_ISA_SUPPORTS_AVX512SKX AND
+      list(APPEND OSPRAY_ISPC_TARGET_LIST avx512knl-i32x16)
+    elseif (EMBREE_ISA_SUPPORTS_AVX512SKX AND
             NOT OSPRAY_ISPC_TARGET_LIST STREQUAL "avx512skx-i32x16")
-      LIST(APPEND OSPRAY_ISPC_TARGET_LIST avx512skx-i32x16)
-    ENDIF()
-  ENDIF()
-ENDMACRO()
+      list(APPEND OSPRAY_ISPC_TARGET_LIST avx512skx-i32x16)
+    endif()
+  endif()
+endmacro()

 ## Macro configure ISA targets for ispc ##
-MACRO(OSPRAY_CONFIGURE_ISPC_ISA)
-
-  SET(OSPRAY_BUILD_ISA "ALL" CACHE STRING
+macro(ospray_configure_ispc_isa)
+
+  set(OSPRAY_BUILD_ISA "ALL" CACHE STRING
       "Target ISA (SSE4, AVX, AVX2, AVX512KNL, AVX512SKX, or ALL)")
-  STRING(TOUPPER ${OSPRAY_BUILD_ISA} OSPRAY_BUILD_ISA)
-
-  OPTION(OSPRAY_BUILD_ISA_SCALAR
+  string(TOUPPER ${OSPRAY_BUILD_ISA} OSPRAY_BUILD_ISA)
+
+  option(OSPRAY_BUILD_ISA_SCALAR
          "Include 'SCALAR' target (WARNING: may not work!)" OFF)
-  MARK_AS_ADVANCED(OSPRAY_BUILD_ISA_SCALAR)
-
-  IF (OSPRAY_BUILD_ISA_SCALAR)
-    SET(OSPRAY_SUPPORTED_ISAS SCALAR)
-  ENDIF()
-
-  IF(EMBREE_ISA_SUPPORTS_SSE4)
-    SET(OSPRAY_SUPPORTED_ISAS ${OSPRAY_SUPPORTED_ISAS} SSE4)
-  ENDIF()
-  IF(EMBREE_ISA_SUPPORTS_AVX)
-    SET(OSPRAY_SUPPORTED_ISAS ${OSPRAY_SUPPORTED_ISAS} AVX)
-  ENDIF()
-  IF(EMBREE_ISA_SUPPORTS_AVX2)
-    SET(OSPRAY_SUPPORTED_ISAS ${OSPRAY_SUPPORTED_ISAS} AVX2)
-  ENDIF()
-  IF(EMBREE_ISA_SUPPORTS_AVX512KNL)
-    SET(OSPRAY_SUPPORTED_ISAS ${OSPRAY_SUPPORTED_ISAS} AVX512KNL)
-  ENDIF()
-  IF(EMBREE_ISA_SUPPORTS_AVX512SKX)
-    SET(OSPRAY_SUPPORTED_ISAS ${OSPRAY_SUPPORTED_ISAS} AVX512SKX)
-  ENDIF()
-
-  SET_PROPERTY(CACHE OSPRAY_BUILD_ISA PROPERTY STRINGS
+  mark_as_advanced(OSPRAY_BUILD_ISA_SCALAR)
+
+  if (OSPRAY_BUILD_ISA_SCALAR)
+    set(OSPRAY_SUPPORTED_ISAS SCALAR)
+  endif()
+
+  if(EMBREE_ISA_SUPPORTS_SSE4)
+    set(OSPRAY_SUPPORTED_ISAS ${OSPRAY_SUPPORTED_ISAS} SSE4)
+  endif()
+  if(EMBREE_ISA_SUPPORTS_AVX)
+    set(OSPRAY_SUPPORTED_ISAS ${OSPRAY_SUPPORTED_ISAS} AVX)
+  endif()
+  if(EMBREE_ISA_SUPPORTS_AVX2)
+    set(OSPRAY_SUPPORTED_ISAS ${OSPRAY_SUPPORTED_ISAS} AVX2)
+  endif()
+  if(EMBREE_ISA_SUPPORTS_AVX512KNL)
+    set(OSPRAY_SUPPORTED_ISAS ${OSPRAY_SUPPORTED_ISAS} AVX512KNL)
+  endif()
+  if(EMBREE_ISA_SUPPORTS_AVX512SKX)
+    set(OSPRAY_SUPPORTED_ISAS ${OSPRAY_SUPPORTED_ISAS} AVX512SKX)
+  endif()
+
+  set_property(CACHE OSPRAY_BUILD_ISA PROPERTY STRINGS
                ALL ${OSPRAY_SUPPORTED_ISAS})

-  UNSET(OSPRAY_ISPC_TARGET_LIST)
-
-  IF (OSPRAY_BUILD_ISA STREQUAL "ALL")
-
-    IF(EMBREE_ISA_SUPPORTS_SSE4)
-      SET(OSPRAY_ISPC_TARGET_LIST ${OSPRAY_ISPC_TARGET_LIST} sse4)
-      MESSAGE(STATUS "OSPRay SSE4 ISA target enabled.")
-    ENDIF()
-    IF(EMBREE_ISA_SUPPORTS_AVX)
-      SET(OSPRAY_ISPC_TARGET_LIST ${OSPRAY_ISPC_TARGET_LIST} avx)
-      MESSAGE(STATUS "OSPRay AVX ISA target enabled.")
-    ENDIF()
-    IF(EMBREE_ISA_SUPPORTS_AVX2)
-      SET(OSPRAY_ISPC_TARGET_LIST ${OSPRAY_ISPC_TARGET_LIST} avx2)
-      MESSAGE(STATUS "OSPRay AVX2 ISA target enabled.")
-    ENDIF()
-    IF(EMBREE_ISA_SUPPORTS_AVX512KNL)
-      SET(OSPRAY_ISPC_TARGET_LIST ${OSPRAY_ISPC_TARGET_LIST} avx512knl-i32x16)
-      MESSAGE(STATUS "OSPRay AVX512KNL ISA target enabled.")
-    ENDIF()
-    IF(EMBREE_ISA_SUPPORTS_AVX512SKX)
-      SET(OSPRAY_ISPC_TARGET_LIST ${OSPRAY_ISPC_TARGET_LIST} avx512skx-i32x16)
-      MESSAGE(STATUS "OSPRay AVX512SKX ISA target enabled.")
-    ENDIF()
-
-  ELSEIF (OSPRAY_BUILD_ISA STREQUAL "AVX512SKX")
-
-    IF(NOT EMBREE_ISA_SUPPORTS_AVX512SKX)
-      MESSAGE(FATAL_ERROR "Your Embree build does not support AVX512SKX!")
-    ENDIF()
-    SET(OSPRAY_ISPC_TARGET_LIST avx512skx-i32x16)
-
-  ELSEIF (OSPRAY_BUILD_ISA STREQUAL "AVX512KNL")
-
-    IF(NOT EMBREE_ISA_SUPPORTS_AVX512KNL)
-      MESSAGE(FATAL_ERROR "Your Embree build does not support AVX512KNL!")
-    ENDIF()
-    SET(OSPRAY_ISPC_TARGET_LIST avx512knl-i32x16)
-
-  ELSEIF (OSPRAY_BUILD_ISA STREQUAL "AVX2")
-
-    IF(NOT EMBREE_ISA_SUPPORTS_AVX2)
-      MESSAGE(FATAL_ERROR "Your Embree build does not support AVX2!")
-    ENDIF()
-    SET(OSPRAY_ISPC_TARGET_LIST avx2)
-
-  ELSEIF (OSPRAY_BUILD_ISA STREQUAL "AVX")
-
-    IF(NOT EMBREE_ISA_SUPPORTS_AVX)
-      MESSAGE(FATAL_ERROR "Your Embree build does not support AVX!")
-    ENDIF()
-    SET(OSPRAY_ISPC_TARGET_LIST avx)
-
-  ELSEIF (OSPRAY_BUILD_ISA STREQUAL "SSE4")
-
-    IF(NOT EMBREE_ISA_SUPPORTS_SSE4)
-      MESSAGE(FATAL_ERROR "Your Embree build does not support SSE4!")
-    ENDIF()
-    SET(OSPRAY_ISPC_TARGET_LIST sse4)
-
-  ELSE ()
-    MESSAGE(ERROR "Invalid OSPRAY_BUILD_ISA value. "
+  unset(OSPRAY_ISPC_TARGET_LIST)
+  if (OSPRAY_BUILD_ISA STREQUAL "ALL")
+
+    if(EMBREE_ISA_SUPPORTS_SSE4)
+      set(OSPRAY_ISPC_TARGET_LIST ${OSPRAY_ISPC_TARGET_LIST} sse4)
+      message(STATUS "OSPRay SSE4 ISA target enabled.")
+    endif()
+    if(EMBREE_ISA_SUPPORTS_AVX)
+      set(OSPRAY_ISPC_TARGET_LIST ${OSPRAY_ISPC_TARGET_LIST} avx)
+      message(STATUS "OSPRay AVX ISA target enabled.")
+    endif()
+    if(EMBREE_ISA_SUPPORTS_AVX2)
+      set(OSPRAY_ISPC_TARGET_LIST ${OSPRAY_ISPC_TARGET_LIST} avx2)
+      message(STATUS "OSPRay AVX2 ISA target enabled.")
+    endif()
+    if(EMBREE_ISA_SUPPORTS_AVX512KNL)
+      set(OSPRAY_ISPC_TARGET_LIST ${OSPRAY_ISPC_TARGET_LIST} avx512knl-i32x16)
+      message(STATUS "OSPRay AVX512KNL ISA target enabled.")
+    endif()
+    if(EMBREE_ISA_SUPPORTS_AVX512SKX)
+      set(OSPRAY_ISPC_TARGET_LIST ${OSPRAY_ISPC_TARGET_LIST} avx512skx-i32x16)
+      message(STATUS "OSPRay AVX512SKX ISA target enabled.")
+    endif()
+
+  elseif (OSPRAY_BUILD_ISA STREQUAL "AVX512SKX")
+
+    if(NOT EMBREE_ISA_SUPPORTS_AVX512SKX)
+      message(FATAL_ERROR "Your Embree build does not support AVX512SKX!")
+    endif()
+    set(OSPRAY_ISPC_TARGET_LIST avx512skx-i32x16)
+
+  elseif (OSPRAY_BUILD_ISA STREQUAL "AVX512KNL")
+
+    if(NOT EMBREE_ISA_SUPPORTS_AVX512KNL)
+      message(FATAL_ERROR "Your Embree build does not support AVX512KNL!")
+    endif()
+    set(OSPRAY_ISPC_TARGET_LIST avx512knl-i32x16)
+
+  elseif (OSPRAY_BUILD_ISA STREQUAL "AVX2")
+
+    if(NOT EMBREE_ISA_SUPPORTS_AVX2)
+      message(FATAL_ERROR "Your Embree build does not support AVX2!")
+    endif()
+    set(OSPRAY_ISPC_TARGET_LIST avx2)
+
+  elseif (OSPRAY_BUILD_ISA STREQUAL "AVX")
+
+    if(NOT EMBREE_ISA_SUPPORTS_AVX)
+      message(FATAL_ERROR "Your Embree build does not support AVX!")
+    endif()
+    set(OSPRAY_ISPC_TARGET_LIST avx)
+
+  elseif (OSPRAY_BUILD_ISA STREQUAL "SSE4")
+
+    if(NOT EMBREE_ISA_SUPPORTS_SSE4)
+      message(FATAL_ERROR "Your Embree build does not support SSE4!")
+    endif()
+    set(OSPRAY_ISPC_TARGET_LIST sse4)
+
+  else()
+    message(ERROR "Invalid OSPRAY_BUILD_ISA value. "
                   "Please select one of ${OSPRAY_SUPPORTED_ISAS}, or ALL.")
-  ENDIF()
-
-  OSPRAY_FIX_ISPC_TARGET_LIST()
-ENDMACRO()
+  endif()
+
+  ospray_fix_ispc_target_list()
+endmacro()

 ## Target creation macros ##

-MACRO(OSPRAY_ADD_LIBRARY name type)
-  SET(ISPC_SOURCES "")
-  SET(OTHER_SOURCES "")
-  FOREACH(src ${ARGN})
-    GET_FILENAME_COMPONENT(ext ${src} EXT)
-    IF (ext STREQUAL ".ispc")
-      SET(ISPC_SOURCES ${ISPC_SOURCES} ${src})
-    ELSE ()
-      SET(OTHER_SOURCES ${OTHER_SOURCES} ${src})
-    ENDIF ()
-  ENDFOREACH()
-  OSPRAY_ISPC_COMPILE(${ISPC_SOURCES})
-  ADD_LIBRARY(${name} ${type} ${ISPC_OBJECTS} ${OTHER_SOURCES} ${ISPC_SOURCES})
-ENDMACRO()
+macro(ospray_add_library name type)
+  set(ISPC_SOURCES "")
+  set(OTHER_SOURCES "")
+  foreach(src ${ARGN})
+    get_filename_component(ext ${src} EXT)
+    if (ext STREQUAL ".ispc")
+      set(ISPC_SOURCES ${ISPC_SOURCES} ${src})
+    else()
+      set(OTHER_SOURCES ${OTHER_SOURCES} ${src})
+    endif ()
+  endforeach()
+  ospray_ispc_compile(${ISPC_SOURCES})
+  add_library(${name} ${type} ${ISPC_OBJECTS} ${OTHER_SOURCES} ${ISPC_SOURCES})
+endmacro()

 ## Target install macros for OSPRay libraries ##
-INCLUDE(GNUInstallDirs)
-
-MACRO(OSPRAY_INSTALL_LIBRARY name component)
-  INSTALL(TARGETS ${name}
+include(GNUInstallDirs)
+
+macro(ospray_install_library name component)
+  install(TARGETS ${name}
     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
       COMPONENT ${component}
       NAMELINK_SKIP
@@ -197,7 +196,7 @@
   # RUNTIME and ARCHIVE components a second time to prevent an "install TARGETS
   # given no ARCHIVE DESTINATION for static library target" error. Installing
   # these components twice doesn't hurt anything.
-  INSTALL(TARGETS ${name}
+  install(TARGETS ${name}
     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
       COMPONENT devel
       NAMELINK_ONLY
@@ -206,58 +205,57 @@
     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
       COMPONENT devel
   )
-ENDMACRO()
+endmacro()

 ## Target versioning macro ##

-MACRO(OSPRAY_SET_LIBRARY_VERSION name)
-  SET_TARGET_PROPERTIES(${name}
+macro(ospray_set_library_version name)
+  set_target_properties(${name}
     PROPERTIES VERSION ${OSPRAY_VERSION} SOVERSION ${OSPRAY_SOVERSION})
-ENDMACRO()
-
-
-# Helper function to return arguments of OSPRAY_CREATE_ in separate
+endmacro()
+
+# Helper function to return arguments of ospray_create_ in separate
 # variables, prefixed with PREFIX
-FUNCTION(OSPRAY_SPLIT_CREATE_ARGS PREFIX)
-  SET(MY_SOURCES "")
-  SET(LIBS "")
-  SET(MY_EXCLUDE_FROM_ALL FALSE)
-  SET(MY_COMPONENT ${OSPRAY_DEFAULT_COMPONENT})
-  SET(CURRENT_LIST MY_SOURCES)
-
-  FOREACH(arg ${ARGN})
-    IF ("${arg}" STREQUAL "LINK")
-      SET(CURRENT_LIST LIBS)
-    ELSEIF ("${arg}" STREQUAL "EXCLUDE_FROM_ALL")
-      SET(MY_EXCLUDE_FROM_ALL TRUE)
-    ELSEIF ("${arg}" STREQUAL "COMPONENT")
-      SET(CURRENT_LIST MY_COMPONENT)
-    ELSE()
-      LIST(APPEND ${CURRENT_LIST} ${arg})
-    ENDIF ()
-  ENDFOREACH()
+function(ospray_split_create_args PREFIX)
+  set(MY_SOURCES "")
+  set(LIBS "")
+  set(MY_EXCLUDE_FROM_ALL FALSE)
+  set(MY_COMPONENT ${OSPRAY_DEFAULT_COMPONENT})
+  set(CURRENT_LIST MY_SOURCES)
+
+  foreach(arg ${ARGN})
+    if ("${arg}" STREQUAL "LINK")
+      set(CURRENT_LIST LIBS)
+    elseif ("${arg}" STREQUAL "EXCLUDE_FROM_ALL")
+      set(MY_EXCLUDE_FROM_ALL TRUE)
+    elseif ("${arg}" STREQUAL "COMPONENT")
+      set(CURRENT_LIST MY_COMPONENT)
+    else()
+      list(APPEND ${CURRENT_LIST} ${arg})
+    endif ()
+  endforeach()

   # COMPONENT only required when installed
-  IF (NOT ${MY_EXCLUDE_FROM_ALL})
-    LIST(LENGTH MY_COMPONENT COMPONENTS)
-    IF (COMPONENTS EQUAL 0)
-      MESSAGE(STATUS "No COMPONENT for installation specified! Using default COMPONENT name \"${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}\"")
-      SET(MY_COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
-    ELSE()
-      LIST(GET MY_COMPONENT -1 MY_COMPONENT)
-    ENDIF()
-  ENDIF()
-
-  SET(${PREFIX}_SOURCES ${MY_SOURCES} PARENT_SCOPE)
-  SET(${PREFIX}_LIBS ${LIBS} PARENT_SCOPE)
-  SET(${PREFIX}_EXCLUDE_FROM_ALL ${MY_EXCLUDE_FROM_ALL} PARENT_SCOPE)
-  SET(${PREFIX}_COMPONENT ${MY_COMPONENT} PARENT_SCOPE)
-ENDFUNCTION()
+  if (NOT ${MY_EXCLUDE_FROM_ALL})
+    list(LENGTH MY_COMPONENT COMPONENTS)
+    if (COMPONENTS EQUAL 0)
+      message(STATUS "No COMPONENT for installation specified! Using default COMPONENT name \"${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}\"")
+      set(MY_COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
+    else()
+      list(GET MY_COMPONENT -1 MY_COMPONENT)
+    endif()
+  endif()
+
+  set(${PREFIX}_SOURCES ${MY_SOURCES} PARENT_SCOPE)
+  set(${PREFIX}_LIBS ${LIBS} PARENT_SCOPE)
+  set(${PREFIX}_EXCLUDE_FROM_ALL ${MY_EXCLUDE_FROM_ALL} PARENT_SCOPE)
+  set(${PREFIX}_COMPONENT ${MY_COMPONENT} PARENT_SCOPE)
+endfunction()

 ## Conveniance macro for creating OSPRay libraries ##
 # Usage
 #
-#   OSPRAY_CREATE_LIBRARY(<name> source1 [source2 ...]
+#   ospray_create_library(<name> source1 [source2 ...]
 #                         [LINK lib1 [lib2 ...]]
 #                         [EXCLUDE_FROM_ALL]
 #                         [COMPONENT component])
@@ -270,23 +268,23 @@
 # OSPRAY_DEFAULT_COMPONENT which can be overridden individually with
 # COMPONENT.

-MACRO(OSPRAY_CREATE_LIBRARY LIBRARY_NAME)
-  OSPRAY_SPLIT_CREATE_ARGS(LIBRARY ${ARGN})
-
-  OSPRAY_ADD_LIBRARY(${LIBRARY_NAME} SHARED ${LIBRARY_SOURCES})
-  TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${LIBRARY_LIBS})
-  OSPRAY_SET_LIBRARY_VERSION(${LIBRARY_NAME})
-  IF(${LIBRARY_EXCLUDE_FROM_ALL})
-    SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE)
-  ELSE()
-    OSPRAY_INSTALL_LIBRARY(${LIBRARY_NAME} ${LIBRARY_COMPONENT})
-  ENDIF()
-ENDMACRO()
+macro(ospray_create_library LIBRARY_NAME)
+  ospray_split_create_args(LIBRARY ${ARGN})
+
+  ospray_add_library(${LIBRARY_NAME} SHARED ${LIBRARY_SOURCES})
+  target_link_libraries(${LIBRARY_NAME} ${LIBRARY_LIBS})
+  ospray_set_library_version(${LIBRARY_NAME})
+  if(${LIBRARY_EXCLUDE_FROM_ALL})
+    set_target_properties(${LIBRARY_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE)
+  else()
+    ospray_install_library(${LIBRARY_NAME} ${LIBRARY_COMPONENT})
+  endif()
+endmacro()

 ## Conveniance macro for creating OSPRay applications ##
 # Usage
 #
-#   OSPRAY_CREATE_APPLICATION(<name> source1 [source2 ...]
+#   ospray_create_application(<name> source1 [source2 ...]
 #                             [LINK lib1 [lib2 ...]]
 #                             [EXCLUDE_FROM_ALL]
 #                             [COMPONENT component])
@@ -299,247 +297,247 @@
 # OSPRAY_DEFAULT_COMPONENT which can be overridden individually with
 # COMPONENT.

-MACRO(OSPRAY_CREATE_APPLICATION APP_NAME)
-  OSPRAY_SPLIT_CREATE_ARGS(APP ${ARGN})
-
-  ADD_EXECUTABLE(${APP_NAME} ${APP_SOURCES})
-  TARGET_LINK_LIBRARIES(${APP_NAME} ${APP_LIBS})
-  IF (WIN32)
-    SET_TARGET_PROPERTIES(${APP_NAME} PROPERTIES VERSION ${OSPRAY_VERSION})
-  ENDIF()
-  IF(${APP_EXCLUDE_FROM_ALL})
-    SET_TARGET_PROPERTIES(${APP_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE)
-  ELSE()
-    INSTALL(TARGETS ${APP_NAME}
+macro(ospray_create_application APP_NAME)
+  ospray_split_create_args(APP ${ARGN})
+
+  add_executable(${APP_NAME} ${APP_SOURCES})
+  target_link_libraries(${APP_NAME} ${APP_LIBS})
+  if (WIN32)
+    set_target_properties(${APP_NAME} PROPERTIES VERSION ${OSPRAY_VERSION})
+  endif()
+  if(${APP_EXCLUDE_FROM_ALL})
+    set_target_properties(${APP_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE)
+  else()
+    install(TARGETS ${APP_NAME}
       DESTINATION ${CMAKE_INSTALL_BINDIR}
       COMPONENT ${APP_COMPONENT}
     )
-  ENDIF()
-ENDMACRO()
+  endif()
+endmacro()

 ## Conveniance macro for creating OSPRay test applications ##
-# Usage - same as OSPRAY_CREATE_APPLICATION
+# Usage - same as ospray_create_application
 #
 # Will build the app if 'OSPRAY_ENABLE_TESTING=ON' in CMake

-MACRO(OSPRAY_CREATE_TEST)
-  IF (OSPRAY_ENABLE_TESTING)
-    OSPRAY_CREATE_APPLICATION(
+macro(ospray_create_test)
+  if (OSPRAY_ENABLE_TESTING)
+    ospray_create_application(
       ${ARGN}
       COMPONENT test
     )
-  ENDIF()
-ENDMACRO()
+  endif()
+endmacro()

 ## Conveniance macro for installing OSPRay headers ##
 # Usage
 #
-#   OSPRAY_INSTALL_SDK_HEADERS(header1 [header2 ...] [DESTINATION destination])
+#   ospray_install_sdk_headers(header1 [header2 ...] [DESTINATION destination])
 #
 # will install headers into ${CMAKE_INSTALL_PREFIX}/ospray/SDK/${destination},
 # where destination is optional.

-MACRO(OSPRAY_INSTALL_SDK_HEADERS)
-  SET(HEADERS "")
-  SET(MY_DESTINATION "")
-
-  SET(CURRENT_LIST HEADERS)
-  FOREACH(arg ${ARGN})
-    IF ("${arg}" STREQUAL "DESTINATION")
-      SET(CURRENT_LIST MY_DESTINATION)
-    ELSE()
-      LIST(APPEND ${CURRENT_LIST} ${arg})
-    ENDIF ()
-  ENDFOREACH()
-
-  INSTALL(FILES ${HEADERS}
+macro(ospray_install_sdk_headers)
+  set(HEADERS "")
+  set(MY_DESTINATION "")
+
+  set(CURRENT_LIST HEADERS)
+  foreach(arg ${ARGN})
+    if ("${arg}" STREQUAL "DESTINATION")
+      set(CURRENT_LIST MY_DESTINATION)
+    else()
+      list(APPEND ${CURRENT_LIST} ${arg})
+    endif ()
+  endforeach()
+
+  install(FILES ${HEADERS}
     DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ospray/SDK/${MY_DESTINATION}
     COMPONENT devel
   )
-ENDMACRO()
+endmacro()

 ## Compiler configuration macros ##

-MACRO(OSPRAY_CONFIGURE_COMPILER)
+macro(ospray_configure_compiler)
   # unhide compiler to make it easier for users to see what they are using
-  MARK_AS_ADVANCED(CLEAR CMAKE_CXX_COMPILER)
-
-  OPTION(OSPRAY_STRICT_BUILD "Build with additional warning flags" ON)
-  MARK_AS_ADVANCED(OSPRAY_STRICT_BUILD)
-
-  OPTION(OSPRAY_WARN_AS_ERRORS "Treat warnings as errors" OFF)
-  MARK_AS_ADVANCED(OSPRAY_WARN_AS_ERRORS)
-
-  SET(OSPRAY_COMPILER_ICC   FALSE)
-  SET(OSPRAY_COMPILER_GCC   FALSE)
-  SET(OSPRAY_COMPILER_CLANG FALSE)
-  SET(OSPRAY_COMPILER_MSVC  FALSE)
-
-  IF (${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
-    SET(OSPRAY_COMPILER_ICC TRUE)
-    IF(WIN32) # icc on Windows behaves like msvc
-      INCLUDE(msvc)
-    ELSE()
-      INCLUDE(icc)
-    ENDIF()
-  ELSEIF (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
-    SET(OSPRAY_COMPILER_GCC TRUE)
-    INCLUDE(gcc)
-  ELSEIF (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
-    SET(OSPRAY_COMPILER_CLANG TRUE)
-    INCLUDE(clang)
-  ELSEIF (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
-    SET(OSPRAY_COMPILER_MSVC TRUE)
-    INCLUDE(msvc)
-  ELSE()
-    MESSAGE(FATAL_ERROR
+  mark_as_advanced(CLEAR CMAKE_CXX_COMPILER)
+
+  option(OSPRAY_STRICT_BUILD "Build with additional warning flags" ON)
+  mark_as_advanced(OSPRAY_STRICT_BUILD)
+
+  option(OSPRAY_WARN_AS_ERRORS "Treat warnings as errors" OFF)
+  mark_as_advanced(OSPRAY_WARN_AS_ERRORS)
+
+  set(OSPRAY_COMPILER_ICC   FALSE)
+  set(OSPRAY_COMPILER_GCC   FALSE)
+  set(OSPRAY_COMPILER_CLANG FALSE)
+  set(OSPRAY_COMPILER_MSVC  FALSE)
+
+  if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
+    set(OSPRAY_COMPILER_ICC TRUE)
+    if(WIN32) # icc on Windows behaves like msvc
+      include(msvc)
+    else()
+      include(icc)
+    endif()
+  elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
+    set(OSPRAY_COMPILER_GCC TRUE)
+    include(gcc)
+  elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
+    set(OSPRAY_COMPILER_CLANG TRUE)
+    include(clang)
+  elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
+    set(OSPRAY_COMPILER_MSVC TRUE)
+    include(msvc)
+  else()
+    message(FATAL_ERROR
             "Unsupported compiler specified: '${CMAKE_CXX_COMPILER_ID}'")
-  ENDIF()
-
-  IF (WIN32)
+  endif()
+
+  if (WIN32)
     # increase stack to 8MB (the default size of 1MB is too small for our apps)
     # note: linker options are independent of compiler (icc or MSVC)
-    SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:8388608")
-  ENDIF()
-ENDMACRO()
-
-MACRO(OSPRAY_DISABLE_COMPILER_WARNINGS)
-  IF (NOT OSPRAY_COMPILER_MSVC)
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
-  #ELSEIF (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
-  ENDIF()
-ENDMACRO()
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:8388608")
+  endif()
+endmacro()
+
+macro(ospray_disable_compiler_warnings)
+  if (NOT OSPRAY_COMPILER_MSVC)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
+  #elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
+  endif()
+endmacro()

 ## Tasking system configuration macro ##

-MACRO(OSPRAY_CONFIGURE_TASKING_SYSTEM)
+macro(ospray_configure_tasking_system)
   # -------------------------------------------------------
   # Setup tasking system build configuration
   # -------------------------------------------------------

   # NOTE(jda) - Notice that this implies that OSPRAY_CONFIGURE_COMPILER() has
   #             been called before this macro!
-  IF(OSPRAY_COMPILER_ICC)
-    SET(CILK_STRING "Cilk")
-  ENDIF()
-
-  SET(OSPRAY_TASKING_SYSTEM TBB CACHE STRING
+  if(OSPRAY_COMPILER_ICC)
+    set(CILK_STRING "Cilk")
+  endif()
+
+  set(OSPRAY_TASKING_SYSTEM TBB CACHE STRING
       "Per-node thread tasking system [TBB,OpenMP,Cilk,LibDispatch,Internal,Debug]")

-  SET_PROPERTY(CACHE OSPRAY_TASKING_SYSTEM PROPERTY
+  set_property(CACHE OSPRAY_TASKING_SYSTEM PROPERTY
                STRINGS TBB ${CILK_STRING} OpenMP Internal LibDispatch Debug)
-  MARK_AS_ADVANCED(OSPRAY_TASKING_SYSTEM)
+  mark_as_advanced(OSPRAY_TASKING_SYSTEM)

   # NOTE(jda) - Make the OSPRAY_TASKING_SYSTEM build option case-insensitive
-  STRING(TOUPPER ${OSPRAY_TASKING_SYSTEM} OSPRAY_TASKING_SYSTEM_ID)
-
-  SET(OSPRAY_TASKING_TBB         FALSE)
-  SET(OSPRAY_TASKING_CILK        FALSE)
-  SET(OSPRAY_TASKING_OPENMP      FALSE)
-  SET(OSPRAY_TASKING_INTERNAL    FALSE)
-  SET(OSPRAY_TASKING_LIBDISPATCH FALSE)
-  SET(OSPRAY_TASKING_DEBUG       FALSE)
-
-  IF(${OSPRAY_TASKING_SYSTEM_ID} STREQUAL "TBB")
-    SET(OSPRAY_TASKING_TBB TRUE)
-  ELSEIF(${OSPRAY_TASKING_SYSTEM_ID} STREQUAL "CILK")
-    SET(OSPRAY_TASKING_CILK TRUE)
-  ELSEIF(${OSPRAY_TASKING_SYSTEM_ID} STREQUAL "OPENMP")
-    SET(OSPRAY_TASKING_OPENMP TRUE)
-  ELSEIF(${OSPRAY_TASKING_SYSTEM_ID} STREQUAL "INTERNAL")
-    SET(OSPRAY_TASKING_INTERNAL TRUE)
-  ELSEIF(${OSPRAY_TASKING_SYSTEM_ID} STREQUAL "LIBDISPATCH")
-    SET(OSPRAY_TASKING_LIBDISPATCH TRUE)
-  ELSE()
-    SET(OSPRAY_TASKING_DEBUG TRUE)
-  ENDIF()
-
-  UNSET(TASKING_SYSTEM_LIBS)
-
-  IF(OSPRAY_TASKING_TBB)
-    FIND_PACKAGE(TBB REQUIRED)
-    ADD_DEFINITIONS(-DOSPRAY_TASKING_TBB)
-    INCLUDE_DIRECTORIES(${TBB_INCLUDE_DIRS})
-    SET(TASKING_SYSTEM_LIBS ${TBB_LIBRARIES})
-  ELSE(OSPRAY_TASKING_TBB)
-    UNSET(TBB_INCLUDE_DIR          CACHE)
-    UNSET(TBB_LIBRARY              CACHE)
-    UNSET(TBB_LIBRARY_DEBUG        CACHE)
-    UNSET(TBB_LIBRARY_MALLOC       CACHE)
-    UNSET(TBB_LIBRARY_MALLOC_DEBUG CACHE)
-    IF(OSPRAY_TASKING_OPENMP)
-      FIND_PACKAGE(OpenMP)
-      IF (OPENMP_FOUND)
-        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
-        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
-        IF(OSPRAY_COMPILER_ICC) # workaround linker issue #115
-          SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -liomp5")
-        ENDIF()
-        ADD_DEFINITIONS(-DOSPRAY_TASKING_OMP)
-      ENDIF()
-    ELSEIF(OSPRAY_TASKING_CILK)
-      ADD_DEFINITIONS(-DOSPRAY_TASKING_CILK)
-      IF (OSPRAY_COMPILER_GCC OR OSPRAY_COMPILER_CLANG)
-        OSPRAY_WARN_ONCE(UNSAFE_USE_OF_CILK
+  string(TOUPPER ${OSPRAY_TASKING_SYSTEM} OSPRAY_TASKING_SYSTEM_ID)
+
+  set(OSPRAY_TASKING_TBB         FALSE)
+  set(OSPRAY_TASKING_CILK        FALSE)
+  set(OSPRAY_TASKING_OPENMP      FALSE)
+  set(OSPRAY_TASKING_INTERNAL    FALSE)
+  set(OSPRAY_TASKING_LIBDISPATCH FALSE)
+  set(OSPRAY_TASKING_DEBUG       FALSE)
+
+  if(${OSPRAY_TASKING_SYSTEM_ID} STREQUAL "TBB")
+    set(OSPRAY_TASKING_TBB TRUE)
+  elseif(${OSPRAY_TASKING_SYSTEM_ID} STREQUAL "CILK")
+    set(OSPRAY_TASKING_CILK TRUE)
+  elseif(${OSPRAY_TASKING_SYSTEM_ID} STREQUAL "OPENMP")
+    set(OSPRAY_TASKING_OPENMP TRUE)
+  elseif(${OSPRAY_TASKING_SYSTEM_ID} STREQUAL "INTERNAL")
+    set(OSPRAY_TASKING_INTERNAL TRUE)
+  elseif(${OSPRAY_TASKING_SYSTEM_ID} STREQUAL "LIBDISPATCH")
+    set(OSPRAY_TASKING_LIBDISPATCH TRUE)
+  else()
+    set(OSPRAY_TASKING_DEBUG TRUE)
+  endif()
+
+  unset(TASKING_SYSTEM_LIBS)
+
+  if(OSPRAY_TASKING_TBB)
+    find_package(TBB REQUIRED)
+    add_definitions(-DOSPRAY_TASKING_TBB)
+    include_directories(${TBB_INCLUDE_DIRS})
+    set(TASKING_SYSTEM_LIBS ${TBB_LIBRARIES})
+  else(OSPRAY_TASKING_TBB)
+    unset(TBB_INCLUDE_DIR          CACHE)
+    unset(TBB_LIBRARY              CACHE)
+    unset(TBB_LIBRARY_DEBUG        CACHE)
+    unset(TBB_LIBRARY_MALLOC       CACHE)
+    unset(TBB_LIBRARY_MALLOC_DEBUG CACHE)
+    if(OSPRAY_TASKING_OPENMP)
+      find_package(OpenMP)
+      if (OPENMP_FOUND)
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+        if(OSPRAY_COMPILER_ICC) # workaround linker issue #115
+          set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -liomp5")
+        endif()
+        add_definitions(-DOSPRAY_TASKING_OMP)
+      endif()
+    elseif(OSPRAY_TASKING_CILK)
+      add_definitions(-DOSPRAY_TASKING_CILK)
+      if (OSPRAY_COMPILER_GCC OR OSPRAY_COMPILER_CLANG)
+        ospray_warn_once(UNSAFE_USE_OF_CILK
             "You are using Cilk with GCC or Clang...use at your own risk!")
-        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcilkplus")
-        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcilkplus")
-      ENDIF()
-    ELSEIF(OSPRAY_TASKING_INTERNAL)
-      ADD_DEFINITIONS(-DOSPRAY_TASKING_INTERNAL)
-    ELSEIF(OSPRAY_TASKING_LIBDISPATCH)
-      FIND_PACKAGE(libdispatch REQUIRED)
-      INCLUDE_DIRECTORIES(${LIBDISPATCH_INCLUDE_DIRS})
-      SET(TASKING_SYSTEM_LIBS ${LIBDISPATCH_LIBRARIES})
-      ADD_DEFINITIONS(-DOSPRAY_TASKING_LIBDISPATCH)
-    ELSE()#Debug
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcilkplus")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcilkplus")
+      endif()
+    elseif(OSPRAY_TASKING_INTERNAL)
+      add_definitions(-DOSPRAY_TASKING_INTERNAL)
+    elseif(OSPRAY_TASKING_LIBDISPATCH)
+      find_package(libdispatch REQUIRED)
+      include_directories(${LIBDISPATCH_INCLUDE_DIRS})
+      set(TASKING_SYSTEM_LIBS ${LIBDISPATCH_LIBRARIES})
+      add_definitions(-DOSPRAY_TASKING_LIBDISPATCH)
+    else()#Debug
       # Do nothing, will fall back to scalar code (useful for debugging)
-    ENDIF()
-  ENDIF(OSPRAY_TASKING_TBB)
-ENDMACRO()
+    endif()
+  endif(OSPRAY_TASKING_TBB)
+endmacro()

 ## MPI configuration macro ##

-MACRO(OSPRAY_CONFIGURE_MPI)
-  IF (WIN32) # FindMPI does not find Intel MPI on Windows, we need to help here
-    FIND_PACKAGE(MPI)
+macro(OSPRAY_CONFIGURE_MPI)
+  if (WIN32) # FindMPI does not find Intel MPI on Windows, we need to help here
+    find_package(MPI)

     # need to strip quotes, otherwise CMake treats it as relative path
-    STRING(REGEX REPLACE "^\"|\"$" "" MPI_CXX_INCLUDE_PATH ${MPI_CXX_INCLUDE_PATH})
-
-    IF (NOT MPI_CXX_FOUND)
+    string(REGEX REPLACE "^\"|\"$" "" MPI_CXX_INCLUDE_PATH ${MPI_CXX_INCLUDE_PATH})
+
+    if (NOT MPI_CXX_FOUND)
       # try again, hinting the compiler wrappers
-      SET(MPI_CXX_COMPILER mpicxx.bat)
-      SET(MPI_C_COMPILER mpicc.bat)
-      FIND_PACKAGE(MPI)
-
-      IF (NOT MPI_CXX_LIBRARIES)
-        SET(MPI_LIB_PATH ${MPI_CXX_INCLUDE_PATH}\\..\\lib)
-
-        SET(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
-        FIND_LIBRARY(MPI_LIB NAMES impi HINTS ${MPI_LIB_PATH})
-        SET(MPI_C_LIB ${MPI_LIB})
-        SET(MPI_C_LIBRARIES ${MPI_LIB} CACHE STRING "MPI C libraries to link against" FORCE)
-
-        SET(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
-        FIND_LIBRARY(MPI_LIB NAMES impicxx HINTS ${MPI_LIB_PATH})
-        SET(MPI_CXX_LIBRARIES ${MPI_C_LIB} ${MPI_LIB} CACHE STRING "MPI CXX libraries to link against" FORCE)
-        SET(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI lib detection" FORCE)
-      ENDIF()
-    ENDIF()
-  ELSE()
-    FIND_PACKAGE(MPI REQUIRED)
-  ENDIF()
-
-  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_CXX_COMPILE_FLAGS}")
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS}")
-
-  INCLUDE_DIRECTORIES(SYSTEM ${MPI_CXX_INCLUDE_PATH})
-ENDMACRO()
-
-# Keep backwards compatible CONFIGURE_MPI() macro, but warn of deprecation
-MACRO(CONFIGURE_MPI)
-  OSPRAY_WARN_ONCE(CONFIGURE_MPI_DEPRECATION
-                   "CONFIGURE_MPI() is deprecated, use new OSPRAY_CONFIGURE_MPI().")
-  OSPRAY_CONFIGURE_MPI()
-ENDMACRO()
+      set(MPI_CXX_COMPILER mpicxx.bat)
+      set(MPI_C_COMPILER mpicc.bat)
+      find_package(MPI)
+
+      if (NOT MPI_CXX_LIBRARIES)
+        set(MPI_LIB_PATH ${MPI_CXX_INCLUDE_PATH}\\..\\lib)
+
+        set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
+        find_library(MPI_LIB NAMES impi HINTS ${MPI_LIB_PATH})
+        set(MPI_C_LIB ${MPI_LIB})
+        set(MPI_C_LIBRARIES ${MPI_LIB} CACHE STRING "MPI C libraries to link against" FORCE)
+
+        set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
+        find_library(MPI_LIB NAMES impicxx HINTS ${MPI_LIB_PATH})
+        set(MPI_CXX_LIBRARIES ${MPI_C_LIB} ${MPI_LIB} CACHE STRING "MPI CXX libraries to link against" FORCE)
+        set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI lib detection" FORCE)
+      endif()
+    endif()
+  else()
+    find_package(MPI REQUIRED)
+  endif()
+
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_CXX_COMPILE_FLAGS}")
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS}")
+
+  include_directories(SYSTEM ${MPI_CXX_INCLUDE_PATH})
+endmacro()
+
+# Keep backwards compatible configure_mpi() macro, but warn of deprecation
+macro(configure_mpi)
+  ospray_warn_once(CONFIGURE_MPI_DEPRECATION
+                   "configure_mpi() is deprecated, use new ospray_configure_mpi().")
+  ospray_configure_mpi()
+endmacro()


Port system features introspection to CXX

git-svn-id: fbbf69ba8011aca0e74e1c67904b11cccbdbe66b@28585 0785d39b-7218-0410-832d-ea1e28bc413d

--- deal.II/cmake/checks/check_01_system_features.cmake
+++ deal.II/cmake/checks/check_01_system_features.cmake
@@ -15,16 +15,16 @@
 #
 # This file sets up:
 #
+#   HAVE_GETHOSTNAME
+#   HAVE_GETPID
+#   HAVE_JN
+#   HAVE_RAND_R
 #   HAVE_SYS_RESOURCE_H
 #   HAVE_SYS_TIME_H
 #   HAVE_SYS_TIMES_H
 #   HAVE_SYS_TYPES_H
+#   HAVE_TIMES
 #   HAVE_UNISTD_H
-#   HAVE_GETHOSTNAME
-#   HAVE_GETPID
-#   HAVE_RAND_R
-#   HAVE_TIMES
-#   HAVE_JN
 #   DEAL_II_MSVC
 #

@@ -35,24 +35,23 @@
 #                                                                         #
 ###########################################################################

-CHECK_INCLUDE_FILE_CXX("sys/resource.h"  HAVE_SYS_RESOURCE_H)
+#
+# Check for various posix (and linux) specific header files and symbols
+#
+CHECK_INCLUDE_FILE_CXX("sys/resource.h" HAVE_SYS_RESOURCE_H)
+
 CHECK_INCLUDE_FILE_CXX("sys/time.h" HAVE_SYS_TIME_H)
+
 CHECK_INCLUDE_FILE_CXX("sys/times.h" HAVE_SYS_TIMES_H)
+CHECK_CXX_SYMBOL_EXISTS("times" "sys/times.h" HAVE_TIMES)
+
 CHECK_INCLUDE_FILE_CXX("sys/types.h" HAVE_SYS_TYPES_H)

+CHECK_INCLUDE_FILE_CXX("unistd.h" HAVE_UNISTD_H)
+CHECK_CXX_SYMBOL_EXISTS("gethostname" "unistd.h" HAVE_GETHOSTNAME)
+CHECK_CXX_SYMBOL_EXISTS("getpid" "unistd.h" HAVE_GETPID)

-#
-# Check for various posix specific functions. On a posix system they should
-# be all defined in unistd.h. On other platforms, most notably
-# Windows/MinGW unistd.h is available but not all posix functions. So test
-# for each funtion as well.
-#
-CHECK_INCLUDE_FILE_CXX("unistd.h" HAVE_UNISTD_H)
-CHECK_FUNCTION_EXISTS(gethostname HAVE_GETHOSTNAME)
-CHECK_FUNCTION_EXISTS(getpid HAVE_GETPID)
-CHECK_FUNCTION_EXISTS(rand_r HAVE_RAND_R)
-CHECK_FUNCTION_EXISTS(times HAVE_TIMES)
-
+CHECK_CXX_SYMBOL_EXISTS("rand_r" "stdlib.h" HAVE_RAND_R)

 #
 # Do we have the Bessel function jn?
@@ -62,7 +61,7 @@

 IF(NOT m_lib MATCHES "-NOTFOUND")
   SET(CMAKE_REQUIRED_LIBRARIES ${m_lib})
-  CHECK_FUNCTION_EXISTS(jn HAVE_JN)
+  CHECK_CXX_SYMBOL_EXISTS("jn" "math.h" HAVE_JN)
   SET(CMAKE_REQUIRED_LIBRARIES)
   IF(HAVE_JN)
     LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${m_lib})


add ADDITIONAL_MAKE_CLEAN_FILES to setup_test_case.macro.cmake

--- utilities/cmake/setup_test_case.macro.cmake
+++ utilities/cmake/setup_test_case.macro.cmake
@@ -83,4 +83,10 @@
     PROPERTIES TIMEOUT ${_time_out_time}
     )

+  # Code for cleaning
+  SET_DIRECTORY_PROPERTIES(
+    PROPERTIES
+    ADDITIONAL_MAKE_CLEAN_FILES "${_additional_clean_up_files}"
+    )
+
 ENDMACRO()


extension building test

extension building test