Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Richard Torenvliet
eos
Commits
19c69c5e
Commit
19c69c5e
authored
Dec 03, 2016
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set up simple CMake infrastructure to build Matlab mex files
parent
32624ba4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
0 deletions
+86
-0
CMakeLists.txt
CMakeLists.txt
+4
-0
matlab/CMakeLists.txt
matlab/CMakeLists.txt
+21
-0
matlab/private/test.cpp
matlab/private/test.cpp
+61
-0
No files found.
CMakeLists.txt
View file @
19c69c5e
...
@@ -180,3 +180,7 @@ endif()
...
@@ -180,3 +180,7 @@ endif()
if
(
BUILD_DOCUMENTATION
)
if
(
BUILD_DOCUMENTATION
)
add_subdirectory
(
doc
)
add_subdirectory
(
doc
)
endif
()
endif
()
if
(
GENERATE_MATLAB_BINDINGS
)
add_subdirectory
(
matlab
)
endif
()
matlab/CMakeLists.txt
0 → 100644
View file @
19c69c5e
project
(
matlab-bindings
)
cmake_minimum_required
(
VERSION 3.7.0
)
# If Matlab_ROOT_DIR is set, the Matlab at that location is used.
find_package
(
Matlab COMPONENTS MX_LIBRARY REQUIRED
)
# See: https://cmake.org/cmake/help/v3.7/module/FindMatlab.html?highlight=findmatlab#command:matlab_add_mex
matlab_add_mex
(
NAME eos_matlab
#[EXECUTABLE | MODULE | SHARED] # SHARED is the default.
SRC private/test.cpp
#[OUTPUT_NAME output_name]
#[DOCUMENTATION file.txt]
#[LINK_TO target1 target2 ...] # OpenCV etc?
#[...]
)
target_include_directories
(
eos_matlab PRIVATE
${
CMAKE_SOURCE_DIR
}
/3rdparty/mexplus/include
)
# Todo: Look at opencv mex... eg Rect, the .c file. Do they do all the dispatching in mexFunc()?
# Also this may have wrapping for std::vector<T>: https://github.com/kyamagu/mexopencv/blob/master/include/MxArray.hpp
matlab/private/test.cpp
0 → 100644
View file @
19c69c5e
/*
* eos - A 3D Morphable Model fitting library written in modern C++11/14.
*
* File: matlab/private/test.cpp
*
* Copyright 2016 Patrik Huber
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mexplus.h"
#include "mex.h"
//#include "matrix.h"
#include <iostream>
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
int
nrhs
,
const
mxArray
*
prhs
[])
{
// Check for proper number of input and output arguments:
mexPrintf
(
"nlhs: %d, nrhs: %d
\n
"
,
nlhs
,
nrhs
);
if
(
nrhs
!=
2
)
{
mexErrMsgIdAndTxt
(
"eos:example:nargin"
,
"example requires two input arguments."
);
}
else
if
(
nlhs
>=
1
)
{
mexErrMsgIdAndTxt
(
"eos:example:nargout"
,
"example requires no output argument."
);
}
double
*
vin1
,
*
vin2
;
vin1
=
(
double
*
)
mxGetPr
(
prhs
[
0
]);
vin2
=
(
double
*
)
mxGetPr
(
prhs
[
1
]);
mexPrintf
(
"%f, %f
\n
"
,
*
vin1
,
*
vin2
);
};
void
func
()
{
int
x
=
4
;
};
int
func1
()
{
return
5
;
};
class
MyClass
{
public:
MyClass
()
=
default
;
int
test
()
{
return
6
;
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment