Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
dfda79e6
Commit
dfda79e6
authored
Aug 04, 2013
by
hbristow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added passthrough of CXX FLAGS to mex compiler
parent
5e50791a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
10 deletions
+20
-10
CMakeLists.txt
modules/matlab/CMakeLists.txt
+11
-2
compile.cmake
modules/matlab/compile.cmake
+3
-3
mxarray.hpp
modules/matlab/include/mxarray.hpp
+6
-5
No files found.
modules/matlab/CMakeLists.txt
View file @
dfda79e6
...
@@ -65,6 +65,7 @@ if (BUILD_TESTS)
...
@@ -65,6 +65,7 @@ if (BUILD_TESTS)
endif
()
endif
()
include_directories
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
include_directories
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Configure time components
# Configure time components
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
...
@@ -84,6 +85,10 @@ endforeach()
...
@@ -84,6 +85,10 @@ endforeach()
# add extra headers by hand
# add extra headers by hand
list
(
APPEND opencv_hdrs
"
${
OPENCV_MODULE_opencv_core_LOCATION
}
/include/opencv2/core/base.hpp"
)
list
(
APPEND opencv_hdrs
"
${
OPENCV_MODULE_opencv_core_LOCATION
}
/include/opencv2/core/base.hpp"
)
# pass the OPENCV_CXX_EXTRA_FLAGS through to the mex compiler
# remove the visibility modifiers, so the mex gateway is visible
string
(
REGEX REPLACE
"[^
\
]*visibility[^
\
]*"
""
MEX_CXX_FLAGS
"
${
OPENCV_EXTRA_FLAGS
}
${
OPENCV_EXTRA_CXX_FLAGS
}
"
)
# Configure checks
# Configure checks
# Check to see whether the generator and the mex compiler are working.
# Check to see whether the generator and the mex compiler are working.
# The checks currently test:
# The checks currently test:
...
@@ -113,8 +118,8 @@ if (NOT MEX_WORKS)
...
@@ -113,8 +118,8 @@ if (NOT MEX_WORKS)
# attempt to compile a gateway using mex
# attempt to compile a gateway using mex
message
(
STATUS
"Trying to compile mex file"
)
message
(
STATUS
"Trying to compile mex file"
)
execute_process
(
execute_process
(
COMMAND
${
MATLAB_MEX_SCRIPT
}
${
MEX_OPTS
}
${
MEX_INCLUDE_DIRS
}
COMMAND
${
MATLAB_MEX_SCRIPT
}
${
MEX_OPTS
}
"CXXFLAGS=
\$
CXXFLAGS
${
MEX_CXXFLAGS
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/test_compiler.cpp
${
MEX_INCLUDE_DIRS
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/test_compiler.cpp
WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
/junk
WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
/junk
ERROR_VARIABLE MEX_ERROR
ERROR_VARIABLE MEX_ERROR
OUTPUT_QUIET
OUTPUT_QUIET
...
@@ -133,6 +138,7 @@ endif()
...
@@ -133,6 +138,7 @@ endif()
set_property
(
GLOBAL PROPERTY MEX_WORKS TRUE
)
set_property
(
GLOBAL PROPERTY MEX_WORKS TRUE
)
set
(
MEX_WORKS True CACHE BOOL ADVANCED
)
set
(
MEX_WORKS True CACHE BOOL ADVANCED
)
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Build time components
# Build time components
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
...
@@ -142,6 +148,7 @@ set(MEX_WORKS True CACHE BOOL ADVANCED)
...
@@ -142,6 +148,7 @@ set(MEX_WORKS True CACHE BOOL ADVANCED)
# (which do the real work) only when they're outdated
# (which do the real work) only when they're outdated
set
(
GENERATE_PROXY
${
CMAKE_CURRENT_BINARY_DIR
}
/generate.proxy
)
set
(
GENERATE_PROXY
${
CMAKE_CURRENT_BINARY_DIR
}
/generate.proxy
)
set
(
COMPILE_PROXY
${
CMAKE_CURRENT_BINARY_DIR
}
/compile.proxy
)
set
(
COMPILE_PROXY
${
CMAKE_CURRENT_BINARY_DIR
}
/compile.proxy
)
# TODO: Remove following line before merging with master
file
(
REMOVE
${
GENERATE_PROXY
}
${
COMPILE_PROXY
}
)
file
(
REMOVE
${
GENERATE_PROXY
}
${
COMPILE_PROXY
}
)
# generate
# generate
...
@@ -164,6 +171,7 @@ add_custom_command(
...
@@ -164,6 +171,7 @@ add_custom_command(
COMMAND
${
CMAKE_COMMAND
}
-DMATLAB_MEX_SCRIPT=
${
MATLAB_MEX_SCRIPT
}
COMMAND
${
CMAKE_COMMAND
}
-DMATLAB_MEX_SCRIPT=
${
MATLAB_MEX_SCRIPT
}
-DMATLAB_MEXEXT=
${
MATLAB_MEXEXT
}
-DMATLAB_MEXEXT=
${
MATLAB_MEXEXT
}
-DMEX_OPTS=
${
MEX_OPTS
}
-DMEX_OPTS=
${
MEX_OPTS
}
-DMEX_CXXFLAGS=
${
MEX_CXXFLAGS
}
-DMEX_INCLUDE_DIRS=
"
${
MEX_INCLUDE_DIRS
}
"
-DMEX_INCLUDE_DIRS=
"
${
MEX_INCLUDE_DIRS
}
"
-DMEX_LIB_DIR=
${
MEX_LIB_DIR
}
-DMEX_LIB_DIR=
${
MEX_LIB_DIR
}
-DMEX_LIBS=
"
${
MEX_LIBS
}
"
-DMEX_LIBS=
"
${
MEX_LIBS
}
"
...
@@ -182,6 +190,7 @@ if (ENABLE_SOLUTION_FOLDERS)
...
@@ -182,6 +190,7 @@ if (ENABLE_SOLUTION_FOLDERS)
set_target_properties
(
${
the_module
}
PROPERTIES FOLDER
"modules"
)
set_target_properties
(
${
the_module
}
PROPERTIES FOLDER
"modules"
)
endif
()
endif
()
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Install time components
# Install time components
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
...
...
modules/matlab/compile.cmake
View file @
dfda79e6
...
@@ -3,7 +3,6 @@ macro(listify OUT_LIST IN_STRING)
...
@@ -3,7 +3,6 @@ macro(listify OUT_LIST IN_STRING)
endmacro
()
endmacro
()
listify
(
MEX_INCLUDE_DIRS_LIST
${
MEX_INCLUDE_DIRS
}
)
listify
(
MEX_INCLUDE_DIRS_LIST
${
MEX_INCLUDE_DIRS
}
)
set
(
MEX_CXXFLAGS
"CXXFLAGS=
\$
CXXFLAGS -msse -msse2 -msse3 -msse4.1 -msse4.2 -pedantic -Wall -Wextra -Weffc++ -Wno-unused-parameter -Wold-style-cast -Wshadow -Wmissing-declarations -Wmissing-include-dirs -Wnon-virtual-dtor -Wno-newline-eof"
)
file
(
GLOB SOURCE_FILES
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/*.cpp"
)
file
(
GLOB SOURCE_FILES
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/*.cpp"
)
foreach
(
SOURCE_FILE
${
SOURCE_FILES
}
)
foreach
(
SOURCE_FILE
${
SOURCE_FILES
}
)
# strip out the filename
# strip out the filename
...
@@ -11,13 +10,14 @@ foreach(SOURCE_FILE ${SOURCE_FILES})
...
@@ -11,13 +10,14 @@ foreach(SOURCE_FILE ${SOURCE_FILES})
# compie the source file using mex
# compie the source file using mex
if
(
NOT EXISTS
${
CMAKE_CURRENT_BINARY_DIR
}
/+cv/
${
FILENAME
}
.
${
MATLAB_MEXEXT
}
)
if
(
NOT EXISTS
${
CMAKE_CURRENT_BINARY_DIR
}
/+cv/
${
FILENAME
}
.
${
MATLAB_MEXEXT
}
)
execute_process
(
execute_process
(
COMMAND
${
MATLAB_MEX_SCRIPT
}
"
${
MEX_CXXFLAGS
}
"
${
MEX_INCLUDE_DIRS_LIST
}
COMMAND
${
MATLAB_MEX_SCRIPT
}
${
MEX_OPTS
}
"CXXFLAGS=
\$
CXXFLAGS
${
MEX_CXXFLAGS
}
"
${
MEX_INCLUDE_DIRS_LIST
}
${
MEX_LIB_DIR
}
${
MEX_LIBS
}
${
SOURCE_FILE
}
${
MEX_LIB_DIR
}
${
MEX_LIBS
}
${
SOURCE_FILE
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/+cv
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/+cv
OUTPUT_QUIET
ERROR_VARIABLE FAILED
ERROR_VARIABLE FAILED
)
)
endif
()
endif
()
# TODO: If a mex file fails to cmpile, should we error out?
# TODO: If a mex file fails to c
o
mpile, should we error out?
if
(
FAILED
)
if
(
FAILED
)
message
(
FATAL_ERROR
"Failed to compile
${
FILENAME
}
:
${
FAILED
}
"
)
message
(
FATAL_ERROR
"Failed to compile
${
FILENAME
}
:
${
FAILED
}
"
)
endif
()
endif
()
...
...
modules/matlab/include/mxarray.hpp
View file @
dfda79e6
#ifndef OPENCV_MXARRAY_HPP_
#ifndef OPENCV_MXARRAY_HPP_
#define OPENCV_MXARRAY_HPP_
#define OPENCV_MXARRAY_HPP_
#include "mex.h"
#include <stdint.h>
#include "transpose.hpp"
#include <vector>
#include <string>
#include <string>
#include <vector>
#include <opencv2/core.hpp>
#include <opencv2/core.hpp>
#include "mex.h"
#include "transpose.hpp"
/*
/*
* All recent versions of Matlab ship with the MKL library which contains
* All recent versions of Matlab ship with the MKL library which contains
...
@@ -34,7 +35,7 @@ extern "C" {
...
@@ -34,7 +35,7 @@ extern "C" {
* expression fails, an error is raised and the mex function returns
* expression fails, an error is raised and the mex function returns
* to Matlab, otherwise this function does nothing
* to Matlab, otherwise this function does nothing
*/
*/
void
conditionalError
(
bool
expr
,
const
std
::
string
&
str
)
{
static
void
conditionalError
(
bool
expr
,
const
std
::
string
&
str
)
{
if
(
!
expr
)
mexErrMsgTxt
(
std
::
string
(
"condition failed: "
).
append
(
str
).
c_str
());
if
(
!
expr
)
mexErrMsgTxt
(
std
::
string
(
"condition failed: "
).
append
(
str
).
c_str
());
}
}
...
@@ -43,7 +44,7 @@ void conditionalError(bool expr, const std::string& str) {
...
@@ -43,7 +44,7 @@ void conditionalError(bool expr, const std::string& str) {
*
*
* This function is a wrapper around mexErrMsgTxt
* This function is a wrapper around mexErrMsgTxt
*/
*/
void
error
(
const
std
::
string
&
str
)
{
static
void
error
(
const
std
::
string
&
str
)
{
mexErrMsgTxt
(
str
.
c_str
());
mexErrMsgTxt
(
str
.
c_str
());
}
}
...
...
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