Skip to content

Commit ca9f189

Browse files
committed
Merge branch 'development'
# Conflicts: # HISTORY.md
2 parents c35c63b + 2a12f99 commit ca9f189

8 files changed

Lines changed: 58 additions & 104 deletions

File tree

CMake/Mathematica/FindMathematica.cmake

Lines changed: 39 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ cmake_minimum_required(VERSION 2.8.12)
3434
cmake_policy(POP)
3535

3636
set (Mathematica_CMAKE_MODULE_DIR "${CMAKE_CURRENT_LIST_DIR}")
37-
set (Mathematica_CMAKE_MODULE_VERSION "3.2.7")
37+
set (Mathematica_CMAKE_MODULE_VERSION "3.3.0")
3838

3939
# activate select policies
4040
if (POLICY CMP0025)
@@ -245,7 +245,8 @@ macro (_get_program_names _outProgramNames)
245245
set (_MathematicaApps "Mathematica" "Wolfram Desktop" "Wolfram Engine" "gridMathematica Server")
246246
# Mathematica product versions in order of preference
247247
set (_MathematicaVersions
248-
"12.0" "11.3" "11.2" "11.1" "11.0"
248+
"12.1" "12.0"
249+
"11.3" "11.2" "11.1" "11.0"
249250
"10.4" "10.3" "10.2" "10.1" "10.0"
250251
"9.0" "8.0" "7.0" "6.0" "5.2")
251252
# search for explicitly requested application version first
@@ -647,7 +648,17 @@ macro (_get_host_system_IDs _outSystemIDs)
647648
endmacro()
648649

649650
macro (_get_supported_systemIDs _version _outSystemIDs)
650-
if (NOT "${_version}" VERSION_LESS "10.0")
651+
if (NOT "${_version}" VERSION_LESS "12.1")
652+
set (${_outSystemIDs}
653+
"Windows-x86-64"
654+
"Linux-x86-64" "Linux-ARM"
655+
"MacOSX-x86-64")
656+
elseif (NOT "${_version}" VERSION_LESS "11.3")
657+
set (${_outSystemIDs}
658+
"Windows" "Windows-x86-64"
659+
"Linux-x86-64" "Linux-ARM"
660+
"MacOSX-x86-64")
661+
elseif (NOT "${_version}" VERSION_LESS "10.0")
651662
set (${_outSystemIDs}
652663
"Windows" "Windows-x86-64"
653664
"Linux" "Linux-x86-64" "Linux-ARM"
@@ -704,8 +715,16 @@ macro (_get_compatible_system_IDs _systemID _outSystemIDs)
704715
else()
705716
list (APPEND ${_outSystemIDs} "Windows-x86-64")
706717
endif()
707-
# Windows x64 can run x86 through WoW64
708-
list (APPEND ${_outSystemIDs} "Windows")
718+
if (Mathematica_VERSION)
719+
# Mathematica 12.1 dropped support for x86
720+
if ("${Mathematica_VERSION}" VERSION_LESS "12.1")
721+
# Windows x64 can run x86 through WoW64
722+
list (APPEND ${_outSystemIDs} "Windows")
723+
endif()
724+
else()
725+
# Windows x64 can run x86 through WoW64
726+
list (APPEND ${_outSystemIDs} "Windows")
727+
endif()
709728
elseif ("${_systemID}" MATCHES "MacOSX|Darwin")
710729
if ("${_systemID}" MATCHES "MacOSX-x86")
711730
if (Mathematica_VERSION)
@@ -1910,6 +1929,13 @@ macro (_find_jlink)
19101929
DOC "J/Link Java launcher."
19111930
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
19121931
)
1932+
find_path (Mathematica_JLink_JAVA_HOME
1933+
NAMES "bin/${_JLinkJavaNames}"
1934+
HINTS "${_mmaJavaHome}"
1935+
PATH_SUFFIXES ${_HostSystemIDs}
1936+
DOC "J/Link Java home directory."
1937+
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
1938+
)
19131939
endmacro()
19141940

19151941
# internal macro to find MUnit package
@@ -2412,6 +2438,7 @@ macro (_log_found_variables)
24122438
message (STATUS "J/Link JAR file ${Mathematica_JLink_JAR_FILE}")
24132439
message (STATUS "J/Link native library ${Mathematica_JLink_RUNTIME_LIBRARY}")
24142440
message (STATUS "J/Link java launcher ${Mathematica_JLink_JAVA_EXECUTABLE}")
2441+
message (STATUS "J/Link java home directory ${Mathematica_JLink_JAVA_HOME}")
24152442
else()
24162443
message (STATUS "J/Link not found")
24172444
endif()
@@ -2515,7 +2542,8 @@ macro (_get_dependent_cache_variables _var _outDependentVars)
25152542
Mathematica_JLink_PACKAGE_DIR
25162543
Mathematica_MUnit_PACKAGE_FILE
25172544
Mathematica_LibraryLink_PACKAGE_FILE
2518-
Mathematica_JLink_JAVA_EXECUTABLE)
2545+
Mathematica_JLink_JAVA_EXECUTABLE
2546+
Mathematica_JLink_JAVA_HOME)
25192547
_get_dependent_cache_variables("Mathematica_MathLink_HOST_ROOT_DIR" ${_outDependentVars})
25202548
_get_dependent_cache_variables("Mathematica_WSTP_HOST_ROOT_DIR" ${_outDependentVars})
25212549
_get_dependent_cache_variables("Mathematica_JLink_PACKAGE_DIR" ${_outDependentVars})
@@ -2654,6 +2682,7 @@ macro (_update_cache)
26542682
Mathematica_LibraryLink_PACKAGE_FILE
26552683
Mathematica_JLink_RUNTIME_LIBRARY
26562684
Mathematica_JLink_JAVA_EXECUTABLE
2685+
Mathematica_JLink_JAVA_HOME
26572686
)
26582687
_get_cache_variables(_CacheVariables)
26592688
foreach (_CacheVariable IN LISTS _CacheVariables)
@@ -2724,6 +2753,8 @@ macro (_setup_found_variables)
27242753
_get_components_to_find(_components)
27252754
foreach(_component IN LISTS _components)
27262755
_get_required_vars(${_component} _requiredComponentVars)
2756+
# suppress find_package_handle_standard_args warning on mismatching names
2757+
set (FPHSA_NAME_MISMATCHED On)
27272758
find_package_handle_standard_args(
27282759
Mathematica_${_component}
27292760
REQUIRED_VARS ${_requiredComponentVars}
@@ -3407,54 +3438,6 @@ function (Mathematica_ADD_TEST)
34073438
add_test (${_cmd})
34083439
endfunction (Mathematica_ADD_TEST)
34093440

3410-
# public function to add target that runs Mathematica Splice function on template file
3411-
function (Mathematica_SPLICE_C_CODE _templateFile)
3412-
get_filename_component(_templateFileBaseName ${_templateFile} NAME_WE)
3413-
get_filename_component(_templateFileName ${_templateFile} NAME)
3414-
get_filename_component(_templateFileAbs ${_templateFile} ABSOLUTE)
3415-
get_filename_component(_templateFileExt ${_templateFileName} EXT)
3416-
set(_options "")
3417-
set(_oneValueArgs "OUTPUT")
3418-
set(_multiValueArgs "")
3419-
cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
3420-
if(_option_UNPARSED_ARGUMENTS)
3421-
message (FATAL_ERROR "Unknown keywords: ${_option_UNPARSED_ARGUMENTS}")
3422-
endif()
3423-
# Mathematica function Splice does not produce output in current working directory
3424-
# Use absolute paths to make it write to the current binary directory
3425-
if (_option_OUTPUT)
3426-
if (IS_ABSOLUTE ${_option_OUTPUT})
3427-
set (_outputFileAbs "${_option_OUTPUT}")
3428-
else()
3429-
set (_outputFileAbs "${CMAKE_CURRENT_BINARY_DIR}/${_option_OUTPUT}")
3430-
endif()
3431-
else()
3432-
set (_outputFileAbs "${CMAKE_CURRENT_BINARY_DIR}/${_templateFileBaseName}.c")
3433-
endif()
3434-
# Always set FormatType option to prevent Splice function from failing with a
3435-
# Splice::splict error if the template file path contains more than one dot character
3436-
string(TOLOWER ${_templateFileExt} _templateFileExt)
3437-
if ("${_templateFileExt}" STREQUAL ".mc")
3438-
set (_formatType "CForm")
3439-
elseif ("${_templateFileExt}" STREQUAL ".mf")
3440-
set (_formatType "FortranForm")
3441-
elseif ("${_templateFileExt}" STREQUAL ".mtex")
3442-
set (_formatType "TeXForm")
3443-
else()
3444-
set (_formatType "Automatic")
3445-
endif()
3446-
get_filename_component(_outputFileName ${_outputFileAbs} NAME)
3447-
Mathematica_TO_NATIVE_PATH("${_templateFileAbs}" _templateFileMma)
3448-
Mathematica_TO_NATIVE_PATH("${_outputFileAbs}" _outputFileMma)
3449-
set (_msg "Splicing Mathematica code in ${_templateFileName} to ${_outputFileName}")
3450-
Mathematica_ADD_CUSTOM_COMMAND(
3451-
CODE "Splice[${_templateFileMma}, ${_outputFileMma}, FormatType->${_formatType}]"
3452-
OUTPUT "${_outputFileAbs}"
3453-
DEPENDS "${_templateFileAbs}"
3454-
COMMENT ${_msg})
3455-
set_source_files_properties(${_outputFileAbs} PROPERTIES GENERATED TRUE LABELS "Mathematica")
3456-
endfunction(Mathematica_SPLICE_C_CODE)
3457-
34583441
# public function to add target that runs Mathematica Encode function on input files
34593442
function (Mathematica_ENCODE)
34603443
set(_options "CHECK_TIMESTAMPS")
@@ -4472,7 +4455,7 @@ endfunction (Mathematica_ADD_DOCUMENTATION)
44724455

44734456
endif (Mathematica_KERNEL_EXECUTABLE AND Mathematica_JLink_FOUND)
44744457

4475-
if (Mathematica_KERNEL_EXECUTABLE AND Mathematica_JLink_FOUND AND JAVA_FOUND)
4458+
if (Mathematica_KERNEL_EXECUTABLE AND Mathematica_JLink_FOUND)
44764459

44774460
# public function to simplify testing J/Link programs
44784461
function (Mathematica_JLink_ADD_TEST)
@@ -4543,4 +4526,4 @@ function (Mathematica_JLink_ADD_TEST)
45434526
add_test (${_cmd})
45444527
endfunction(Mathematica_JLink_ADD_TEST)
45454528

4546-
endif(Mathematica_KERNEL_EXECUTABLE AND Mathematica_JLink_FOUND AND JAVA_FOUND)
4529+
endif(Mathematica_KERNEL_EXECUTABLE AND Mathematica_JLink_FOUND)

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ if (NOT CMAKE_VERSION VERSION_LESS "3.1")
2121
set (CMAKE_CXX_STANDARD 11)
2222
endif()
2323

24-
# find Java
25-
find_package(Java 1.6 COMPONENTS Development)
26-
2724
# default settings for options that affect search
2825
#set (Mathematica_USE_STATIC_LIBRARIES OFF)
2926
#set (Mathematica_USE_MINIMAL_LIBRARIES ON)
@@ -41,6 +38,12 @@ find_package(Mathematica)
4138
# finds Mathematica >= 9 installation and optional components
4239
#find_package(Mathematica 9 COMPONENTS MathLink JLink)
4340

41+
# find Java and use the Java installation bundled with Mathematica
42+
if (Mathematica_JLink_JAVA_HOME AND NOT APPLE)
43+
set (JAVA_HOME "${Mathematica_JLink_JAVA_HOME}")
44+
endif()
45+
find_package(Java 1.7 COMPONENTS Development)
46+
4447
if (Mathematica_MathLink_DEFINITIONS)
4548
add_definitions(${Mathematica_MathLink_DEFINITIONS})
4649
endif()

HISTORY.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 3.3.0 (2020-03-25)
2+
3+
* *Mathematica* 12.1 compatibility
4+
* remove `Mathematica_SPLICE_C_CODE` whose underlying *Mathematica* function `Splice`
5+
has been deprecated since *Mathematica* 10 and has been removed in *Mathematica* 12.1
6+
* add new variable `Mathematica_JLink_JAVA_HOME`, which contains the full path to Java SDK
7+
bundled with *Mathematica*
8+
19
## 3.2.7 (2020-02-09)
210

311
* fix compatibility with Wolfram Engine under OS X

JLinkExamples/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
include(UseJava)
44

55
# add J/Link jar to Java compiler include path
6-
set(CMAKE_JAVA_INCLUDE_PATH "${Mathematica_JLink_JAR_FILE}")
6+
set (CMAKE_JAVA_INCLUDE_PATH "${Mathematica_JLink_JAR_FILE}")
77
# force Java 6 compilation of example sources, J/Link is not compatible with Java 7
88
# sample source files use Windows character encoding
9-
set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.6" "-target" "1.6" "-encoding" "Cp1252")
9+
set (CMAKE_JAVA_COMPILE_FLAGS "-source" "1.7" "-target" "1.7" "-encoding" "Cp1252")
1010

1111
if (NOT CYGWIN)
1212
# UseJava module cannot handle Cygwin path syntax

MANUAL.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ The module defines the following variables for component `JLink`:
330330
* `Mathematica_JLink_FOUND` - True if the Wolfram Language installation has J/Link SDK
331331
* `Mathematica_JLink_PACKAGE_DIR` - J/Link package root directory
332332
* `Mathematica_JLink_JAR_FILE` - Full path to J/Link JAR file
333+
* `Mathematica_JLink_JAVA_HOME` - Full path to Java SDK bundled with *Mathematica*
333334
* `Mathematica_JLink_JAVA_EXECUTABLE` - path to the host Java runtime executable used by J/Link
334335
* `Mathematica_JLink_RUNTIME_LIBRARY` - Full path to JLinkNativeLibrary
335336
* `Mathematica_JLink_VERSION` - J/Link version number given as "major.minor.patch"
@@ -607,21 +608,6 @@ The `OUTPUT` option can be used to produce output files with different names.
607608
This function is available if the Wolfram Language kernel executable has been found and if the
608609
Wolfram Language installation has a Wolfram Runtime Library.
609610

610-
Mathematica_SPLICE_C_CODE(
611-
<input file>
612-
[ OUTPUT <C source file> ])
613-
614-
This function adds a custom command which runs the Wolfram Language function `Splice` on the input
615-
file. Text enclosed between `<*` and `*>` in the input file is evaluated as Wolfram Language input and
616-
replaced with the resulting Wolfram Language output.
617-
618-
The output file is created in the `CMAKE_CURRENT_BINARY_DIR`. The name of the output file is
619-
obtained by adding the extensions .c to the input file base name. The `OUTPUT` option can be used to
620-
produce an output file with a different name.
621-
622-
This function is available if the Wolfram Language kernel executable has been found. Note that the
623-
function `Splice` has been deprecated as of *Mathematica* 10.
624-
625611
Mathematica_ENCODE(
626612
<input file> [ <input file> ... ]
627613
[ OUTPUT <output file> [ <output file> ... ] | <output directory> ]

MathematicaExamples/CMakeLists.txt

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ Mathematica_EXECUTE(
2828
SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/directories.m"
2929
OUTPUT_FILE "directories.m.log" TIMEOUT 10)
3030

31-
# generate a static library from a template file that is processed by
32-
# the Mathematica function Splice before compiling
33-
include_directories(${Mathematica_INCLUDE_DIR})
34-
Mathematica_SPLICE_C_CODE(spliceDemo.mc OUTPUT spliceDemo.c)
35-
add_library(spliceDemo STATIC spliceDemo.c)
36-
set_target_properties(spliceDemo PROPERTIES FOLDER "Mathematica")
37-
38-
if ("${Mathematica_VERSION_MAJOR}" GREATER 5)
39-
# add a post-build action which computes the MD5 checksum of the library
40-
Mathematica_ADD_CUSTOM_COMMAND(TARGET spliceDemo POST_BUILD
41-
CODE "Print[OutputForm[BaseForm[FileHash[\"$<TARGET_FILE:spliceDemo>\",\"MD5\"],16]]]"
42-
COMMENT "Computing spliceDemo MD5 checksum.")
43-
endif()
44-
4531
# add a stand-alone target which runs Mathematica code
4632
Mathematica_ADD_CUSTOM_TARGET(CurrentDate ALL
4733
CODE "Print[DateString[]]"
@@ -61,8 +47,7 @@ add_custom_target(MathematicaExamples ALL
6147
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/demo.m"
6248
SOURCES
6349
"${CMAKE_CURRENT_SOURCE_DIR}/demo.m"
64-
"${CMAKE_CURRENT_SOURCE_DIR}/directories.m"
65-
"${CMAKE_CURRENT_SOURCE_DIR}/spliceDemo.mc")
50+
"${CMAKE_CURRENT_SOURCE_DIR}/directories.m")
6651
set_target_properties(MathematicaExamples PROPERTIES FOLDER "Mathematica")
6752

6853
# define a helper function to simplify CMake Mathematica tests

MathematicaExamples/spliceDemo.mc

Lines changed: 0 additions & 11 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Features
88
--------
99

1010
* Works with Windows, Linux and OS X versions of the [Wolfram Language][wlang].
11-
* Supports Wolfram Language versions from 5.2 to 12.0.
11+
* Supports Wolfram Language versions from 5.2 to 12.1.
1212
* Supports Wolfram Language implementations [Wolfram Mathematica][wmma],
1313
[Wolfram|One][wone], [Wolfram Engine][weng] and [Wolfram gridMathematica][wgrid].
1414
* Finds include directories and libraries for [LibraryLink][wll] (version 8 or later).

0 commit comments

Comments
 (0)