From c22e373a3077a90a4f1ed509774412a0ab82d992 Mon Sep 17 00:00:00 2001
From: KWSys Upstream <kwrobot@kitware.com>
Date: Wed, 30 Jan 2019 10:35:38 -0500
Subject: KWSys 2019-01-30 (ce89cada)

Code extracted from:

    https://gitlab.kitware.com/utils/kwsys.git

at commit ce89cada1c48be31e6294a984b15c2c75b66eab0 (master).

Upstream Shortlog
-----------------

Brad King (2):
      5d92e8d9 Require CMake 3.1 or higher for KWSys
      6db3c607 Require C++11 or higher to compile KWSys
---
 CMakeLists.txt           | 25 +++++++++++++++----------
 kwsysPlatformTests.cmake |  5 +++++
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b33aa80..e7da994 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,6 +42,10 @@
 #      SET(KWSYS_HEADER_ROOT ${PROJECT_BINARY_DIR})
 #      INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
 #
+#  KWSYS_CXX_STANDARD         = A value for CMAKE_CXX_STANDARD within KWSys.
+#                               Set to empty string to use no default value.
+#  KWSYS_CXX_COMPILE_FEATURES = target_compile_features arguments for KWSys.
+#
 # Optional settings to setup install rules are as follows:
 #
 #  KWSYS_INSTALL_BIN_DIR     = The installation target directories into
@@ -82,25 +86,17 @@
 # any outside mailing list and no documentation of the change will be
 # written.
 
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR)
 FOREACH(p
-    CMP0022 # CMake 2.8, Define link interface - required by android_mk export
-    CMP0025 # CMake 3.0, Compiler id for Apple Clang is now AppleClang.
-    CMP0042 # CMake 3.0, MACOSX_RPATH is enabled by default.
-    CMP0048 # CMake 3.0, Let the project command manage version variables.
     CMP0056 # CMake 3.2, Honor link flags in try_compile() source-file signature.
     CMP0063 # CMake 3.3, Honor visibility properties for all target types.
+    CMP0067 # CMake 3.8, Honor language standard in try_compile source-file signature.
     CMP0069 # CMake 3.9, INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.
     )
   IF(POLICY ${p})
     CMAKE_POLICY(SET ${p} NEW)
   ENDIF()
 ENDFOREACH()
-SET(CMAKE_LEGACY_CYGWIN_WIN32 0)
-
-IF(CMAKE_VERSION VERSION_LESS 3.0)
-  SET(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE 0)
-ENDIF()
 
 #-----------------------------------------------------------------------------
 # If a namespace is not specified, use "kwsys" and enable testing.
@@ -121,6 +117,12 @@ SET_PROPERTY(DIRECTORY
   "KWSYS_HEADER(%)=<${KWSYS_NAMESPACE}/%>"
   )
 
+if(KWSYS_CXX_STANDARD)
+  set(CMAKE_CXX_STANDARD "${KWSYS_CXX_STANDARD}")
+elseif(NOT DEFINED CMAKE_CXX_STANDARD AND NOT DEFINED KWSYS_CXX_STANDARD)
+  set(CMAKE_CXX_STANDARD 11)
+endif()
+
 # Select library components.
 IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
   SET(KWSYS_ENABLE_C 1)
@@ -884,6 +886,8 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
       ${KWSYS_TARGET_INTERFACE})
     TARGET_SOURCES(${KWSYS_TARGET_LINK} INTERFACE
       $<TARGET_OBJECTS:${KWSYS_TARGET_OBJECT}>)
+    target_compile_features(${KWSYS_TARGET_OBJECT} PRIVATE ${KWSYS_CXX_COMPILE_FEATURES})
+    target_compile_features(${KWSYS_TARGET_INTERFACE} INTERFACE ${KWSYS_CXX_COMPILE_FEATURES})
   ELSE()
     SET(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE})
     SET(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE})
@@ -892,6 +896,7 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
     SET(KWSYS_LINK_DEPENDENCY PUBLIC)
     ADD_LIBRARY(${KWSYS_TARGET_INTERFACE} ${KWSYS_LIBRARY_TYPE}
       ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
+    target_compile_features(${KWSYS_TARGET_INTERFACE} PUBLIC ${KWSYS_CXX_COMPILE_FEATURES})
   ENDIF()
   if (KWSYS_ALIAS_TARGET)
     add_library(${KWSYS_ALIAS_TARGET} ALIAS ${KWSYS_TARGET_INTERFACE})
diff --git a/kwsysPlatformTests.cmake b/kwsysPlatformTests.cmake
index 5386a49..28d3f68 100644
--- a/kwsysPlatformTests.cmake
+++ b/kwsysPlatformTests.cmake
@@ -7,11 +7,16 @@ SET(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
 MACRO(KWSYS_PLATFORM_TEST lang var description invert)
   IF(NOT DEFINED ${var}_COMPILED)
     MESSAGE(STATUS "${description}")
+    set(maybe_cxx_standard "")
+    if(CMAKE_VERSION VERSION_LESS 3.8 AND CMAKE_CXX_STANDARD)
+      set(maybe_cxx_standard "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
+    endif()
     TRY_COMPILE(${var}_COMPILED
       ${CMAKE_CURRENT_BINARY_DIR}
       ${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
       COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
       CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=${KWSYS_PLATFORM_TEST_LINK_LIBRARIES}"
+                  ${maybe_cxx_standard}
       OUTPUT_VARIABLE OUTPUT)
     IF(${var}_COMPILED)
       FILE(APPEND
-- 
cgit v0.12