Closed WinterAlexander closed 4 years ago
Interestingly, if I delete the FindMatlab.cmake
of the project then the terminal output changes:
-- Creating target: igl::core (igl)
CMake Error at C:/Users/Alexander Winter/MATLAB Drive/computer-animation-nserc/Bartels/cmake/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find Matlab (missing: Matlab_MEX_LIBRARY) (found version
"unknown")
Call Stack (most recent call first):
C:/Users/Alexander Winter/MATLAB Drive/computer-animation-nserc/Bartels/cmake/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
C:/Users/Alexander Winter/MATLAB Drive/computer-animation-nserc/Bartels/extern/libigl/cmake/FindMATLAB.cmake:1513 (find_package_handle_standard_args)
CMakeLists.txt:24 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Alexander Winter/MATLAB Drive/computer-animation-nserc/Bartels/matlab/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Alexander Winter/MATLAB Drive/computer-animation-nserc/Bartels/matlab/cmake-build-debug/CMakeFiles/CMakeError.log".
[Finished]
Hinting that it now finds Matlab_MX_LIBRARY which it previously didn't find.
hmmmmm I think this is because Cmake hardcodes compatible versions of matlab in FindMATLAB.cmake. The bartels version of FindMatlab probably doesn't include matlab 2020
Which version of CMAke are you using currently ?
@dilevin I am currently using the latest version, 3.17.2.
and what system are you compiling this on ?
Windows 7 Profesionnal SP1
alright I copied over the newest FindMatlab module, with support for matlab2020. Hopefully that will fix this. I don't have MATLAB 2020 installed to test unfortunately :(
After pulling your change I get the same error as the first one (both Matlab_MEX_LIBRARY and Matlab_MX_LIBRARY missing).
I also tried updating Matlab to update 1 to see if it could fix up the paths or something. No luck
well that's disappointing.
I will investigate further.
I am currently installing the Matlab compiler. My matlab installation was pretty basic. Do you know if this add-on is needed or if any other add-ons are?
EDIT: Confirmed installing both the compiler and the SDK doesn't fix the issue
I haven't been able to reproduce this on my Windows setup.
This worked out of the box for me with Windows X and a trial version of MATLAB 2020a, using Visual Studio 2019 Community Edition as my compiler.
A few more questions to help debug:
Is matlab installed in the default directory ?
What build directory did you use for Bartels?
Matlab is installed under C:\Program Files\MATLAB\R2020a
Installing R2019b and setting it as the default matlab didn't fix the issue
I'm using MinGW as the compiler and using CLion to run the command. The command is
"C:\Program Files\CMake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" "C:\Users\Alexander Winter\MATLAB Drive\computer-animation-nserc\Bartels\matlab"
The build directory (the directory in which cmake outputs its stuff) was mistakenly "cmake-build-debug" instead of "build" (IDE default). After changing it to build, I get this error:
"C:\Program Files\CMake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" "C:\Users\Alexander Winter\MATLAB Drive\computer-animation-nserc\Bartels\matlab"
-- Creating target: igl::core (igl)
CMake Error at C:/Users/Alexander Winter/MATLAB Drive/computer-animation-nserc/Bartels/cmake/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find Matlab (missing: Matlab_MEX_LIBRARY Matlab_MX_LIBRARY
Matlab_ENGINE_LIBRARY Matlab_DATAARRAY_LIBRARY) (found version "9.8")
Call Stack (most recent call first):
C:/Users/Alexander Winter/MATLAB Drive/computer-animation-nserc/Bartels/cmake/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
C:/Users/Alexander Winter/MATLAB Drive/computer-animation-nserc/Bartels/cmake/FindMatlab.cmake:1803 (find_package_handle_standard_args)
CMakeLists.txt:24 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Alexander Winter/MATLAB Drive/computer-animation-nserc/Bartels/matlab/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Alexander Winter/MATLAB Drive/computer-animation-nserc/Bartels/matlab/build/CMakeFiles/CMakeError.log".
[Finished]
Weirdly enough because of this it doesn't find 2 more macros but it has found the version.
It works! The problem was how cmake detects if the machine is 64 bits or 32 bits. The code (FindMatlab.cmake line 1566) looks like this:
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(_matlab_64Build FALSE)
else()
set(_matlab_64Build TRUE)
endif()
This turns out not to work for me, replacing this by set(_matlab_64Build TRUE)
fixed the problem for me. Now, this is probably due to the fact my cmake somehow runs in 32 bit because of minGW or cygwin, yet this is overall a dumb way to detect the architecture of the installation. (One could have matlab installed in 32 bits running on a 64 bits machine with a 64 bits cmake...)
Anyway, glad this is solved and I'll probably send a PR to cmake to fix their FindMatlab.cmake script. (The better way would be to read the directory, instead of assuming and getting an error for the wrong directory name).
oh great, I'm glad you found the solution. Since it works with the standard Windows build tools (Visual Studio) it's likely something to do with MinGW. I'll keep this issue open so that other people with your configuration can find the solution to their problem.
Turns out libigl doesn't support MinGW or cygwin, so althoug the Cmake runs the compilation fails. So it's not so useful in the end.
That's too bad. I guess, for now, only Visual Studio is supported on Windows.
Terminal output:
CMakeError.log
CMakeOutput.log
One potential source of the issue I identified with Matlab R2020a is in the file FindMatlab.cmake at line 243. It should include "R2020a=9.8". Yet, adding this line does not fix the issue nor change the terminal output.
I'm not sure why the file FindMatlab.cmake is in the project though as it should be included in cmake. In this commit for cmake they added support for matlab R2020a. https://github.com/Kitware/CMake/commit/75331a4578111e580b6b528a731adedbf5ba9597 I do not know at the moment if they did something else that would make it work. Perhaps there's a way to ask cmake to use its own FindMatlab.cmake rather than the (outdated) one in the project?
Best, Alexander