-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_matlab_executable.cmake.in
83 lines (75 loc) · 3.36 KB
/
generate_matlab_executable.cmake.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# ============================================================================
# Copyright (c) 2011-2012 University of Pennsylvania
# Copyright (c) 2013-2016 Andreas Schuh
# All rights reserved.
#
# See COPYING file for license information or visit
# https://cmake-basis.github.io/download.html#license
# ============================================================================
##############################################################################
# @file generate_matlab_executable.cmake.in
# @brief Generate wrapper executable for invocation of MATLAB command.
#
# @note This file is generated by BASIS from the template file
# generate_matlab_executable.cmake.in which is part of the BASIS installation.
#
# This script is configured using CMake's configure_sript() function instead
# of providing its arguments using the -D option of CMake before the -P option
# such that the build command can be made dependent on the configured build script.
##############################################################################
cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
include ("@BASIS_MODULE_PATH@/MatlabTools.cmake") # basis_generate_matlab_executable()
# basis_write_addpaths_mfile()
# ----------------------------------------------------------------------------
# configuration
# ----------------------------------------------------------------------------
# general settings
set (MATLAB_EXECUTABLE "@MATLAB_EXECUTABLE@")
set (MATLAB_COMMAND "@MATLAB_COMMAND@")
# settings specific to build tree
set (OUTPUT_FILE "@OUTPUT_FILE@")
set (BUILD_MATLABPATH "@BUILD_MATLABPATH@")
set (BUILD_STARTUP_FILE "@BUILD_STARTUP_FILE@")
# settings specific to installation
set (INSTALL_FILE "@INSTALL_FILE@")
set (INSTALL_DIR "@INSTALL_DIR@")
set (INSTALL_MATLABPATH "@INSTALL_MATLABPATH@")
set (INSTALL_STARTUP_FILE "@INSTALL_STARTUP_FILE@")
set (INSTALL_STARTUP_DIR "@INSTALL_STARTUP_DIR@")
# ----------------------------------------------------------------------------
# main
# ----------------------------------------------------------------------------
# write startup.m file for build tree
if (BUILD_STARTUP_FILE)
file (WRITE "${BUILD_STARTUP_FILE}"
"% DO NOT edit. This file is generated by BASIS.
[mfiledir, ~, ~, ~] = fileparts(mfilename('fullpath'));\n")
basis_write_addpaths_mfile ("${BUILD_STARTUP_FILE}" APPEND ${BUILD_MATLABPATH})
set (BUILD_MATLABPATH)
endif ()
# generate executable for use in build tree
basis_generate_matlab_executable (
"${OUTPUT_FILE}"
COMMAND "${MATLAB_COMMAND}"
STARTUP "${BUILD_STARTUP_FILE}"
MATLABPATH ${BUILD_MATLABPATH}
)
if (INSTALL_FILE)
# write startup.m file for build installation
if (INSTALL_STARTUP_FILE)
file (WRITE "${INSTALL_STARTUP_FILE}"
"% DO NOT edit. This file is generated by BASIS.
[mfiledir, ~, ~, ~] = fileparts(mfilename('fullpath'));\n")
basis_write_addpaths_mfile ("${INSTALL_STARTUP_FILE}" APPEND ${INSTALL_MATLABPATH})
set (INSTALL_MATLABPATH)
endif ()
# generate executable for installation
get_filename_component (INSTALL_STARTUP_NAME "${INSTALL_STARTUP_FILE}" NAME)
basis_generate_matlab_executable (
"${INSTALL_FILE}"
COMMAND "${MATLAB_COMMAND}"
STARTUP "${INSTALL_STARTUP_DIR}/${INSTALL_STARTUP_NAME}"
DESTINATION "${INSTALL_DIR}"
MATLABPATH ${INSTALL_MATLABPATH}
)
endif ()