[Cmake-commits] CMake branch, master, updated. v3.13.0-rc2-256-g1d4b1a5

Kitware Robot kwrobot at kitware.com
Tue Oct 30 11:05:08 EDT 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  1d4b1a5853209be077d36af090ad7a32361a8923 (commit)
       via  87dfd53b276bff00e5e018b29043d05cf503018e (commit)
       via  157e3e1bd6465703ca75fcf8cf7ea2f5271a5c65 (commit)
       via  a298c188127d06876ce493f23f8b8c2fc9941895 (commit)
       via  59d57f023f61446ade0767376cf6b38bb7450e44 (commit)
       via  4c669a0a34569e5276b8dca47165657aad68cade (commit)
       via  263afbad64588eb896452cd85546a07321e9db92 (commit)
       via  b8f5eca5e2cff99ec0eeba645e3ccf5ac40d9825 (commit)
       via  b27cf72deac36b6872809d466f1a1ecdca7534bb (commit)
       via  8d782adbce56d3e81dd361b5ef6e9ff781a6d436 (commit)
       via  99728fe27c993d8482fb55a4780670767d5fab72 (commit)
       via  2fc43415efe5cc78fd39e0f600f7fa70dc18b760 (commit)
       via  e8cc8d22d844a3ffc261b3ca79bb0ce5dc8c6dd6 (commit)
       via  3f5bfb425af391c1740ff7794f0283be3d0f7589 (commit)
       via  3c31ec7a0a34b7fbbf2ceae9c6bc27f9b536c1b8 (commit)
       via  bb57cb80eb7d9ab779d19112f2da65c60bd37f39 (commit)
       via  50572d638b3903f2c2af636dcfe9d3765fd87a7c (commit)
       via  20fd16e756a590c0ff01fd32c162439aef429807 (commit)
       via  42731e94bea0839842fc66cef27af71e12d753e1 (commit)
       via  ee73e733e4ae7a1fe36c3010d8789de4d37dcc1c (commit)
       via  160499296c61b0edf2e6b08c44b31444e022528f (commit)
       via  ee7e97a7d35a793985cf6f9aa185069460cf0ec6 (commit)
       via  d7e19032d52f9d1529a27bb1061da33524b69060 (commit)
       via  518553d9537be7e6c245090e52ba989df5686e19 (commit)
      from  9330afea04d8e5c8f5c867af43a95fef0ad08d35 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1d4b1a5853209be077d36af090ad7a32361a8923
commit 1d4b1a5853209be077d36af090ad7a32361a8923
Merge: 87dfd53 e8cc8d2
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Oct 30 15:02:49 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Oct 30 11:03:03 2018 -0400

    Merge topic 'cuda_device_linking_drop_dynamic_libs'
    
    e8cc8d22d8 Merge branch 'backport-cuda-filter-device-link-libs'
    3f5bfb425a CUDA: Filter out non-static libraries during device linking
    3c31ec7a0a CUDA: Filter out non-static libraries during device linking
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Acked-by: Daniel Arndt <daniel.arndt at iwr.uni-heidelberg.de>
    Merge-request: !2536


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=87dfd53b276bff00e5e018b29043d05cf503018e
commit 87dfd53b276bff00e5e018b29043d05cf503018e
Merge: 157e3e1 50572d6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Oct 30 15:01:26 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Oct 30 11:01:36 2018 -0400

    Merge topic 'set_directory_properties-script-mode'
    
    50572d638b set_directory_properties: Restore in script mode
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2544


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=157e3e1bd6465703ca75fcf8cf7ea2f5271a5c65
commit 157e3e1bd6465703ca75fcf8cf7ea2f5271a5c65
Merge: a298c18 8d782ad
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Oct 30 15:00:10 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Oct 30 11:00:41 2018 -0400

    Merge topic 'flang-preprocess-source'
    
    8d782adbce Flang: Fix command-line used to preprocess sources
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2545


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a298c188127d06876ce493f23f8b8c2fc9941895
commit a298c188127d06876ce493f23f8b8c2fc9941895
Merge: 59d57f0 b27cf72
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Oct 30 14:59:54 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Oct 30 11:00:00 2018 -0400

    Merge topic 'FindBoost-stacktrace'
    
    b27cf72dea FindBoost: Add support for stacktrace components
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Reviewed-by: Roger Leigh <rleigh at codelibre.net>
    Merge-request: !2541


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=59d57f023f61446ade0767376cf6b38bb7450e44
commit 59d57f023f61446ade0767376cf6b38bb7450e44
Merge: 4c669a0 99728fe
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Oct 30 14:59:05 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Oct 30 10:59:12 2018 -0400

    Merge topic 'qccDepfile'
    
    99728fe27c QNX: Update qcc depfile flags to be compliant with ccache
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2540


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4c669a0a34569e5276b8dca47165657aad68cade
commit 4c669a0a34569e5276b8dca47165657aad68cade
Merge: 263afba 2fc4341
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Oct 30 14:56:54 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Oct 30 10:57:45 2018 -0400

    Merge topic 'UseSWIG-typos'
    
    2fc43415ef UseSWIG: Add target language and input file in command description
    20fd16e756 UseSWIG: Typo, add missing letter
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2542


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=263afbad64588eb896452cd85546a07321e9db92
commit 263afbad64588eb896452cd85546a07321e9db92
Merge: b8f5eca bb57cb8
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Oct 30 14:56:49 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Oct 30 10:56:55 2018 -0400

    Merge topic 'UseSWIG-multi-input'
    
    bb57cb80eb UseSWIG: multiple input files must be supported in version 2
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2539


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b8f5eca5e2cff99ec0eeba645e3ccf5ac40d9825
commit b8f5eca5e2cff99ec0eeba645e3ccf5ac40d9825
Merge: 9330afe 42731e9
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Oct 30 14:55:43 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Oct 30 10:55:52 2018 -0400

    Merge topic 'FindMatlab-2018a-API'
    
    42731e94be FindMatlab: Fix linker command under Windows.
    ee73e733e4 FindMatlab: Fix compilation error in one specific test configuration.
    160499296c FindMatlab: added unit tests for new functionality.
    ee7e97a7d3 FindMatlab: add change log item.
    d7e19032d5 FindMatlab: `matlab_add_mex` has new options `R2017b` and `R2018a`.
    518553d953 FindMatlab: Always find core libraries.
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2508


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b27cf72deac36b6872809d466f1a1ecdca7534bb
commit b27cf72deac36b6872809d466f1a1ecdca7534bb
Author:     Martin Quinson <martin.quinson at ens-rennes.fr>
AuthorDate: Mon Oct 29 10:26:59 2018 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 29 16:09:56 2018 -0400

    FindBoost: Add support for stacktrace components
    
    Define the headers associated to `boost_stacktrace_*`.
    
    Fixes: #17297

diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index cc66532..d54890a 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -929,6 +929,12 @@ function(_Boost_COMPONENT_HEADERS component _hdrs)
   set(_Boost_REGEX_HEADERS               "boost/regex.hpp")
   set(_Boost_SERIALIZATION_HEADERS       "boost/serialization/serialization.hpp")
   set(_Boost_SIGNALS_HEADERS             "boost/signals.hpp")
+  set(_Boost_STACKTRACE_ADDR2LINE_HEADERS "boost/stacktrace.hpp")
+  set(_Boost_STACKTRACE_BACKTRACE_HEADERS "boost/stacktrace.hpp")
+  set(_Boost_STACKTRACE_BASIC_HEADERS    "boost/stacktrace.hpp")
+  set(_Boost_STACKTRACE_NOOP_HEADERS     "boost/stacktrace.hpp")
+  set(_Boost_STACKTRACE_WINDBG_CACHED_HEADERS "boost/stacktrace.hpp")
+  set(_Boost_STACKTRACE_WINDBG_HEADERS   "boost/stacktrace.hpp")
   set(_Boost_SYSTEM_HEADERS              "boost/system/config.hpp")
   set(_Boost_TEST_EXEC_MONITOR_HEADERS   "boost/test/test_exec_monitor.hpp")
   set(_Boost_THREAD_HEADERS              "boost/thread.hpp")

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8d782adbce56d3e81dd361b5ef6e9ff781a6d436
commit 8d782adbce56d3e81dd361b5ef6e9ff781a6d436
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 29 14:21:15 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 29 14:23:58 2018 -0400

    Flang: Fix command-line used to preprocess sources
    
    Running flang with `-E` now ignores any `-o` option and always prints
    preprocessed output to stdout.  Use shell redirection to place it in a
    file instead.
    
    Fixes: #18497

diff --git a/Modules/Compiler/Flang-Fortran.cmake b/Modules/Compiler/Flang-Fortran.cmake
index a1051f4..d522739 100644
--- a/Modules/Compiler/Flang-Fortran.cmake
+++ b/Modules/Compiler/Flang-Fortran.cmake
@@ -2,7 +2,7 @@ include(Compiler/Clang)
 __compiler_clang(Fortran)
 
 set(CMAKE_Fortran_PREPROCESS_SOURCE
-    "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> -o <PREPROCESSED_SOURCE>")
+    "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
 
 set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form")
 set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form")

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=99728fe27c993d8482fb55a4780670767d5fab72
commit 99728fe27c993d8482fb55a4780670767d5fab72
Author:     Maikel van den Hurk <maikel.vandenhurk at tomtom.com>
AuthorDate: Sat Oct 27 22:27:33 2018 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 29 12:50:55 2018 -0400

    QNX: Update qcc depfile flags to be compliant with ccache
    
    Pass the flags to the preprocessor phase via `-Wp,`.  This is
    accepted both by qcc and ccache.

diff --git a/Modules/Compiler/QCC.cmake b/Modules/Compiler/QCC.cmake
index 9ba9900..9df8269 100644
--- a/Modules/Compiler/QCC.cmake
+++ b/Modules/Compiler/QCC.cmake
@@ -11,7 +11,7 @@ macro(__compiler_qcc lang)
   set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-V")
 
   set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,")
-  set(CMAKE_DEPFILE_FLAGS_${lang} "-Wc,-MD,<DEPFILE>,-MT,<OBJECT>,-MF,<DEPFILE>")
+  set(CMAKE_DEPFILE_FLAGS_${lang} "-Wp,-MD,<DEPFILE> -Wp,-MT,<OBJECT> -Wp,-MF,<DEPFILE>")
 
   set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,")
   set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2fc43415efe5cc78fd39e0f600f7fa70dc18b760
commit 2fc43415efe5cc78fd39e0f600f7fa70dc18b760
Author:     Sylvain Joubert <joubert.sy at gmail.com>
AuthorDate: Mon Oct 29 15:08:08 2018 +0100
Commit:     Sylvain Joubert <joubert.sy at gmail.com>
CommitDate: Mon Oct 29 17:09:48 2018 +0100

    UseSWIG: Add target language and input file in command description

diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index e73b007..56eca31 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -485,7 +485,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
     MAIN_DEPENDENCY "${swig_source_file_fullname}"
     DEPENDS ${swig_dependencies}
     IMPLICIT_DEPENDS CXX "${swig_source_file_fullname}"
-    COMMENT "Swig source"
+    COMMENT "Swig compile ${infile} for ${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}"
     COMMAND_EXPAND_LISTS)
   set_source_files_properties("${swig_generated_file_fullname}" ${swig_extra_generated_files}
     PROPERTIES GENERATED 1)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e8cc8d22d844a3ffc261b3ca79bb0ce5dc8c6dd6
commit e8cc8d22d844a3ffc261b3ca79bb0ce5dc8c6dd6
Merge: 3c31ec7 3f5bfb4
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 29 12:00:40 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 29 12:00:40 2018 -0400

    Merge branch 'backport-cuda-filter-device-link-libs'


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3f5bfb425af391c1740ff7794f0283be3d0f7589
commit 3f5bfb425af391c1740ff7794f0283be3d0f7589
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Fri Oct 26 17:12:14 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 29 11:59:54 2018 -0400

    CUDA: Filter out non-static libraries during device linking
    
    Since commit v3.12.0-rc1~278^2 (CUDA: Pass more link libraries to device
    linking, 2018-03-27) we consider every link library during device
    linking and use `-Xnvlink` to pass those that do not end in `.a`.
    However, nvlink breaks on versioned shared library names such as
    `.so.1`.  Work around this problem by not passing library paths that do
    not end in `.a` or `.lib`.  nvlink would not find device symbols in them
    anyway.
    
    Fixes: #18504

diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index 470f394..20bd537 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -68,15 +68,15 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
     }
 
     if (item.IsPath) {
-      // nvcc understands absolute paths to libraries ending in '.a' should
-      // be passed to nvlink.  Other extensions like '.so' or '.dylib' are
-      // rejected by the nvcc front-end even though nvlink knows to ignore
-      // them.  Bypass the front-end via '-Xnvlink'.
-      if (!cmHasLiteralSuffix(item.Value, ".a")) {
-        fout << "-Xnvlink ";
+      // nvcc understands absolute paths to libraries ending in '.a' or '.lib'.
+      // These should be passed to nvlink.  Other extensions need to be left
+      // out because nvlink may not understand or need them.  Even though it
+      // can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'.
+      if (cmHasLiteralSuffix(item.Value, ".a") ||
+          cmHasLiteralSuffix(item.Value, ".lib")) {
+        fout << this->ConvertToOutputFormat(
+          this->ConvertToLinkReference(item.Value));
       }
-      fout << this->ConvertToOutputFormat(
-        this->ConvertToLinkReference(item.Value));
     } else if (cmLinkItemValidForDevice(item.Value)) {
       fout << item.Value;
     }

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c31ec7a0a34b7fbbf2ceae9c6bc27f9b536c1b8
commit 3c31ec7a0a34b7fbbf2ceae9c6bc27f9b536c1b8
Author:     Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Fri Oct 26 17:12:14 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 29 11:57:29 2018 -0400

    CUDA: Filter out non-static libraries during device linking
    
    Since commit v3.12.0-rc1~278^2 (CUDA: Pass more link libraries to device
    linking, 2018-03-27) we consider every link library during device
    linking and use `-Xnvlink` to pass those that do not end in `.a`.
    However, nvlink breaks on versioned shared library names such as
    `.so.1`.  Work around this problem by not passing library paths that do
    not end in `.a` or `.lib`.  nvlink would not find device symbols in them
    anyway.
    
    Fixes: #18504

diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index 025c6e4..a93ec12 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -77,15 +77,15 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
 
     std::string out;
     if (item.IsPath) {
-      // nvcc understands absolute paths to libraries ending in '.a' should
-      // be passed to nvlink.  Other extensions like '.so' or '.dylib' are
-      // rejected by the nvcc front-end even though nvlink knows to ignore
-      // them.  Bypass the front-end via '-Xnvlink'.
-      if (!cmHasLiteralSuffix(item.Value, ".a")) {
-        out += "-Xnvlink ";
+      // nvcc understands absolute paths to libraries ending in '.a' or '.lib'.
+      // These should be passed to nvlink.  Other extensions need to be left
+      // out because nvlink may not understand or need them.  Even though it
+      // can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'.
+      if (cmHasLiteralSuffix(item.Value, ".a") ||
+          cmHasLiteralSuffix(item.Value, ".lib")) {
+        out += this->ConvertToOutputFormat(
+          this->ConvertToLinkReference(item.Value));
       }
-      out +=
-        this->ConvertToOutputFormat(this->ConvertToLinkReference(item.Value));
     } else if (cmLinkItemValidForDevice(item.Value)) {
       out += item.Value;
     }

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bb57cb80eb7d9ab779d19112f2da65c60bd37f39
commit bb57cb80eb7d9ab779d19112f2da65c60bd37f39
Author:     Marc Chevrier <marc.chevrier at gmail.com>
AuthorDate: Sat Oct 27 16:49:17 2018 +0200
Commit:     Marc Chevrier <marc.chevrier at gmail.com>
CommitDate: Mon Oct 29 16:39:03 2018 +0100

    UseSWIG: multiple input files must be supported in version 2
    
    Fixes: #18506

diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index f20a53b..31395d9 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -234,6 +234,8 @@ set(SWIG_PYTHON_EXTRA_FILE_EXTENSIONS ".py")
 set(SWIG_JAVA_EXTRA_FILE_EXTENSIONS ".java" "JNI.java")
 set(SWIG_CSHARP_EXTRA_FILE_EXTENSIONS ".cs" "PINVOKE.cs")
 
+set(SWIG_MANAGE_SUPPORT_FILES_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/UseSWIG/ManageSupportFiles.cmake")
+
 ##
 ## PRIVATE functions
 ##
@@ -444,9 +446,13 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
   if (UseSWIG_MODULE_VERSION VERSION_GREATER 1)
     # as part of custom command, start by removing old generated files
     # to ensure obsolete files do not stay
-    set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" -E remove_directory "${outdir}")
+    set (swig_file_outdir "${workingdir}/${swig_source_file_name_we}.files")
+    set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_WORKING_DIRECTORY=${swig_file_outdir}" "-DSUPPORT_FILES_OUTPUT_DIRECTORY=${outdir}" -DACTION=CLEAN -P "${SWIG_MANAGE_SUPPORT_FILES_SCRIPT}")
+    set (swig_copy_command COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_WORKING_DIRECTORY=${swig_file_outdir}" "-DSUPPORT_FILES_OUTPUT_DIRECTORY=${outdir}" -DACTION=COPY -P "${SWIG_MANAGE_SUPPORT_FILES_SCRIPT}")
   else()
+    set (swig_file_outdir "${outdir}")
     unset (swig_cleanup_command)
+    unset (swig_copy_command)
   endif()
 
   # IMPLICIT_DEPENDS below can not handle situations where a dependent file is
@@ -476,12 +482,13 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
     COMMAND "${CMAKE_COMMAND}" -E env "SWIG_LIB=${SWIG_DIR}" "${SWIG_EXECUTABLE}"
     "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}"
     "${swig_source_file_flags}"
-    -outdir "${outdir}"
+    -outdir "${swig_file_outdir}"
     ${swig_special_flags}
     ${swig_extra_flags}
     "${swig_include_dirs}"
     -o "${swig_generated_file_fullname}"
     "${swig_source_file_fullname}"
+    ${swig_copy_command}
     MAIN_DEPENDENCY "${swig_source_file_fullname}"
     DEPENDS ${swig_dependencies}
     IMPLICIT_DEPENDS CXX "${swig_source_file_fullname}"
diff --git a/Modules/UseSWIG/ManageSupportFiles.cmake b/Modules/UseSWIG/ManageSupportFiles.cmake
new file mode 100644
index 0000000..4a03900
--- /dev/null
+++ b/Modules/UseSWIG/ManageSupportFiles.cmake
@@ -0,0 +1,31 @@
+# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+if (ACTION STREQUAL "CLEAN")
+  # Collect current list of generated files
+  file (GLOB files LIST_DIRECTORIES FALSE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*")
+
+  if (files)
+    # clean-up the output directory
+    ## compute full paths
+    list (TRANSFORM files PREPEND "${SUPPORT_FILES_OUTPUT_DIRECTORY}/")
+    ## remove generated files from the output directory
+    file (REMOVE ${files})
+
+    # clean-up working directory
+    file (REMOVE_RECURSE "${SUPPORT_FILES_WORKING_DIRECTORY}")
+  endif()
+
+  file (MAKE_DIRECTORY "${SUPPORT_FILES_WORKING_DIRECTORY}")
+endif()
+
+if (ACTION STREQUAL "COPY")
+  # Collect current list of generated files
+  file (GLOB files LIST_DIRECTORIES FALSE "${SUPPORT_FILES_WORKING_DIRECTORY}/*")
+
+  if (files)
+    # copy files to the output directory
+    file (COPY ${files} DESTINATION "${SUPPORT_FILES_OUTPUT_DIRECTORY}")
+  endif()
+endif()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=50572d638b3903f2c2af636dcfe9d3765fd87a7c
commit 50572d638b3903f2c2af636dcfe9d3765fd87a7c
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 29 11:15:10 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 29 11:37:32 2018 -0400

    set_directory_properties: Restore in script mode
    
    Since commit v3.10.0-rc1~391^2~3 (Add directory property 'LABELS' and
    CMAKE_DIRECTORY_LABELS variable, 2017-06-23) this command was
    accidentally not allowed in script mode.  It was dropped because
    `ctest -S` mode needs to start with CMake's normal script mode and
    then replace the `set_directory_properties` implementation.  Restore
    the normal `set_directory_properties` in script mode and then add
    special logic to replace it in ctest.  Also add a test case.
    
    Fixes: #18523

diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index c7ed927..d24410d 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -1662,6 +1662,7 @@ void cmCTestTestHandler::GetListOfTests()
   cm.GetState()->AddBuiltinCommand("set_tests_properties", newCom4);
 
   // Add handler for SET_DIRECTORY_PROPERTIES
+  cm.GetState()->RemoveBuiltinCommand("set_directory_properties");
   cmCTestSetDirectoryPropertiesCommand* newCom5 =
     new cmCTestSetDirectoryPropertiesCommand;
   newCom5->TestHandler = this;
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 8a7d9bd..ab0378b 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -147,6 +147,8 @@ void GetScriptingCommands(cmState* state)
   state->AddBuiltinCommand("separate_arguments",
                            new cmSeparateArgumentsCommand);
   state->AddBuiltinCommand("set", new cmSetCommand);
+  state->AddBuiltinCommand("set_directory_properties",
+                           new cmSetDirectoryPropertiesCommand);
   state->AddBuiltinCommand("set_property", new cmSetPropertyCommand);
   state->AddBuiltinCommand("site_name", new cmSiteNameCommand);
   state->AddBuiltinCommand("string", new cmStringCommand);
@@ -229,8 +231,6 @@ void GetProjectCommands(cmState* state)
   state->AddBuiltinCommand("install_targets", new cmInstallTargetsCommand);
   state->AddBuiltinCommand("link_directories", new cmLinkDirectoriesCommand);
   state->AddBuiltinCommand("project", new cmProjectCommand);
-  state->AddBuiltinCommand("set_directory_properties",
-                           new cmSetDirectoryPropertiesCommand);
   state->AddBuiltinCommand("set_source_files_properties",
                            new cmSetSourceFilesPropertiesCommand);
   state->AddBuiltinCommand("set_target_properties",
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 5957b5b..ae29160 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -456,6 +456,16 @@ std::vector<std::string> cmState::GetCommandNames() const
   return commandNames;
 }
 
+void cmState::RemoveBuiltinCommand(std::string const& name)
+{
+  assert(name == cmSystemTools::LowerCase(name));
+  std::map<std::string, cmCommand*>::iterator i =
+    this->BuiltinCommands.find(name);
+  assert(i != this->BuiltinCommands.end());
+  delete i->second;
+  this->BuiltinCommands.erase(i);
+}
+
 void cmState::RemoveUserDefinedCommands()
 {
   cmDeleteAll(this->ScriptedCommands);
diff --git a/Source/cmState.h b/Source/cmState.h
index e03ad89..a6db7b1 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -128,6 +128,7 @@ public:
                             cmPolicies::PolicyID policy, const char* message);
   void AddUnexpectedCommand(std::string const& name, const char* error);
   void AddScriptedCommand(std::string const& name, cmCommand* command);
+  void RemoveBuiltinCommand(std::string const& name);
   void RemoveUserDefinedCommands();
   std::vector<std::string> GetCommandNames() const;
 
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 29325ff..f4e32ae 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -158,6 +158,7 @@ add_RunCMake_test(ObjectLibrary)
 if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
   add_RunCMake_test(RuntimePath)
 endif()
+add_RunCMake_test(ScriptMode)
 add_RunCMake_test(Swift)
 add_RunCMake_test(TargetObjects)
 add_RunCMake_test(TargetSources)
diff --git a/Tests/RunCMake/ScriptMode/RunCMakeTest.cmake b/Tests/RunCMake/ScriptMode/RunCMakeTest.cmake
new file mode 100644
index 0000000..4c44ffb
--- /dev/null
+++ b/Tests/RunCMake/ScriptMode/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake_command(set_directory_properties ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/set_directory_properties.cmake)
diff --git a/Tests/RunCMake/ScriptMode/set_directory_properties.cmake b/Tests/RunCMake/ScriptMode/set_directory_properties.cmake
new file mode 100644
index 0000000..bf79317
--- /dev/null
+++ b/Tests/RunCMake/ScriptMode/set_directory_properties.cmake
@@ -0,0 +1 @@
+set_directory_properties(PROPERTIES SOME_PROPERTY FALSE)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=20fd16e756a590c0ff01fd32c162439aef429807
commit 20fd16e756a590c0ff01fd32c162439aef429807
Author:     Sylvain Joubert <joubert.sy at gmail.com>
AuthorDate: Mon Oct 29 14:59:37 2018 +0100
Commit:     Sylvain Joubert <joubert.sy at gmail.com>
CommitDate: Mon Oct 29 15:00:11 2018 +0100

    UseSWIG: Typo, add missing letter

diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index f20a53b..e73b007 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -122,7 +122,7 @@ ensure generated files will receive the required settings.
   If set to ``TRUE``, contents of target property
   :prop_tgt:`INCLUDE_DIRECTORIES` will be forwarded to ``SWIG`` compiler.
   If set to ``FALSE`` target property :prop_tgt:`INCLUDE_DIRECTORIES` will be
-  ignored. If not set, target property ``SWIG_USE_TARGT_INCLUDE_DIRECTORIES``
+  ignored. If not set, target property ``SWIG_USE_TARGET_INCLUDE_DIRECTORIES``
   will be considered.
 
 ``GENERATED_INCLUDE_DIRECTORIES``, ``GENERATED_COMPILE_DEFINITIONS`` and ``GENERATED_COMPILE_OPTIONS``

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42731e94bea0839842fc66cef27af71e12d753e1
commit 42731e94bea0839842fc66cef27af71e12d753e1
Author:     Cris Luengo <cris.l.luengo at gmail.com>
AuthorDate: Sun Oct 28 23:10:19 2018 -0600
Commit:     Cris Luengo <cris.l.luengo at gmail.com>
CommitDate: Sun Oct 28 23:12:25 2018 -0600

    FindMatlab: Fix linker command under Windows.

diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 0f0fd8d..8544653 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -1022,13 +1022,13 @@ function(matlab_add_mex)
 
     if (MSVC)
 
-      set(_link_flags "${_link_flags} /EXPORT:${mexFunction}")
+      set(_link_flags "${_link_flags} /EXPORT:mexFunction")
       if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, export version
-        set(_link_flags "${_link_flags} /EXPORT:${mexfilerequiredapiversion}")
+        set(_link_flags "${_link_flags} /EXPORT:mexfilerequiredapiversion")
       endif()
 
       if(Matlab_HAS_CPP_API)
-        set(_link_flags "${_link_flags} /EXPORT:${mexCreateMexFunction} /EXPORT:${mexDestroyMexFunction} /EXPORT:${mexFunctionAdapter}")
+        set(_link_flags "${_link_flags} /EXPORT:mexCreateMexFunction /EXPORT:mexDestroyMexFunction /EXPORT:mexFunctionAdapter")
         #TODO: Is this necessary?
       endif()
 
@@ -1460,6 +1460,7 @@ if(DEFINED Matlab_ROOT_DIR_LAST_CACHED)
 
   if(NOT Matlab_ROOT_DIR_LAST_CACHED STREQUAL Matlab_ROOT_DIR)
     set(_Matlab_cached_vars
+        Matlab_VERSION_STRING
         Matlab_INCLUDE_DIRS
         Matlab_MEX_LIBRARY
         Matlab_MEX_COMPILER
@@ -1477,7 +1478,7 @@ if(DEFINED Matlab_ROOT_DIR_LAST_CACHED)
         Matlab_MEXEXTENSIONS_PROG
         Matlab_ROOT_DIR_LAST_CACHED
         #Matlab_PROG_VERSION_STRING_AUTO_DETECT
-        Matlab_VERSION_STRING_INTERNAL
+        #Matlab_VERSION_STRING_INTERNAL
         )
     foreach(_var IN LISTS _Matlab_cached_vars)
       if(DEFINED ${_var})

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ee73e733e4ae7a1fe36c3010d8789de4d37dcc1c
commit ee73e733e4ae7a1fe36c3010d8789de4d37dcc1c
Author:     Cris Luengo <cris.l.luengo at gmail.com>
AuthorDate: Sun Oct 28 23:07:26 2018 -0600
Commit:     Cris Luengo <cris.l.luengo at gmail.com>
CommitDate: Sun Oct 28 23:12:26 2018 -0600

    FindMatlab: Fix compilation error in one specific test configuration.
    
    `matlab_wrapper2.cpp` failed to compile in one specific test configuration.
    I've copied an odd workaround from `matlab_wrapper1.cpp`, which doesn't fail
    to compile. I presume this workaround was meant to address this issue, but
    can't verify this locally.

diff --git a/Tests/FindMatlab/matlab_wrapper2.cpp b/Tests/FindMatlab/matlab_wrapper2.cpp
index 8b73ade..e768fbf 100644
--- a/Tests/FindMatlab/matlab_wrapper2.cpp
+++ b/Tests/FindMatlab/matlab_wrapper2.cpp
@@ -1,3 +1,9 @@
+
+// simple workaround to some compiler specific problems
+// see
+// http://stackoverflow.com/questions/22367516/mex-compile-error-unknown-type-name-char16-t/23281916#23281916
+#include <algorithm>
+
 #include "mex.h"
 
 // This test uses the new complex-interleaved C API (R2018a and newer)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=160499296c61b0edf2e6b08c44b31444e022528f
commit 160499296c61b0edf2e6b08c44b31444e022528f
Author:     Cris Luengo <cris.l.luengo at gmail.com>
AuthorDate: Mon Oct 22 02:19:04 2018 -0600
Commit:     Cris Luengo <cris.l.luengo at gmail.com>
CommitDate: Wed Oct 24 00:09:06 2018 -0600

    FindMatlab: added unit tests for new functionality.
    
    Also allowing a way to select which of multiple installed MATLAB versions to use in the test.

diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 71928a9..c7cfa86 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1493,13 +1493,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
 
   # Matlab module
   # CMake_TEST_FindMatlab: indicates to look for Matlab (from PATH for Linux)
+  # CMake_TEST_FindMatlab_ROOT_DIR: indicates an optional root directory for Matlab, allows to select a version.
   # CMake_TEST_FindMatlab_MCR: indicates the MCR is installed
   # CMake_TEST_FindMatlab_MCR_ROOT_DIR: indicates an optional root directory for the MCR, required on Linux
-  if(CMake_TEST_FindMatlab OR CMake_TEST_FindMatlab_MCR OR (NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL ""))
+  if(CMake_TEST_FindMatlab OR (NOT "${CMake_TEST_FindMatlab_ROOT_DIR}" STREQUAL "") OR
+     CMake_TEST_FindMatlab_MCR OR (NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL ""))
     set(FindMatlab_additional_test_options )
     if(CMake_TEST_FindMatlab_MCR OR NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "")
       set(FindMatlab_additional_test_options -DIS_MCR=TRUE)
     endif()
+    if(NOT "${CMake_TEST_FindMatlab_ROOT_DIR}" STREQUAL "")
+      set(FindMatlab_additional_test_options ${FindMatlab_additional_test_options} "-DMatlab_ROOT_DIR=${CMake_TEST_FindMatlab_ROOT_DIR}")
+    endif()
     if(NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "")
       set(FindMatlab_additional_test_options ${FindMatlab_additional_test_options} "-DMCR_ROOT:FILEPATH=${CMake_TEST_FindMatlab_MCR_ROOT_DIR}")
     endif()
@@ -1511,6 +1516,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
     ADD_TEST_MACRO(FindMatlab.components_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
     set(FindMatlab.failure_reports_BUILD_OPTIONS ${FindMatlab_additional_test_options})
     ADD_TEST_MACRO(FindMatlab.failure_reports   ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
+    set(FindMatlab.r2018a_check_BUILD_OPTIONS ${FindMatlab_additional_test_options})
+    ADD_TEST_MACRO(FindMatlab.r2018a_check   ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
   endif()
 
   find_package(GTK2 QUIET)
diff --git a/Tests/FindMatlab/basic_checks/CMakeLists.txt b/Tests/FindMatlab/basic_checks/CMakeLists.txt
index 4a74d93..c5be1ea 100644
--- a/Tests/FindMatlab/basic_checks/CMakeLists.txt
+++ b/Tests/FindMatlab/basic_checks/CMakeLists.txt
@@ -10,11 +10,10 @@ set(MATLAB_FIND_DEBUG TRUE)
 # - on 64bits builds (cmake is building with 64 bits), it looks for 64 bits Matlab
 
 if(IS_MCR)
-    set(components MX_LIBRARY)
     set(RUN_UNIT_TESTS FALSE)
 else()
     set(RUN_UNIT_TESTS TRUE)
-    set(components MX_LIBRARY MAIN_PROGRAM)
+    set(components MAIN_PROGRAM)
 endif()
 
 if(NOT "${MCR_ROOT}" STREQUAL "")
@@ -34,7 +33,7 @@ matlab_add_mex(
     OUTPUT_NAME cmake_matlab_mex1
     SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp
     DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt
-  )
+    )
 
 if(RUN_UNIT_TESTS)
     matlab_add_unit_test(
diff --git a/Tests/FindMatlab/cmake_matlab_unit_tests4.m b/Tests/FindMatlab/cmake_matlab_unit_tests4.m
new file mode 100644
index 0000000..6a7b04d
--- /dev/null
+++ b/Tests/FindMatlab/cmake_matlab_unit_tests4.m
@@ -0,0 +1,28 @@
+
+classdef cmake_matlab_unit_tests4 < matlab.unittest.TestCase
+  % Testing R2017b and R2018a APIs
+  properties
+  end
+
+  methods (Test)
+    function testR2017b(testCase)
+      ret = cmake_matlab_mex2a(5+6i);
+      testCase.verifyEqual(ret, 8);
+    end
+
+    function testR2018a(testCase)
+      ret = cmake_matlab_mex2b(5+6i);
+      v = version;
+      n = find(v=='.');
+      v = str2double(v(1:n(2)-1));
+      disp(v)
+      if v>= 9.4 % R2018a
+        testCase.verifyEqual(ret, 16);
+        disp('TESTING version >= 9.4')
+      else
+        testCase.verifyEqual(ret, 8);
+      end
+    end
+
+  end
+end
diff --git a/Tests/FindMatlab/cmake_matlab_unit_tests5.m b/Tests/FindMatlab/cmake_matlab_unit_tests5.m
new file mode 100644
index 0000000..b1936e3
--- /dev/null
+++ b/Tests/FindMatlab/cmake_matlab_unit_tests5.m
@@ -0,0 +1,20 @@
+
+classdef cmake_matlab_unit_tests5 < matlab.unittest.TestCase
+  % C++ API test
+  properties
+  end
+
+  methods (Test)
+    function testDummyCall(testCase)
+      % very simple call test
+      disp('TESTING C++')
+      ret = cmake_matlab_mex3(162);
+      testCase.verifyEqual(ret, 162);
+    end
+
+    function testFailTest(testCase)
+      testCase.verifyError(@() cmake_matlab_mex3, 'MATLAB:mex:CppMexException');
+    end
+
+  end
+end
diff --git a/Tests/FindMatlab/components_checks/CMakeLists.txt b/Tests/FindMatlab/components_checks/CMakeLists.txt
index da6a2b0..f5d4880 100644
--- a/Tests/FindMatlab/components_checks/CMakeLists.txt
+++ b/Tests/FindMatlab/components_checks/CMakeLists.txt
@@ -15,7 +15,7 @@ endif()
 # the success of the following command is dependent on the current configuration:
 # - on 32bits builds (cmake is building with 32 bits), it looks for 32 bits Matlab
 # - on 64bits builds (cmake is building with 64 bits), it looks for 64 bits Matlab
-find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY ENG_LIBRARY MAT_LIBRARY
+find_package(Matlab REQUIRED COMPONENTS ENG_LIBRARY MAT_LIBRARY
                     OPTIONAL_COMPONENTS MAIN_PROGRAM)
 
 message(STATUS "FindMatlab libraries: ${Matlab_LIBRARIES}")
@@ -28,4 +28,4 @@ matlab_add_mex(
     SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp
     DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt
     LINK_TO ${Matlab_LIBRARIES}
-  )
+    )
diff --git a/Tests/FindMatlab/failure_reports/CMakeLists.txt b/Tests/FindMatlab/failure_reports/CMakeLists.txt
index e597a4a..4b092cd 100644
--- a/Tests/FindMatlab/failure_reports/CMakeLists.txt
+++ b/Tests/FindMatlab/failure_reports/CMakeLists.txt
@@ -8,11 +8,10 @@ project(failure_reports)
 set(MATLAB_FIND_DEBUG TRUE)
 
 if(IS_MCR)
-    set(components MX_LIBRARY)
     set(RUN_UNIT_TESTS FALSE)
 else()
     set(RUN_UNIT_TESTS TRUE)
-    set(components MX_LIBRARY MAIN_PROGRAM)
+    set(components MAIN_PROGRAM)
 endif()
 
 if(NOT "${MCR_ROOT}" STREQUAL "")
@@ -32,7 +31,7 @@ matlab_add_mex(
     OUTPUT_NAME cmake_matlab_mex1
     SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp
     DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt
-  )
+    )
 
 if(RUN_UNIT_TESTS)
     # the unit test file does not exist: the failure should be properly reported
diff --git a/Tests/FindMatlab/matlab_wrapper2.cpp b/Tests/FindMatlab/matlab_wrapper2.cpp
new file mode 100644
index 0000000..8b73ade
--- /dev/null
+++ b/Tests/FindMatlab/matlab_wrapper2.cpp
@@ -0,0 +1,16 @@
+#include "mex.h"
+
+// This test uses the new complex-interleaved C API (R2018a and newer)
+
+// The input should be a complex array (scalar is OK). It returns the number of
+// bytes in a matrix element. For the old (R2017b) API, this is 8. For the new
+// (R2018a) API, this is 16.
+
+void mexFunction(const int nlhs, mxArray* plhs[], const int nrhs,
+                 const mxArray* prhs[])
+{
+  if (nrhs != 1 || !mxIsComplex(prhs[0])) {
+    mexErrMsgTxt("Incorrect arguments");
+  }
+  plhs[0] = mxCreateDoubleScalar(mxGetElementSize(prhs[0]));
+}
diff --git a/Tests/FindMatlab/matlab_wrapper3.cpp b/Tests/FindMatlab/matlab_wrapper3.cpp
new file mode 100644
index 0000000..6670815
--- /dev/null
+++ b/Tests/FindMatlab/matlab_wrapper3.cpp
@@ -0,0 +1,29 @@
+#include "mex.hpp"
+#include "mexAdapter.hpp"
+
+// This test uses the new C++ API (R2018a and newer)
+
+// The input should be a scalar double array. The output is a copy of that
+// array.
+
+using namespace matlab::data;
+using matlab::mex::ArgumentList;
+
+class MexFunction : public matlab::mex::Function
+{
+public:
+  void operator()(ArgumentList outputs, ArgumentList inputs)
+  {
+    std::shared_ptr<matlab::engine::MATLABEngine> matlabPtr = getEngine();
+    ArrayFactory factory;
+    if (inputs[0].getType() != ArrayType::DOUBLE ||
+        inputs[0].getType() == ArrayType::COMPLEX_DOUBLE ||
+        inputs[0].getNumberOfElements() != 1) {
+      matlabPtr->feval(
+        u"error", 0,
+        std::vector<Array>({ factory.createScalar("Incorrect arguments") }));
+    }
+    double a = inputs[0][0];
+    outputs[0] = factory.createScalar(a);
+  }
+};
diff --git a/Tests/FindMatlab/r2018a_check/CMakeLists.txt b/Tests/FindMatlab/r2018a_check/CMakeLists.txt
new file mode 100644
index 0000000..c732be1
--- /dev/null
+++ b/Tests/FindMatlab/r2018a_check/CMakeLists.txt
@@ -0,0 +1,84 @@
+
+cmake_minimum_required (VERSION 2.8.12)
+enable_testing()
+project(r2018a_checks)
+
+set(MATLAB_FIND_DEBUG TRUE)
+
+# this test doesn't do much if MATLAB version < R2018a
+
+if(IS_MCR)
+    set(RUN_UNIT_TESTS FALSE)
+else()
+    set(RUN_UNIT_TESTS TRUE)
+    set(components MAIN_PROGRAM)
+endif()
+
+if(NOT "${MCR_ROOT}" STREQUAL "")
+    set(Matlab_ROOT_DIR "${MCR_ROOT}")
+    if(NOT EXISTS "${MCR_ROOT}")
+        message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
+    endif()
+endif()
+
+find_package(Matlab REQUIRED COMPONENTS ${components})
+
+set(IS_R2018a 1)
+if(${Matlab_VERSION_STRING} VERSION_LESS "9.4")
+    # This is an older version of MATLAB, tests will fail
+    set(IS_R2018a 0)
+endif()
+
+matlab_add_mex(
+    # target name
+    NAME cmake_matlab_test_wrapper2a
+    # output name
+    OUTPUT_NAME cmake_matlab_mex2a
+    SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper2.cpp
+    R2017b
+    )
+
+matlab_add_mex(
+    # target name
+    NAME cmake_matlab_test_wrapper2b
+    # output name
+    OUTPUT_NAME cmake_matlab_mex2b
+    SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper2.cpp
+    R2018a
+    )
+
+if(IS_R2018a)
+    matlab_add_mex(
+        # target name
+        NAME cmake_matlab_test_wrapper3
+        # output name
+        OUTPUT_NAME cmake_matlab_mex3
+        SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper3.cpp
+        )
+    set_target_properties(
+        cmake_matlab_test_wrapper3
+        PROPERTIES
+        CXX_STANDARD 11
+        CXX_STANDARD_REQUIRED ON
+        )
+endif()
+
+if(RUN_UNIT_TESTS)
+    # Check that the R2017b and R2018a APIs work.
+    matlab_add_unit_test(
+        NAME ${PROJECT_NAME}_matlabtest-1
+        TIMEOUT 300
+        UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests4.m
+        ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper2a>
+        )
+
+    # Check that the C++ API works (test run only on R2018a and newer)
+    if(IS_R2018a)
+        matlab_add_unit_test(
+            NAME ${PROJECT_NAME}_matlabtest-3
+            TIMEOUT 300
+            UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests5.m
+            ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper3>
+            )
+    endif()
+endif()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ee7e97a7d35a793985cf6f9aa185069460cf0ec6
commit ee7e97a7d35a793985cf6f9aa185069460cf0ec6
Author:     Cris Luengo <cris.l.luengo at gmail.com>
AuthorDate: Mon Oct 22 00:03:17 2018 -0600
Commit:     Cris Luengo <cris.l.luengo at gmail.com>
CommitDate: Wed Oct 24 00:09:06 2018 -0600

    FindMatlab: add change log item.

diff --git a/Help/release/dev/FindMatlab-2018a-API.rst b/Help/release/dev/FindMatlab-2018a-API.rst
new file mode 100644
index 0000000..1063411
--- /dev/null
+++ b/Help/release/dev/FindMatlab-2018a-API.rst
@@ -0,0 +1,7 @@
+FindMatlab-2018a-API
+--------------------
+
+* The :module:`FindMatlab` module gained new options ``R2017b`` and
+  ``R2018a`` to specify the MEX API version to use; these options
+  mirror the new options to the ``mex`` command in MATLAB R2018a.
+  The option ``MX_LIBRARY`` is no longer needed.

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d7e19032d52f9d1529a27bb1061da33524b69060
commit d7e19032d52f9d1529a27bb1061da33524b69060
Author:     Cris Luengo <cris.l.luengo at gmail.com>
AuthorDate: Sun Oct 21 23:59:31 2018 -0600
Commit:     Cris Luengo <cris.l.luengo at gmail.com>
CommitDate: Tue Oct 23 23:50:17 2018 -0600

    FindMatlab: `matlab_add_mex` has new options `R2017b` and `R2018a`.
    
    - These options are equivalent to `mex` command options `-R2017b` and `-R2018a`.
    - `R2017b` is the default, and selects the compatability API.
    - `R2018a` is the alternative, and selects the new complex-interleaved API.
    - For versions of MATLAB before R2018a, these options are ignored.
    - `matlab_add_mex` now works correctly with newer MATLABs.

diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 1e29702..0f0fd8d 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -884,6 +884,7 @@ endfunction()
          [OUTPUT_NAME output_name]
          [DOCUMENTATION file.txt]
          [LINK_TO target1 target2 ...]
+         [R2017b | R2018a]
          [...]
      )
 
@@ -904,6 +905,12 @@ endfunction()
     the same folder without any processing, with the same name as the final
     mex file, and with extension `.m`. In that case, typing ``help <name>``
     in Matlab prints the documentation contained in this file.
+  ``R2017b`` or ``R2018a`` may be given to specify the version of the C API
+    to use: ``R2017b`` specifies the traditional (separate complex) C API,
+    and corresponds to the ``-R2017b`` flag for the `mex` command. ``R2018a``
+    specifies the new interleaved complex C API, and corresponds to the
+    ``-R2018a`` flag for the `mex` command. Ignored if MATLAB version prior
+    to R2018a. Defaults to ``R2017b``.
   ``MODULE`` or ``SHARED`` may be given to specify the type of library to be
     created. ``EXECUTABLE`` may be given to create an executable instead of
     a library. If no type is given explicitly, the type is ``SHARED``.
@@ -933,7 +940,7 @@ function(matlab_add_mex)
 
   endif()
 
-  set(options EXECUTABLE MODULE SHARED)
+  set(options EXECUTABLE MODULE SHARED R2017b R2018a)
   set(oneValueArgs NAME DOCUMENTATION OUTPUT_NAME)
   set(multiValueArgs LINK_TO SRC)
 
@@ -948,9 +955,25 @@ function(matlab_add_mex)
     set(${prefix}_OUTPUT_NAME ${${prefix}_NAME})
   endif()
 
+  if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, add version source file
+    # TODO: check the file extensions in ${${prefix}_SRC} to see if they're C or C++ files
+    # Currently, the C and C++ versions of the version files are identical, so this doesn't matter.
+    set(MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/c_mexapi_version.c")
+    #set(MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/cpp_mexapi_version.cpp")
+  endif()
+
+  if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.4") # For 9.4 (R2018a) and newer, add API macro
+    if(${${prefix}_R2018a})
+      set(MEX_API_MACRO "MATLAB_DEFAULT_RELEASE=R2018a")
+    else()
+      set(MEX_API_MACRO "MATLAB_DEFAULT_RELEASE=R2017b")
+    endif()
+  endif()
+
   if(${prefix}_EXECUTABLE)
     add_executable(${${prefix}_NAME}
       ${${prefix}_SRC}
+      ${MEX_VERSION_FILE}
       ${${prefix}_DOCUMENTATION}
       ${${prefix}_UNPARSED_ARGUMENTS})
   else()
@@ -963,31 +986,25 @@ function(matlab_add_mex)
     add_library(${${prefix}_NAME}
       ${type}
       ${${prefix}_SRC}
+      ${MEX_VERSION_FILE}
       ${${prefix}_DOCUMENTATION}
       ${${prefix}_UNPARSED_ARGUMENTS})
   endif()
 
   target_include_directories(${${prefix}_NAME} PRIVATE ${Matlab_INCLUDE_DIRS})
 
-  if(DEFINED Matlab_MX_LIBRARY)
-    target_link_libraries(${${prefix}_NAME} ${Matlab_MX_LIBRARY})
-  endif()
-
-  if(DEFINED Matlab_ENGINE_LIBRARY)
-    target_link_libraries(${${prefix}_NAME} ${Matlab_ENGINE_LIBRARY})
-  endif()
-
-  if(DEFINED Matlab_DATAARRAY_LIBRARY)
-    target_link_libraries(${${prefix}_NAME} ${Matlab_DATAARRAY_LIBRARY})
+  if(Matlab_HAS_CPP_API)
+    target_link_libraries(${${prefix}_NAME} ${Matlab_ENGINE_LIBRARY} ${Matlab_DATAARRAY_LIBRARY})
   endif()
 
-  target_link_libraries(${${prefix}_NAME} ${Matlab_MEX_LIBRARY} ${${prefix}_LINK_TO})
+  target_link_libraries(${${prefix}_NAME} ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${${prefix}_LINK_TO})
   set_target_properties(${${prefix}_NAME}
       PROPERTIES
         PREFIX ""
         OUTPUT_NAME ${${prefix}_OUTPUT_NAME}
         SUFFIX ".${Matlab_MEX_EXTENSION}")
 
+  target_compile_definitions(${${prefix}_NAME} PRIVATE ${MEX_API_MACRO} MATLAB_MEX_FILE)
 
   # documentation
   if(NOT ${${prefix}_DOCUMENTATION} STREQUAL "")
@@ -1001,82 +1018,82 @@ function(matlab_add_mex)
   endif() # documentation
 
   # entry point in the mex file + taking care of visibility and symbol clashes.
-  if (MSVC)
-    get_target_property(
-        _previous_link_flags
-        ${${prefix}_NAME}
-        LINK_FLAGS)
-    if(NOT _previous_link_flags)
-      set(_previous_link_flags)
-    endif()
+  if(WIN32)
 
-    set_target_properties(${${prefix}_NAME}
-      PROPERTIES
-        LINK_FLAGS "${_previous_link_flags} /EXPORT:mexFunction")
-  endif()
+    if (MSVC)
+
+      set(_link_flags "${_link_flags} /EXPORT:${mexFunction}")
+      if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, export version
+        set(_link_flags "${_link_flags} /EXPORT:${mexfilerequiredapiversion}")
+      endif()
+
+      if(Matlab_HAS_CPP_API)
+        set(_link_flags "${_link_flags} /EXPORT:${mexCreateMexFunction} /EXPORT:${mexDestroyMexFunction} /EXPORT:${mexFunctionAdapter}")
+        #TODO: Is this necessary?
+      endif()
+
+      set_property(TARGET ${${prefix}_NAME} APPEND PROPERTY LINK_FLAGS ${_link_flags})
+
+    endif() # TODO: what if there's a different compiler on Windows?
 
-  if(WIN32)
     set_target_properties(${${prefix}_NAME}
       PROPERTIES
         DEFINE_SYMBOL "DLL_EXPORT_SYM=__declspec(dllexport)")
+
   else()
 
-    if(HAS_MINUS_PTHREAD AND NOT APPLE)
-      # Apparently, compiling with -pthread generated the proper link flags
-      # and some defines at compilation
-      target_compile_options(${${prefix}_NAME} PRIVATE "-pthread")
+    if(${Matlab_VERSION_STRING} VERSION_LESS "9.1") # For versions prior to 9.1 (R2016b)
+      set(_ver_map_files ${Matlab_EXTERN_LIBRARY_DIR}/mexFunction.map)
+    else()                                          # For 9.1 (R2016b) and newer
+      set(_ver_map_files ${Matlab_EXTERN_LIBRARY_DIR}/c_exportsmexfileversion.map)
     endif()
 
+    if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.5") # For 9.5 (R2018b) (and newer?)
+      target_compile_options(${${prefix}_NAME} PRIVATE "-fvisibility=default")
+      # This one is weird, it might be a bug in <mex.h> for R2018b. When compiling with
+      # -fvisibility=hidden, the symbol `mexFunction` cannot be exported. Reading the
+      # source code for <mex.h>, it seems that the preprocessor macro `MW_NEEDS_VERSION_H`
+      # needs to be defined for `__attribute__ ((visibility("default")))` to be added
+      # in front of the declaration of `mexFunction`. In previous versions of MATLAB this
+      # was not the case, there `DLL_EXPORT_SYM` needed to be defined.
+      # Adding `-fvisibility=hidden` to the `mex` command causes the build to fail.
+      # TODO: Check that this is still necessary in R2019a when it comes out.
+    endif()
 
-    # if we do not do that, the symbols linked from eg. boost remain weak and
-    # then clash with the ones defined in the matlab process. So by default
-    # the symbols are hidden.
-    # This also means that for shared libraries (like MEX), the entry point
-    # should be explicitly declared with default visibility, otherwise Matlab
-    # cannot find the entry point.
-    # Note that this is particularly meaningful if the MEX wrapper itself
-    # contains symbols that are clashing with Matlab (that are compiled in the
-    # MEX file). In order to propagate the visibility options to the libraries
-    # to which the MEX file is linked against, the -Wl,--exclude-libs,ALL
-    # option should also be specified.
+    if(APPLE)
 
-    set_target_properties(${${prefix}_NAME}
-      PROPERTIES
-        CXX_VISIBILITY_PRESET "hidden"
-        C_VISIBILITY_PRESET "hidden"
-        VISIBILITY_INLINES_HIDDEN ON
-    )
+      if(Matlab_HAS_CPP_API)
+        list(APPEND _ver_map_files ${Matlab_EXTERN_LIBRARY_DIR}/cppMexFunction.map) # This one doesn't exist on Linux
+        set(_link_flags "${_link_flags} -Wl,-U,_mexCreateMexFunction -Wl,-U,_mexDestroyMexFunction -Wl,-U,_mexFunctionAdapter")
+        # On MacOS, the MEX command adds the above, without it the link breaks
+        # because we indiscriminately use "cppMexFunction.map" even for C API MEX-files.
+      endif()
 
-    #  get_target_property(
-    #    _previous_link_flags
-    #    ${${prefix}_NAME}
-    #    LINK_FLAGS)
-    #  if(NOT _previous_link_flags)
-    #    set(_previous_link_flags)
-    #  endif()
-
-    #  if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-    #    set_target_properties(${${prefix}_NAME}
-    #      PROPERTIES
-    #        LINK_FLAGS "${_previous_link_flags} -Wl,--exclude-libs,ALL"
-    #        # -Wl,--version-script=${_FindMatlab_SELF_DIR}/MatlabLinuxVisibility.map"
-    #    )
-    #  elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
-    #    # in this case, all other symbols become hidden.
-    #    set_target_properties(${${prefix}_NAME}
-    #      PROPERTIES
-    #        LINK_FLAGS "${_previous_link_flags} -Wl,-exported_symbol,_mexFunction"
-    #        #-Wl,-exported_symbols_list,${_FindMatlab_SELF_DIR}/MatlabOSXVisilibity.map"
-    #    )
-    #  endif()
+      set(_export_flag_name -exported_symbols_list)
 
+    else() # Linux
 
+      if(HAS_MINUS_PTHREAD)
+        # Apparently, compiling with -pthread generated the proper link flags
+        # and some defines at compilation
+        target_compile_options(${${prefix}_NAME} PRIVATE "-pthread")
+      endif()
+
+      set(_link_flags "${_link_flags} -Wl,--as-needed")
+
+      set(_export_flag_name --version-script)
+
+    endif()
+
+    foreach(_file ${_ver_map_files})
+      set(_link_flags "${_link_flags} -Wl,${_export_flag_name},${_file}")
+    endforeach()
 
     set_target_properties(${${prefix}_NAME}
       PROPERTIES
         DEFINE_SYMBOL "DLL_EXPORT_SYM=__attribute__ ((visibility (\"default\")))"
-    )
-
+        LINK_FLAGS "${_link_flags}"
+    ) # The `mex` command doesn't add this define. Is it necessary?
 
   endif()
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=518553d9537be7e6c245090e52ba989df5686e19
commit 518553d9537be7e6c245090e52ba989df5686e19
Author:     Cris Luengo <cris.l.luengo at gmail.com>
AuthorDate: Sun Oct 21 23:56:33 2018 -0600
Commit:     Cris Luengo <cris.l.luengo at gmail.com>
CommitDate: Tue Oct 23 23:50:17 2018 -0600

    FindMatlab: Always find core libraries.
    
    - `MX_LIBRARY`, `Matlab_ENGINE_LIBRARY` and `Matlab_DATAARRAY_LIBRARY` are always found.
    - The corresponding options are now ignored.

diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 8ba88b0..1e29702 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -19,10 +19,8 @@ can also be used:
 
 The module supports the following components:
 
-* ``MX_LIBRARY``, ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the ``MX``,
-  ``ENG`` and ``MAT`` libraries of Matlab
-* ``ENGINE_LIBRARY``, ``DATAARRAY_LIBRARY``: respectively the ``MatlabEngine``
-  and ``MatlabDataArray`` libraries of Matlab (Matlab 2018a and later)
+* ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the ``ENG`` and ``MAT``
+  libraries of Matlab
 * ``MAIN_PROGRAM`` the Matlab binary program. Note that this component is not
   available on the MCR version, and will yield an error if the MCR is found
   instead of the regular Matlab installation.
@@ -101,8 +99,7 @@ Result variables
 ``Matlab_MEX_LIBRARY``
   library for mex, always available.
 ``Matlab_MX_LIBRARY``
-  mx library of Matlab (arrays). Available only if the component
-  ``MX_LIBRARY`` has been requested.
+  mx library of Matlab (arrays), always available.
 ``Matlab_ENG_LIBRARY``
   Matlab engine library. Available only if the component ``ENG_LIBRARY``
   is requested.
@@ -110,11 +107,9 @@ Result variables
   Matlab matrix library. Available only if the component ``MAT_LIBRARY``
   is requested.
 ``Matlab_ENGINE_LIBRARY``
-  Matlab C++ engine library. Available only if the component ``ENGINE_LIBRARY``
-  is requested.
+  Matlab C++ engine library, always available for R2018a and newer.
 ``Matlab_DATAARRAY_LIBRARY``
-  Matlab C++ data array library. Available only if the component ``DATAARRAY_LIBRARY``
-  is requested.
+  Matlab C++ data array library, always available for R2018a and newer.
 ``Matlab_LIBRARIES``
   the whole set of libraries of Matlab
 ``Matlab_MEX_COMPILER``
@@ -898,8 +893,7 @@ endfunction()
     list of source files.
   ``LINK_TO``
     a list of additional link dependencies.  The target links to ``libmex``
-    by default. If ``Matlab_MX_LIBRARY`` is defined, it also
-    links to ``libmx``.
+    and ``libmx`` by default.
   ``OUTPUT_NAME``
     if given, overrides the default name. The default name is
     the name of the target without any prefix and
@@ -1491,7 +1485,9 @@ if(MATLAB_FIND_DEBUG)
   message(STATUS "[MATLAB] Current version is ${Matlab_VERSION_STRING} located ${Matlab_ROOT_DIR}")
 endif()
 
-
+if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.4") # MATLAB 9.4 (R2018a) and newer have a new C++ API
+  set(Matlab_HAS_CPP_API 1)
+endif()
 
 if(Matlab_ROOT_DIR)
   file(TO_CMAKE_PATH ${Matlab_ROOT_DIR} Matlab_ROOT_DIR)
@@ -1530,6 +1526,8 @@ set(Matlab_BINARIES_DIR
     ${Matlab_ROOT_DIR}/bin/${_matlab_bin_prefix}${_matlab_current_suffix})
 set(Matlab_EXTERN_LIBRARY_DIR
     ${Matlab_ROOT_DIR}/extern/lib/${_matlab_bin_prefix}${_matlab_current_suffix})
+set(Matlab_EXTERN_BINARIES_DIR
+    ${Matlab_ROOT_DIR}/extern/bin/${_matlab_bin_prefix}${_matlab_current_suffix})
 
 if(WIN32)
   if(MINGW)
@@ -1539,7 +1537,7 @@ if(WIN32)
   endif()
   set(_matlab_lib_prefix_for_search "lib")
 else()
-  set(_matlab_lib_dir_for_search ${Matlab_BINARIES_DIR})
+  set(_matlab_lib_dir_for_search ${Matlab_BINARIES_DIR} ${Matlab_EXTERN_BINARIES_DIR})
   set(_matlab_lib_prefix_for_search "lib")
 endif()
 
@@ -1590,7 +1588,6 @@ _Matlab_find_library(
   PATHS ${_matlab_lib_dir_for_search}
   NO_DEFAULT_PATH
 )
-
 list(APPEND _matlab_required_variables Matlab_MEX_LIBRARY)
 
 # the MEX extension is required
@@ -1631,21 +1628,18 @@ if(_matlab_find_matlab_program GREATER -1)
 endif()
 unset(_matlab_find_matlab_program)
 
-# Component MX library
-list(FIND Matlab_FIND_COMPONENTS MX_LIBRARY _matlab_find_mx)
-if(_matlab_find_mx GREATER -1)
-  _Matlab_find_library(
-    ${_matlab_lib_prefix_for_search}
-    Matlab_MX_LIBRARY
-    mx
-    PATHS ${_matlab_lib_dir_for_search}
-    NO_DEFAULT_PATH
-  )
-  if(Matlab_MX_LIBRARY)
-    set(Matlab_MX_LIBRARY_FOUND TRUE)
-  endif()
+# The MX library is required
+_Matlab_find_library(
+  ${_matlab_lib_prefix_for_search}
+  Matlab_MX_LIBRARY
+  mx
+  PATHS ${_matlab_lib_dir_for_search}
+  NO_DEFAULT_PATH
+)
+list(APPEND _matlab_required_variables Matlab_MX_LIBRARY)
+if(Matlab_MX_LIBRARY)
+  set(Matlab_MX_LIBRARY_FOUND TRUE)
 endif()
-unset(_matlab_find_mx)
 
 # Component ENG library
 list(FIND Matlab_FIND_COMPONENTS ENG_LIBRARY _matlab_find_eng)
@@ -1711,9 +1705,9 @@ if(_matlab_find_mcc_compiler GREATER -1)
 endif()
 unset(_matlab_find_mcc_compiler)
 
-# component MatlabEngine
-list(FIND Matlab_FIND_COMPONENTS ENGINE_LIBRARY _matlab_find_matlab_engine)
-if(_matlab_find_matlab_engine GREATER -1)
+if(Matlab_HAS_CPP_API)
+
+  # The MatlabEngine library is required for R2018a+
   _Matlab_find_library(
     ${_matlab_lib_prefix_for_search}
     Matlab_ENGINE_LIBRARY
@@ -1722,40 +1716,33 @@ if(_matlab_find_matlab_engine GREATER -1)
     DOC "MatlabEngine Library"
     NO_DEFAULT_PATH
   )
+  list(APPEND _matlab_required_variables Matlab_ENGINE_LIBRARY)
   if(Matlab_ENGINE_LIBRARY)
     set(Matlab_ENGINE_LIBRARY_FOUND TRUE)
   endif()
-endif()
-unset(_matlab_find_matlab_engine)
 
-# component MatlabDataArray
-list(FIND Matlab_FIND_COMPONENTS DATAARRAY_LIBRARY _matlab_find_matlab_dataarray)
-if(_matlab_find_matlab_dataarray GREATER -1)
+  # The MatlabDataArray library is required for R2018a+
   _Matlab_find_library(
-  ${_matlab_lib_prefix_for_search}
+    ${_matlab_lib_prefix_for_search}
     Matlab_DATAARRAY_LIBRARY
     MatlabDataArray
     PATHS ${_matlab_lib_dir_for_search}
     DOC "MatlabDataArray Library"
     NO_DEFAULT_PATH
   )
+  list(APPEND _matlab_required_variables Matlab_DATAARRAY_LIBRARY)
   if(Matlab_DATAARRAY_LIBRARY)
     set(Matlab_DATAARRAY_LIBRARY_FOUND TRUE)
   endif()
+
 endif()
-unset(_matlab_find_matlab_dataarray)
 
 unset(_matlab_lib_dir_for_search)
 
-set(Matlab_LIBRARIES ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${Matlab_ENG_LIBRARY} ${Matlab_MAT_LIBRARY})
-
-if(Matlab_DATAARRAY_LIBRARY_FOUND)
-  set(Matlab_LIBRARIES ${Matlab_LIBRARIES} ${Matlab_DATAARRAY_LIBRARY})
-endif()
-
-if(Matlab_ENGINE_LIBRARY_FOUND)
-  set(Matlab_LIBRARIES ${Matlab_LIBRARIES} ${Matlab_ENGINE_LIBRARY})
-endif()
+set(Matlab_LIBRARIES
+  ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY}
+  ${Matlab_ENG_LIBRARY} ${Matlab_MAT_LIBRARY}
+  ${Matlab_DATAARRAY_LIBRARY} ${Matlab_ENGINE_LIBRARY})
 
 find_package_handle_standard_args(
   Matlab

-----------------------------------------------------------------------

Summary of changes:
 Help/release/dev/FindMatlab-2018a-API.rst          |   7 +
 Modules/Compiler/Flang-Fortran.cmake               |   2 +-
 Modules/Compiler/QCC.cmake                         |   2 +-
 Modules/FindBoost.cmake                            |   6 +
 Modules/FindMatlab.cmake                           | 243 +++++++++++----------
 Modules/UseSWIG.cmake                              |  15 +-
 Modules/UseSWIG/ManageSupportFiles.cmake           |  31 +++
 Source/CTest/cmCTestTestHandler.cxx                |   1 +
 Source/cmCommands.cxx                              |   4 +-
 Source/cmLinkLineDeviceComputer.cxx                |  16 +-
 Source/cmState.cxx                                 |  10 +
 Source/cmState.h                                   |   1 +
 Tests/CMakeLists.txt                               |   9 +-
 Tests/FindMatlab/basic_checks/CMakeLists.txt       |   5 +-
 Tests/FindMatlab/cmake_matlab_unit_tests4.m        |  28 +++
 Tests/FindMatlab/cmake_matlab_unit_tests5.m        |  20 ++
 Tests/FindMatlab/components_checks/CMakeLists.txt  |   4 +-
 Tests/FindMatlab/failure_reports/CMakeLists.txt    |   5 +-
 .../matlab_wrapper2.cpp}                           |  19 +-
 Tests/FindMatlab/matlab_wrapper3.cpp               |  29 +++
 Tests/FindMatlab/r2018a_check/CMakeLists.txt       |  84 +++++++
 Tests/RunCMake/CMakeLists.txt                      |   1 +
 Tests/RunCMake/ScriptMode/RunCMakeTest.cmake       |   3 +
 .../ScriptMode/set_directory_properties.cmake      |   1 +
 24 files changed, 390 insertions(+), 156 deletions(-)
 create mode 100644 Help/release/dev/FindMatlab-2018a-API.rst
 create mode 100644 Modules/UseSWIG/ManageSupportFiles.cmake
 create mode 100644 Tests/FindMatlab/cmake_matlab_unit_tests4.m
 create mode 100644 Tests/FindMatlab/cmake_matlab_unit_tests5.m
 copy Tests/{RunCMake/FindMatlab/matlab_wrapper1.cpp => FindMatlab/matlab_wrapper2.cpp} (50%)
 create mode 100644 Tests/FindMatlab/matlab_wrapper3.cpp
 create mode 100644 Tests/FindMatlab/r2018a_check/CMakeLists.txt
 create mode 100644 Tests/RunCMake/ScriptMode/RunCMakeTest.cmake
 create mode 100644 Tests/RunCMake/ScriptMode/set_directory_properties.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list