Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindMatlab: Provides initial support for Fortran MEX #375

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions Modules/FindMatlab.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,12 @@ function(matlab_add_mex)
else()
# If neither C or CXX is enabled, warn because we cannot add the source.
# TODO: add support for fortran mex files
message(WARNING "[MATLAB] matlab_add_mex requires that at least C or CXX are enabled languages")
if(DEFINED FORTRANMEX)
set(MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/fortran_mexapi_version.F")
message("[MATLAB] matlab_add_mex now build fortran mex files")
else()
message(WARNING "[MATLAB] matlab_add_mex requires that at least C or CXX are enabled languages")
endif()
endif()
endif()

Expand Down Expand Up @@ -1246,11 +1251,17 @@ function(matlab_add_mex)
if(WIN32)

if (MSVC)

if(DEFINED FORTRANMEX)
string(APPEND _link_flags " /EXPORT:MEXFUNCTION")
if(NOT Matlab_VERSION_STRING VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, export version
string(APPEND _link_flags " /EXPORT:MEXFILEREQUIREDAPIVERSION")
endif()
else()
string(APPEND _link_flags " /EXPORT:mexFunction")
if(NOT Matlab_VERSION_STRING VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, export version
string(APPEND _link_flags " /EXPORT:mexfilerequiredapiversion")
endif()
string(APPEND _link_flags " /EXPORT:mexfilerequiredapiversion")
endif()
endif()

set_property(TARGET ${${prefix}_NAME} APPEND PROPERTY LINK_FLAGS ${_link_flags})

Expand Down