[cmake-developers] [CMake 0015786]: FindMatlab / matlab_add_mex does not work with 64-bit Matlab Version - Version detected as 32-bit Matlab

Mantis Bug Tracker mantis at public.kitware.com
Tue Oct 13 07:32:46 EDT 2015


The following issue has been SUBMITTED. 
====================================================================== 
https://public.kitware.com/Bug/view.php?id=15786 
====================================================================== 
Reported By:                Kerstin Keller
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15786
Category:                   Modules
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-10-13 07:32 EDT
Last Modified:              2015-10-13 07:32 EDT
====================================================================== 
Summary:                    FindMatlab / matlab_add_mex does not work with
64-bit Matlab Version - Version detected as 32-bit Matlab
Description: 
I have installed a 64bit Matlab Version (2015a) and CMake 3.3.2. 
When writing a simple CMakeLists.txt script

cmake_minimum_required(VERSION 3.3)
project(easy_example)
find_package(MATLAB REQUIRED)

include_directories(Matlab_INCLUDE_DIRS)

matlab_add_mex(
  NAME easy_example
  SRC easy_example.cpp
)

It cannot find the mex library. The Output is

-- Could NOT find Matlab (missing:  Matlab_MEX_LIBRARY) (found version "8.5")
CMake Error: The following variables are used in this project, but they are set
to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake
files:
Matlab_MEX_LIBRARY
    linked by target "easy_example" in directory
D:/SourceCode/Matlab/easy_example
-- Configuring incomplete, errors occurred!


Steps to Reproduce: 
Try to run 

find_package(MATLAB REQUIRED)

and then use

matlab_add_mex(
...
)

with a 64-bit Matlab Version.

Additional Information: 
Digging a little into the FindMatlab.cmake script, and outputted the directories
where it searches for the directories (l.1342).

message(STATUS "The include dir ${MATLAB_INCLUDE_DIR_TO_LOOK}")
message(STATUS "The library dir ${_matlab_lib_dir_for_search}")

This gives me the following Output

-- The include dir C:/LegacyApp/Matlab15a/R2015a_64bit/extern/include
-- The library dir
C:/LegacyApp/Matlab15a/R2015a_64bit/extern/lib/win32/microsoft

However, as my Matlab Version is 64bit, it library dir should be 
C:/LegacyApp/Matlab15a/R2015a_64bit/extern/lib/win64/microsoft

This can be traced back to line 1276, where I added another message Output:
if(_matlab_64Build)
  set(_matlab_current_suffix ${_matlab_bin_suffix_64bits})
  message(STATUS "64bit Matlab")
else()
  set(_matlab_current_suffix ${_matlab_bin_suffix_32bits})
  message(STATUS "32bit Matlab")
endif()

CMake falsely detects a 32bit Matlab Version
-- 32bit Matlab

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-10-13 07:32 Kerstin Keller New Issue                                    
======================================================================



More information about the cmake-developers mailing list