Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
# Conflicts:
#	HISTORY.md
  • Loading branch information
sakra committed Mar 25, 2020
2 parents c35c63b + 2a12f99 commit ca9f189
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 104 deletions.
95 changes: 39 additions & 56 deletions CMake/Mathematica/FindMathematica.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1910,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
Expand Down Expand Up @@ -2412,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()
Expand Down Expand Up @@ -2515,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})
Expand Down Expand Up @@ -2654,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)
Expand Down Expand Up @@ -2724,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}
Expand Down Expand Up @@ -3407,54 +3438,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")
Expand Down Expand Up @@ -4472,7 +4455,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)
Expand Down Expand Up @@ -4543,4 +4526,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)
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.7 COMPONENTS Development)

if (Mathematica_MathLink_DEFINITIONS)
add_definitions(${Mathematica_MathLink_DEFINITIONS})
endif()
Expand Down
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -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.7 (2020-02-09)

* fix compatibility with Wolfram Engine under OS X
Expand Down
4 changes: 2 additions & 2 deletions JLinkExamples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 1 addition & 15 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -607,21 +608,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(
<input file>
[ OUTPUT <C source file> ])

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(
<input file> [ <input file> ... ]
[ OUTPUT <output file> [ <output file> ... ] | <output directory> ]
Expand Down
17 changes: 1 addition & 16 deletions MathematicaExamples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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[\"$<TARGET_FILE:spliceDemo>\",\"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[]]"
Expand All @@ -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
Expand Down
11 changes: 0 additions & 11 deletions MathematicaExamples/spliceDemo.mc

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit ca9f189

Please sign in to comment.