From ecb6c0c5f71e6614fcd9baa18a652340f3ecce44 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 19 Mar 2020 20:27:30 +0100 Subject: [PATCH 1/8] start version 3.3.0 --- CMake/Mathematica/FindMathematica.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/Mathematica/FindMathematica.cmake b/CMake/Mathematica/FindMathematica.cmake index 004d9ca..5f55108 100644 --- a/CMake/Mathematica/FindMathematica.cmake +++ b/CMake/Mathematica/FindMathematica.cmake @@ -34,7 +34,7 @@ cmake_minimum_required(VERSION 2.8.12) cmake_policy(POP) set (Mathematica_CMAKE_MODULE_DIR "${CMAKE_CURRENT_LIST_DIR}") -set (Mathematica_CMAKE_MODULE_VERSION "3.2.7") +set (Mathematica_CMAKE_MODULE_VERSION "3.3.0") # activate select policies if (POLICY CMP0025) From eb7a2f5389dd73bcc71687d0b954fddab698b874 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 19 Mar 2020 20:29:30 +0100 Subject: [PATCH 2/8] Mathematica 12.1 compatibility --- CMake/Mathematica/FindMathematica.cmake | 27 +++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/CMake/Mathematica/FindMathematica.cmake b/CMake/Mathematica/FindMathematica.cmake index 5f55108..df69d3a 100644 --- a/CMake/Mathematica/FindMathematica.cmake +++ b/CMake/Mathematica/FindMathematica.cmake @@ -245,7 +245,8 @@ macro (_get_program_names _outProgramNames) set (_MathematicaApps "Mathematica" "Wolfram Desktop" "Wolfram Engine" "gridMathematica Server") # Mathematica product versions in order of preference set (_MathematicaVersions - "12.0" "11.3" "11.2" "11.1" "11.0" + "12.1" "12.0" + "11.3" "11.2" "11.1" "11.0" "10.4" "10.3" "10.2" "10.1" "10.0" "9.0" "8.0" "7.0" "6.0" "5.2") # search for explicitly requested application version first @@ -647,7 +648,17 @@ macro (_get_host_system_IDs _outSystemIDs) endmacro() macro (_get_supported_systemIDs _version _outSystemIDs) - if (NOT "${_version}" VERSION_LESS "10.0") + if (NOT "${_version}" VERSION_LESS "12.1") + set (${_outSystemIDs} + "Windows-x86-64" + "Linux-x86-64" "Linux-ARM" + "MacOSX-x86-64") + elseif (NOT "${_version}" VERSION_LESS "11.3") + set (${_outSystemIDs} + "Windows" "Windows-x86-64" + "Linux-x86-64" "Linux-ARM" + "MacOSX-x86-64") + elseif (NOT "${_version}" VERSION_LESS "10.0") set (${_outSystemIDs} "Windows" "Windows-x86-64" "Linux" "Linux-x86-64" "Linux-ARM" @@ -704,8 +715,16 @@ macro (_get_compatible_system_IDs _systemID _outSystemIDs) else() list (APPEND ${_outSystemIDs} "Windows-x86-64") endif() - # Windows x64 can run x86 through WoW64 - list (APPEND ${_outSystemIDs} "Windows") + if (Mathematica_VERSION) + # Mathematica 12.1 dropped support for x86 + if ("${Mathematica_VERSION}" VERSION_LESS "12.1") + # Windows x64 can run x86 through WoW64 + list (APPEND ${_outSystemIDs} "Windows") + endif() + else() + # Windows x64 can run x86 through WoW64 + list (APPEND ${_outSystemIDs} "Windows") + endif() elseif ("${_systemID}" MATCHES "MacOSX|Darwin") if ("${_systemID}" MATCHES "MacOSX-x86") if (Mathematica_VERSION) From 01e437a6a55dc0e7618291bf88dec6b3c39e62e5 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 19 Mar 2020 20:30:40 +0100 Subject: [PATCH 3/8] remove Mathematica_SPLICE_C_CODE --- CMake/Mathematica/FindMathematica.cmake | 48 ------------------------- MANUAL.md | 15 -------- MathematicaExamples/CMakeLists.txt | 17 +-------- MathematicaExamples/spliceDemo.mc | 11 ------ 4 files changed, 1 insertion(+), 90 deletions(-) delete mode 100644 MathematicaExamples/spliceDemo.mc diff --git a/CMake/Mathematica/FindMathematica.cmake b/CMake/Mathematica/FindMathematica.cmake index df69d3a..1687071 100644 --- a/CMake/Mathematica/FindMathematica.cmake +++ b/CMake/Mathematica/FindMathematica.cmake @@ -3426,54 +3426,6 @@ function (Mathematica_ADD_TEST) add_test (${_cmd}) endfunction (Mathematica_ADD_TEST) -# public function to add target that runs Mathematica Splice function on template file -function (Mathematica_SPLICE_C_CODE _templateFile) - get_filename_component(_templateFileBaseName ${_templateFile} NAME_WE) - get_filename_component(_templateFileName ${_templateFile} NAME) - get_filename_component(_templateFileAbs ${_templateFile} ABSOLUTE) - get_filename_component(_templateFileExt ${_templateFileName} EXT) - set(_options "") - set(_oneValueArgs "OUTPUT") - set(_multiValueArgs "") - cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) - if(_option_UNPARSED_ARGUMENTS) - message (FATAL_ERROR "Unknown keywords: ${_option_UNPARSED_ARGUMENTS}") - endif() - # Mathematica function Splice does not produce output in current working directory - # Use absolute paths to make it write to the current binary directory - if (_option_OUTPUT) - if (IS_ABSOLUTE ${_option_OUTPUT}) - set (_outputFileAbs "${_option_OUTPUT}") - else() - set (_outputFileAbs "${CMAKE_CURRENT_BINARY_DIR}/${_option_OUTPUT}") - endif() - else() - set (_outputFileAbs "${CMAKE_CURRENT_BINARY_DIR}/${_templateFileBaseName}.c") - endif() - # Always set FormatType option to prevent Splice function from failing with a - # Splice::splict error if the template file path contains more than one dot character - string(TOLOWER ${_templateFileExt} _templateFileExt) - if ("${_templateFileExt}" STREQUAL ".mc") - set (_formatType "CForm") - elseif ("${_templateFileExt}" STREQUAL ".mf") - set (_formatType "FortranForm") - elseif ("${_templateFileExt}" STREQUAL ".mtex") - set (_formatType "TeXForm") - else() - set (_formatType "Automatic") - endif() - get_filename_component(_outputFileName ${_outputFileAbs} NAME) - Mathematica_TO_NATIVE_PATH("${_templateFileAbs}" _templateFileMma) - Mathematica_TO_NATIVE_PATH("${_outputFileAbs}" _outputFileMma) - set (_msg "Splicing Mathematica code in ${_templateFileName} to ${_outputFileName}") - Mathematica_ADD_CUSTOM_COMMAND( - CODE "Splice[${_templateFileMma}, ${_outputFileMma}, FormatType->${_formatType}]" - OUTPUT "${_outputFileAbs}" - DEPENDS "${_templateFileAbs}" - COMMENT ${_msg}) - set_source_files_properties(${_outputFileAbs} PROPERTIES GENERATED TRUE LABELS "Mathematica") -endfunction(Mathematica_SPLICE_C_CODE) - # public function to add target that runs Mathematica Encode function on input files function (Mathematica_ENCODE) set(_options "CHECK_TIMESTAMPS") diff --git a/MANUAL.md b/MANUAL.md index 180ada8..0fb2aec 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -607,21 +607,6 @@ The `OUTPUT` option can be used to produce output files with different names. This function is available if the Wolfram Language kernel executable has been found and if the Wolfram Language installation has a Wolfram Runtime Library. - Mathematica_SPLICE_C_CODE( - - [ OUTPUT ]) - -This function adds a custom command which runs the Wolfram Language function `Splice` on the input -file. Text enclosed between `<*` and `*>` in the input file is evaluated as Wolfram Language input and -replaced with the resulting Wolfram Language output. - -The output file is created in the `CMAKE_CURRENT_BINARY_DIR`. The name of the output file is -obtained by adding the extensions .c to the input file base name. The `OUTPUT` option can be used to -produce an output file with a different name. - -This function is available if the Wolfram Language kernel executable has been found. Note that the -function `Splice` has been deprecated as of *Mathematica* 10. - Mathematica_ENCODE( [ ... ] [ OUTPUT [ ... ] | ] diff --git a/MathematicaExamples/CMakeLists.txt b/MathematicaExamples/CMakeLists.txt index 680c781..6b3fc04 100644 --- a/MathematicaExamples/CMakeLists.txt +++ b/MathematicaExamples/CMakeLists.txt @@ -28,20 +28,6 @@ Mathematica_EXECUTE( SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/directories.m" OUTPUT_FILE "directories.m.log" TIMEOUT 10) -# generate a static library from a template file that is processed by -# the Mathematica function Splice before compiling -include_directories(${Mathematica_INCLUDE_DIR}) -Mathematica_SPLICE_C_CODE(spliceDemo.mc OUTPUT spliceDemo.c) -add_library(spliceDemo STATIC spliceDemo.c) -set_target_properties(spliceDemo PROPERTIES FOLDER "Mathematica") - -if ("${Mathematica_VERSION_MAJOR}" GREATER 5) - # add a post-build action which computes the MD5 checksum of the library - Mathematica_ADD_CUSTOM_COMMAND(TARGET spliceDemo POST_BUILD - CODE "Print[OutputForm[BaseForm[FileHash[\"$\",\"MD5\"],16]]]" - COMMENT "Computing spliceDemo MD5 checksum.") -endif() - # add a stand-alone target which runs Mathematica code Mathematica_ADD_CUSTOM_TARGET(CurrentDate ALL CODE "Print[DateString[]]" @@ -61,8 +47,7 @@ add_custom_target(MathematicaExamples ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/demo.m" SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/demo.m" - "${CMAKE_CURRENT_SOURCE_DIR}/directories.m" - "${CMAKE_CURRENT_SOURCE_DIR}/spliceDemo.mc") + "${CMAKE_CURRENT_SOURCE_DIR}/directories.m") set_target_properties(MathematicaExamples PROPERTIES FOLDER "Mathematica") # define a helper function to simplify CMake Mathematica tests diff --git a/MathematicaExamples/spliceDemo.mc b/MathematicaExamples/spliceDemo.mc deleted file mode 100644 index 071b01b..0000000 --- a/MathematicaExamples/spliceDemo.mc +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include "mdefs.h" - -double f(double x) -{ - double y; - - y = <* Integrate[Cos[x]^5, x] *>; - - return (2*y - 1); -} From d3af39a403963403074a04dad24d5ecd42f668d1 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 19 Mar 2020 20:33:25 +0100 Subject: [PATCH 4/8] set up Mathematica_JLink_JAVA_HOME variable --- CMake/Mathematica/FindMathematica.cmake | 16 +++++++++++++--- CMakeLists.txt | 9 ++++++--- JLinkExamples/CMakeLists.txt | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CMake/Mathematica/FindMathematica.cmake b/CMake/Mathematica/FindMathematica.cmake index 1687071..4f91983 100644 --- a/CMake/Mathematica/FindMathematica.cmake +++ b/CMake/Mathematica/FindMathematica.cmake @@ -1929,6 +1929,13 @@ macro (_find_jlink) DOC "J/Link Java launcher." NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) + find_path (Mathematica_JLink_JAVA_HOME + NAMES "bin/${_JLinkJavaNames}" + HINTS "${_mmaJavaHome}" + PATH_SUFFIXES ${_HostSystemIDs} + DOC "J/Link Java home directory." + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH + ) endmacro() # internal macro to find MUnit package @@ -2431,6 +2438,7 @@ macro (_log_found_variables) message (STATUS "J/Link JAR file ${Mathematica_JLink_JAR_FILE}") message (STATUS "J/Link native library ${Mathematica_JLink_RUNTIME_LIBRARY}") message (STATUS "J/Link java launcher ${Mathematica_JLink_JAVA_EXECUTABLE}") + message (STATUS "J/Link java home directory ${Mathematica_JLink_JAVA_HOME}") else() message (STATUS "J/Link not found") endif() @@ -2534,7 +2542,8 @@ macro (_get_dependent_cache_variables _var _outDependentVars) Mathematica_JLink_PACKAGE_DIR Mathematica_MUnit_PACKAGE_FILE Mathematica_LibraryLink_PACKAGE_FILE - Mathematica_JLink_JAVA_EXECUTABLE) + Mathematica_JLink_JAVA_EXECUTABLE + Mathematica_JLink_JAVA_HOME) _get_dependent_cache_variables("Mathematica_MathLink_HOST_ROOT_DIR" ${_outDependentVars}) _get_dependent_cache_variables("Mathematica_WSTP_HOST_ROOT_DIR" ${_outDependentVars}) _get_dependent_cache_variables("Mathematica_JLink_PACKAGE_DIR" ${_outDependentVars}) @@ -2673,6 +2682,7 @@ macro (_update_cache) Mathematica_LibraryLink_PACKAGE_FILE Mathematica_JLink_RUNTIME_LIBRARY Mathematica_JLink_JAVA_EXECUTABLE + Mathematica_JLink_JAVA_HOME ) _get_cache_variables(_CacheVariables) foreach (_CacheVariable IN LISTS _CacheVariables) @@ -4443,7 +4453,7 @@ endfunction (Mathematica_ADD_DOCUMENTATION) endif (Mathematica_KERNEL_EXECUTABLE AND Mathematica_JLink_FOUND) -if (Mathematica_KERNEL_EXECUTABLE AND Mathematica_JLink_FOUND AND JAVA_FOUND) +if (Mathematica_KERNEL_EXECUTABLE AND Mathematica_JLink_FOUND) # public function to simplify testing J/Link programs function (Mathematica_JLink_ADD_TEST) @@ -4514,4 +4524,4 @@ function (Mathematica_JLink_ADD_TEST) add_test (${_cmd}) endfunction(Mathematica_JLink_ADD_TEST) -endif(Mathematica_KERNEL_EXECUTABLE AND Mathematica_JLink_FOUND AND JAVA_FOUND) +endif(Mathematica_KERNEL_EXECUTABLE AND Mathematica_JLink_FOUND) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f386f0..b443e6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,9 +21,6 @@ if (NOT CMAKE_VERSION VERSION_LESS "3.1") set (CMAKE_CXX_STANDARD 11) endif() -# find Java -find_package(Java 1.6 COMPONENTS Development) - # default settings for options that affect search #set (Mathematica_USE_STATIC_LIBRARIES OFF) #set (Mathematica_USE_MINIMAL_LIBRARIES ON) @@ -41,6 +38,12 @@ find_package(Mathematica) # finds Mathematica >= 9 installation and optional components #find_package(Mathematica 9 COMPONENTS MathLink JLink) +# find Java and use the Java installation bundled with Mathematica +if (Mathematica_JLink_JAVA_HOME AND NOT APPLE) + set (JAVA_HOME "${Mathematica_JLink_JAVA_HOME}") +endif() +find_package(Java 1.6 COMPONENTS Development) + if (Mathematica_MathLink_DEFINITIONS) add_definitions(${Mathematica_MathLink_DEFINITIONS}) endif() diff --git a/JLinkExamples/CMakeLists.txt b/JLinkExamples/CMakeLists.txt index e206bea..e4e04e8 100644 --- a/JLinkExamples/CMakeLists.txt +++ b/JLinkExamples/CMakeLists.txt @@ -3,10 +3,10 @@ include(UseJava) # add J/Link jar to Java compiler include path -set(CMAKE_JAVA_INCLUDE_PATH "${Mathematica_JLink_JAR_FILE}") +set (CMAKE_JAVA_INCLUDE_PATH "${Mathematica_JLink_JAR_FILE}") # force Java 6 compilation of example sources, J/Link is not compatible with Java 7 # sample source files use Windows character encoding -set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.6" "-target" "1.6" "-encoding" "Cp1252") +set (CMAKE_JAVA_COMPILE_FLAGS "-source" "1.7" "-target" "1.7" "-encoding" "Cp1252") if (NOT CYGWIN) # UseJava module cannot handle Cygwin path syntax From 18fe0a0ce7fefd57ecfa14b2a924540c8563db9d Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Thu, 19 Mar 2020 20:50:36 +0100 Subject: [PATCH 5/8] document Mathematica_JLink_JAVA_HOME variable --- MANUAL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/MANUAL.md b/MANUAL.md index 0fb2aec..78110fc 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -330,6 +330,7 @@ The module defines the following variables for component `JLink`: * `Mathematica_JLink_FOUND` - True if the Wolfram Language installation has J/Link SDK * `Mathematica_JLink_PACKAGE_DIR` - J/Link package root directory * `Mathematica_JLink_JAR_FILE` - Full path to J/Link JAR file +* `Mathematica_JLink_JAVA_HOME` - Full path to Java SDK bundled with *Mathematica* * `Mathematica_JLink_JAVA_EXECUTABLE` - path to the host Java runtime executable used by J/Link * `Mathematica_JLink_RUNTIME_LIBRARY` - Full path to JLinkNativeLibrary * `Mathematica_JLink_VERSION` - J/Link version number given as "major.minor.patch" From 91182780a8382ef850006f74c75bfc837c1922ff Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Sat, 21 Mar 2020 13:48:14 +0100 Subject: [PATCH 6/8] suppress find_package_handle_standard_args warning on mismatching names --- CMake/Mathematica/FindMathematica.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMake/Mathematica/FindMathematica.cmake b/CMake/Mathematica/FindMathematica.cmake index 4f91983..6e721a0 100644 --- a/CMake/Mathematica/FindMathematica.cmake +++ b/CMake/Mathematica/FindMathematica.cmake @@ -2753,6 +2753,8 @@ macro (_setup_found_variables) _get_components_to_find(_components) foreach(_component IN LISTS _components) _get_required_vars(${_component} _requiredComponentVars) + # suppress find_package_handle_standard_args warning on mismatching names + set (FPHSA_NAME_MISMATCHED On) find_package_handle_standard_args( Mathematica_${_component} REQUIRED_VARS ${_requiredComponentVars} From bec846d20df9312b11cb3e05613b603915641a7e Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 25 Mar 2020 14:16:43 +0100 Subject: [PATCH 7/8] require Java 1.7 for Java examples --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b443e6d..29ff271 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ find_package(Mathematica) if (Mathematica_JLink_JAVA_HOME AND NOT APPLE) set (JAVA_HOME "${Mathematica_JLink_JAVA_HOME}") endif() -find_package(Java 1.6 COMPONENTS Development) +find_package(Java 1.7 COMPONENTS Development) if (Mathematica_MathLink_DEFINITIONS) add_definitions(${Mathematica_MathLink_DEFINITIONS}) From 2a12f990992c41200bd1c4dffd7d336d6cd5b3e8 Mon Sep 17 00:00:00 2001 From: Sascha Kratky Date: Wed, 25 Mar 2020 14:22:37 +0100 Subject: [PATCH 8/8] docu updates --- HISTORY.md | 8 ++++++++ README.md | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 9c831d3..26042fd 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,11 @@ +## 3.3.0 (2020-03-25) + +* *Mathematica* 12.1 compatibility +* remove `Mathematica_SPLICE_C_CODE` whose underlying *Mathematica* function `Splice` + has been deprecated since *Mathematica* 10 and has been removed in *Mathematica* 12.1 +* add new variable `Mathematica_JLink_JAVA_HOME`, which contains the full path to Java SDK + bundled with *Mathematica* + ## 3.2.6 (2020-02-07) * Wolfram Desktop compatibility diff --git a/README.md b/README.md index d40383a..89068a5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Features -------- * Works with Windows, Linux and OS X versions of the [Wolfram Language][wlang]. -* Supports Wolfram Language versions from 5.2 to 12.0. +* Supports Wolfram Language versions from 5.2 to 12.1. * Supports Wolfram Language implementations [Wolfram Mathematica][wmma], [Wolfram|One][wone], [Wolfram Engine][weng] and [Wolfram gridMathematica][wgrid]. * Finds include directories and libraries for [LibraryLink][wll] (version 8 or later).