robotology / blockfactory

A tiny framework to wrap algorithms for dataflow programming
https://robotology.github.io/blockfactory
GNU Lesser General Public License v2.1
40 stars 16 forks source link

CMake Error related to MatLab Libraries with MATLAB 2021a/2022a on Windows 10 Version 21H2 with CMake 3.22.3 #68

Closed kevinwidjaja21 closed 2 years ago

kevinwidjaja21 commented 2 years ago

So, I have been trying to compile BlockFactory with Matlab R2021a and keep getting the following error.

PS F:\simconnect-monitor\blockfactory> cmake -S . -B build
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19044.
-- Could NOT find Matlab (missing: Matlab_MEX_LIBRARY Matlab_MX_LIBRARY ENG_LIBRARY) (found version "9.10")
CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Matlab (missing: Matlab_MEX_LIBRARY Matlab_MX_LIBRARY
  MX_LIBRARY) (found version "9.10")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindMatlab.cmake:1872 (find_package_handle_standard_args)
  deps/mxpp/CMakeLists.txt:45 (find_package)

-- Configuring incomplete, errors occurred!
See also "F:/simconnect-monitor/blockfactory/build/CMakeFiles/CMakeOutput.log".

I have already tried also with Matlab R2022a (which I notice is not listed by FindMatlab.cmake so I installed R2021a. Still haven't uninstalled R2022a). I am on Windows 10 and have tried to add matlabr2021a_root\extern\lib\win64\microsoft to the PATH environment variable.

Sorry if the question seems trivial but I don't know what to do.

traversaro commented 2 years ago

Hi @kevinwidjaja21 ! I am away from keyboard now, but two things to check are:

kevinwidjaja21 commented 2 years ago

Hi @traversaro . So, I have tried adding set(Matlab_ROOT_DIR "D:/MATLAB/R2021a") to FindMatlab.cmake just after include(CheckCCompilerFlag). I also tried to add -D Matlab_ROOT_DIR="D:/MATLAB/R2021a". No difference, still the same issue. I have confirmed that it is are the correct path to the MatLab root and I confirmed that I can launch Matlab through PowerShell, command prompt, and Git Bash.

traversaro commented 2 years ago

I also tried to add -D Matlab_ROOT_DIR="D:/MATLAB/R2021a".

There should be no space betwween -D and Matlab_ROOT_DIR. Anyhow, perhaps this is not the issue. Can you share the CMakeCache.txt from the build directory to understand which could be the problem?

kevinwidjaja21 commented 2 years ago

Ok, this is what's inside CMakeCache.txt

# This is the CMakeCache file.
# For build in directory: f:/simconnect-monitor/blockfactory/build
# It was generated by CMake: C:/Program Files/CMake/bin/cmake.exe
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
# VALUE is the current value for the KEY.

########################
# EXTERNAL cache entries
########################

//Compile BlockFactory as a shared library
BUILD_SHARED_LIBS:BOOL=ON

//Create tests using CMake
BUILD_TESTING:BOOL=OFF

//Path to a program.
CMAKE_AR:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/lib.exe

//Semicolon separated list of supported configuration types, only
// supports Debug, Release, MinSizeRel, and RelWithDebInfo, anything
// else will be ignored.
CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release;MinSizeRel;RelWithDebInfo

//Flags used by the CXX compiler during all build types.
CMAKE_CXX_FLAGS:STRING=/DWIN32 /D_WINDOWS /W3 /GR /EHsc

//Flags used by the CXX compiler during DEBUG builds.
CMAKE_CXX_FLAGS_DEBUG:STRING=/MDd /Zi /Ob0 /Od /RTC1

//Flags used by the CXX compiler during MINSIZEREL builds.
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /DNDEBUG

//Flags used by the CXX compiler during RELEASE builds.
CMAKE_CXX_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /DNDEBUG

//Flags used by the CXX compiler during RELWITHDEBINFO builds.
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /DNDEBUG

//Libraries linked by default with all C++ applications.
CMAKE_CXX_STANDARD_LIBRARIES:STRING=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib

//Flags used by the linker during all build types.
CMAKE_EXE_LINKER_FLAGS:STRING=/machine:X86

//Flags used by the linker during DEBUG builds.
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL

//Flags used by the linker during MINSIZEREL builds.
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO

//Flags used by the linker during RELEASE builds.
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO

//Flags used by the linker during RELWITHDEBINFO builds.
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL

//User executables (bin)
CMAKE_INSTALL_BINDIR:PATH=bin

//Read-only architecture-independent data (DATAROOTDIR)
CMAKE_INSTALL_DATADIR:PATH=

//Read-only architecture-independent data root (share)
CMAKE_INSTALL_DATAROOTDIR:PATH=share

//Documentation root (DATAROOTDIR/doc/PROJECT_NAME)
CMAKE_INSTALL_DOCDIR:PATH=

//C header files (include)
CMAKE_INSTALL_INCLUDEDIR:PATH=include

//Info documentation (DATAROOTDIR/info)
CMAKE_INSTALL_INFODIR:PATH=

//Object code libraries (lib)
CMAKE_INSTALL_LIBDIR:PATH=lib

//Program executables (libexec)
CMAKE_INSTALL_LIBEXECDIR:PATH=libexec

//Locale-dependent data (DATAROOTDIR/locale)
CMAKE_INSTALL_LOCALEDIR:PATH=

//Modifiable single-machine data (var)
CMAKE_INSTALL_LOCALSTATEDIR:PATH=var

//Man documentation (DATAROOTDIR/man)
CMAKE_INSTALL_MANDIR:PATH=

//C header files for non-gcc (/usr/include)
CMAKE_INSTALL_OLDINCLUDEDIR:PATH=/usr/include

//Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX:PATH=F:/simconnect-monitor/test_build

//Run-time variable data (LOCALSTATEDIR/run)
CMAKE_INSTALL_RUNSTATEDIR:PATH=

//System admin executables (sbin)
CMAKE_INSTALL_SBINDIR:PATH=sbin

//Modifiable architecture-independent data (com)
CMAKE_INSTALL_SHAREDSTATEDIR:PATH=com

//Read-only single-machine data (etc)
CMAKE_INSTALL_SYSCONFDIR:PATH=etc

//Path to a program.
CMAKE_LINKER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/link.exe

//Flags used by the linker during the creation of modules during
// all build types.
CMAKE_MODULE_LINKER_FLAGS:STRING=/machine:X86

//Flags used by the linker during the creation of modules during
// DEBUG builds.
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL

//Flags used by the linker during the creation of modules during
// MINSIZEREL builds.
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO

//Flags used by the linker during the creation of modules during
// RELEASE builds.
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO

//Flags used by the linker during the creation of modules during
// RELWITHDEBINFO builds.
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL

//Path to a program.
CMAKE_MT:FILEPATH=CMAKE_MT-NOTFOUND

//Value Computed by CMake
CMAKE_PROJECT_DESCRIPTION:STATIC=

//Value Computed by CMake
CMAKE_PROJECT_HOMEPAGE_URL:STATIC=

//Value Computed by CMake
CMAKE_PROJECT_NAME:STATIC=blockfactory

//Value Computed by CMake
CMAKE_PROJECT_VERSION:STATIC=0.8.2

//Value Computed by CMake
CMAKE_PROJECT_VERSION_MAJOR:STATIC=0

//Value Computed by CMake
CMAKE_PROJECT_VERSION_MINOR:STATIC=8

//Value Computed by CMake
CMAKE_PROJECT_VERSION_PATCH:STATIC=2

//Value Computed by CMake
CMAKE_PROJECT_VERSION_TWEAK:STATIC=

//RC compiler
CMAKE_RC_COMPILER:FILEPATH=rc

//Flags for Windows Resource Compiler during all build types.
CMAKE_RC_FLAGS:STRING=-DWIN32

//Flags for Windows Resource Compiler during DEBUG builds.
CMAKE_RC_FLAGS_DEBUG:STRING=-D_DEBUG

//Flags for Windows Resource Compiler during MINSIZEREL builds.
CMAKE_RC_FLAGS_MINSIZEREL:STRING=

//Flags for Windows Resource Compiler during RELEASE builds.
CMAKE_RC_FLAGS_RELEASE:STRING=

//Flags for Windows Resource Compiler during RELWITHDEBINFO builds.
CMAKE_RC_FLAGS_RELWITHDEBINFO:STRING=

//Flags used by the linker during the creation of shared libraries
// during all build types.
CMAKE_SHARED_LINKER_FLAGS:STRING=/machine:X86

//Flags used by the linker during the creation of shared libraries
// during DEBUG builds.
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL

//Flags used by the linker during the creation of shared libraries
// during MINSIZEREL builds.
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO

//Flags used by the linker during the creation of shared libraries
// during RELEASE builds.
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO

//Flags used by the linker during the creation of shared libraries
// during RELWITHDEBINFO builds.
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL

//If set, runtime paths are not added when installing shared libraries,
// but are added when building.
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO

//If set, runtime paths are not added when using shared libraries.
CMAKE_SKIP_RPATH:BOOL=NO

//Flags used by the linker during the creation of static libraries
// during all build types.
CMAKE_STATIC_LINKER_FLAGS:STRING=/machine:X86

//Flags used by the linker during the creation of static libraries
// during DEBUG builds.
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=

//Flags used by the linker during the creation of static libraries
// during MINSIZEREL builds.
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=

//Flags used by the linker during the creation of static libraries
// during RELEASE builds.
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=

//Flags used by the linker during the creation of static libraries
// during RELWITHDEBINFO builds.
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=

//If this value is on, makefiles will be generated without the
// .SILENT directive, and all commands will be echoed to the console
// during the make.  This is useful for debugging only. With Visual
// Studio IDE projects all commands are done without /nologo.
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE

//Enable verbose warnings
ENABLE_WARNINGS:BOOL=ON

//Always produce ANSI-colored output (GNU/Clang only).
FORCE_COLORED_OUTPUT:BOOL=ON

//MatlabDataArray Library
Matlab_DATAARRAY_LIBRARY:FILEPATH=Matlab_DATAARRAY_LIBRARY-NOTFOUND

//MatlabEngine Library
Matlab_ENGINE_LIBRARY:FILEPATH=Matlab_ENGINE_LIBRARY-NOTFOUND

//Path to a library.
Matlab_ENG_LIBRARY:FILEPATH=Matlab_ENG_LIBRARY-NOTFOUND

//Path to a file.
Matlab_INCLUDE_DIRS:PATH=D:/MATLAB/R2021a/extern/include

//Extensions for the mex targets (automatically given by Matlab)
Matlab_MEX_EXTENSION:STRING=mexw64

//Path to a library.
Matlab_MEX_LIBRARY:FILEPATH=Matlab_MEX_LIBRARY-NOTFOUND

//Path to a library.
Matlab_MX_LIBRARY:FILEPATH=Matlab_MX_LIBRARY-NOTFOUND

//Matlab installation root path
Matlab_ROOT_DIR:PATH=D:/MATLAB/R2021a

//Path to a file.
Matlab_SIMULINK_INCLUDE_DIR:PATH=D:/MATLAB/R2021a/simulink/include

//Compile also Matlab-related components
USES_MATLAB:BOOL=ON

//Value Computed by CMake
blockfactory_BINARY_DIR:STATIC=F:/simconnect-monitor/blockfactory/build

//Value Computed by CMake
blockfactory_IS_TOP_LEVEL:STATIC=ON

//Value Computed by CMake
blockfactory_SOURCE_DIR:STATIC=F:/simconnect-monitor/blockfactory

//Value Computed by CMake
mxpp_BINARY_DIR:STATIC=F:/simconnect-monitor/blockfactory/build/deps/mxpp

//Value Computed by CMake
mxpp_IS_TOP_LEVEL:STATIC=OFF

//Value Computed by CMake
mxpp_SOURCE_DIR:STATIC=F:/simconnect-monitor/blockfactory/deps/mxpp

########################
# INTERNAL cache entries
########################

//ADVANCED property for variable: CMAKE_AR
CMAKE_AR-ADVANCED:INTERNAL=1
//This is the directory where this CMakeCache.txt was created
CMAKE_CACHEFILE_DIR:INTERNAL=f:/simconnect-monitor/blockfactory/build
//Major version of cmake used to create the current loaded cache
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
//Minor version of cmake used to create the current loaded cache
CMAKE_CACHE_MINOR_VERSION:INTERNAL=22
//Patch version of cmake used to create the current loaded cache
CMAKE_CACHE_PATCH_VERSION:INTERNAL=3
//Path to CMake executable.
CMAKE_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cmake.exe
//Path to cpack program executable.
CMAKE_CPACK_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cpack.exe
//Path to ctest program executable.
CMAKE_CTEST_COMMAND:INTERNAL=C:/Program Files/CMake/bin/ctest.exe
//ADVANCED property for variable: CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_STANDARD_LIBRARIES
CMAKE_CXX_STANDARD_LIBRARIES-ADVANCED:INTERNAL=1
//Executable file format
CMAKE_EXECUTABLE_FORMAT:INTERNAL=Unknown
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//Name of external makefile project generator.
CMAKE_EXTRA_GENERATOR:INTERNAL=
//Name of generator.
CMAKE_GENERATOR:INTERNAL=Visual Studio 15 2017
//Generator instance identifier.
CMAKE_GENERATOR_INSTANCE:INTERNAL=C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools
//Name of generator platform.
CMAKE_GENERATOR_PLATFORM:INTERNAL=
//Name of generator toolset.
CMAKE_GENERATOR_TOOLSET:INTERNAL=
//Source directory with the top level CMakeLists.txt file for this
// project
CMAKE_HOME_DIRECTORY:INTERNAL=F:/simconnect-monitor/blockfactory
//ADVANCED property for variable: CMAKE_INSTALL_BINDIR
CMAKE_INSTALL_BINDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_DATADIR
CMAKE_INSTALL_DATADIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_DATAROOTDIR
CMAKE_INSTALL_DATAROOTDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_DOCDIR
CMAKE_INSTALL_DOCDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_INCLUDEDIR
CMAKE_INSTALL_INCLUDEDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_INFODIR
CMAKE_INSTALL_INFODIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_LIBDIR
CMAKE_INSTALL_LIBDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_LIBEXECDIR
CMAKE_INSTALL_LIBEXECDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_LOCALEDIR
CMAKE_INSTALL_LOCALEDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_LOCALSTATEDIR
CMAKE_INSTALL_LOCALSTATEDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_MANDIR
CMAKE_INSTALL_MANDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_OLDINCLUDEDIR
CMAKE_INSTALL_OLDINCLUDEDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_RUNSTATEDIR
CMAKE_INSTALL_RUNSTATEDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_SBINDIR
CMAKE_INSTALL_SBINDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_SHAREDSTATEDIR
CMAKE_INSTALL_SHAREDSTATEDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_SYSCONFDIR
CMAKE_INSTALL_SYSCONFDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_LINKER
CMAKE_LINKER-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MT
CMAKE_MT-ADVANCED:INTERNAL=1
//number of local generators
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=3
//Platform information initialized
CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
//noop for ranlib
CMAKE_RANLIB:INTERNAL=:
//ADVANCED property for variable: CMAKE_RC_COMPILER
CMAKE_RC_COMPILER-ADVANCED:INTERNAL=1
CMAKE_RC_COMPILER_WORKS:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_FLAGS
CMAKE_RC_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_FLAGS_DEBUG
CMAKE_RC_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_FLAGS_MINSIZEREL
CMAKE_RC_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_FLAGS_RELEASE
CMAKE_RC_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_FLAGS_RELWITHDEBINFO
CMAKE_RC_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//Path to CMake installation.
CMAKE_ROOT:INTERNAL=C:/Program Files/CMake/share/cmake-3.22
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SKIP_RPATH
CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: FORCE_COLORED_OUTPUT
FORCE_COLORED_OUTPUT-ADVANCED:INTERNAL=1
//internal matlab location for the discovered version
Matlab_PROG_VERSION_STRING_AUTO_DETECT:INTERNAL=D:/MATLAB/R2021a/bin/matlab.exe
//last Matlab root dir location
Matlab_ROOT_DIR_LAST_CACHED:INTERNAL=D:/MATLAB/R2021a
//Matlab version (automatically determined)
Matlab_VERSION_STRING_INTERNAL:INTERNAL=9.10
//CMAKE_INSTALL_PREFIX during last run
_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX:INTERNAL=F:/simconnect-monitor/test_build

And not sure it will help but this is what's inside CMakeOutput.log

The system is: Windows - 10.0.19044 - AMD64
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler:  
Build flags: 
Id flags:  

The output was:
0
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 23/3/2022 8:43:04 pm.
Project "F:\simconnect-monitor\blockfactory\build\CMakeFiles\3.22.3\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets).
PrepareForBuild:
  Creating directory "Debug\".
  Creating directory "Debug\CompilerIdCXX.tlog\".
InitializeBuildStatus:
  Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\CL.exe /c /nologo /W0 /WX- /diagnostics:classic /Od /Oy- /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc141.pdb" /Gd /TP /analyze- /FC /errorReport:queue CMakeCXXCompilerId.cpp
  CMakeCXXCompilerId.cpp
Link:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdCXX.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdCXX.lib" /MACHINE:X86 /SAFESEH Debug\CMakeCXXCompilerId.obj
  CompilerIdCXX.vcxproj -> F:\simconnect-monitor\blockfactory\build\CMakeFiles\3.22.3\CompilerIdCXX\.\CompilerIdCXX.exe
PostBuildEvent:
  for %%i in (cl.exe) do @echo CMAKE_CXX_COMPILER=%%~$PATH:i
  :VCEnd
  CMAKE_CXX_COMPILER=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86\cl.exe
FinalizeBuildStatus:
  Deleting file "Debug\CompilerIdCXX.tlog\unsuccessfulbuild".
  Touching "Debug\CompilerIdCXX.tlog\CompilerIdCXX.lastbuildstate".
Done Building Project "F:\simconnect-monitor\blockfactory\build\CMakeFiles\3.22.3\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets).

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.84

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CompilerIdCXX.exe"

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CompilerIdCXX.vcxproj"

The CXX compiler identification is MSVC, found in "F:/simconnect-monitor/blockfactory/build/CMakeFiles/3.22.3/CompilerIdCXX/CompilerIdCXX.exe"

Detecting CXX compiler ABI info compiled with the following output:
Change Dir: F:/simconnect-monitor/blockfactory/build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/MSBuild/15.0/Bin/MSBuild.exe cmTC_c2cb3.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:VisualStudioVersion=15.0 /v:m && Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework

Copyright (C) Microsoft Corporation. All rights reserved.

  Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27045 for x86

  Copyright (C) Microsoft Corporation.  All rights reserved.

  CMakeCXXCompilerABI.cpp

  cl /c /Zi /W3 /WX- /diagnostics:classic /Od /Ob0 /Oy- /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_c2cb3.dir\Debug\\" /Fd"cmTC_c2cb3.dir\Debug\vc141.pdb" /Gd /TP /analyze- /errorReport:queue "C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompilerABI.cpp"

  cmTC_c2cb3.vcxproj -> F:\simconnect-monitor\blockfactory\build\CMakeFiles\CMakeTmp\Debug\cmTC_c2cb3.exe
kevinwidjaja21 commented 2 years ago

So, it seems that somehow, _matlab_64Build return as false. I force it to always output 64-bit path by changing line 1658 of FindMatlab.cmake to set(_matlab_current_suffix ${_matlab_bin_suffix_64bits}) and it seems to resolve the issue.

But anotehr issue pop up when trying to run cmake --build . --target install

$ cmake --build . --target install
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Auto build dll exports
  shlibpp.vcxproj -> F:\simconnect-monitor\blockfactory\build\bin\Debug\shlibppd.dll
  Auto build dll exports
  Core.vcxproj -> F:\simconnect-monitor\blockfactory\build\bin\Debug\BlockFactoryCored.dll
  Auto build dll exports
     Creating library F:/simconnect-monitor/blockfactory/build/lib/Debug/mxppd.lib and object F:/simconnect-monitor/bl
  ockfactory/build/lib/Debug/mxppd.exp
MxArray.obj : error LNK2019: unresolved external symbol _mxFree_800 referenced in function "public: bool __thiscall mx
pp::MxArray::asString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?as
String@MxArray@mxpp@@QAE_NAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) [F:\simconnect-monitor\b 
lockfactory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxGetNumberOfDimensions_800 referenced in function "public: _ 
_thiscall mxpp::MxArray::MxArray(struct mxArray_tag const *,bool)" (??0MxArray@mxpp@@QAE@PBUmxArray_tag@@_N@Z) [F:\sim 
connect-monitor\blockfactory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxGetDimensions_800 referenced in function "public: __thiscal 
l mxpp::MxArray::MxArray(struct mxArray_tag const *,bool)" (??0MxArray@mxpp@@QAE@PBUmxArray_tag@@_N@Z) [F:\simconnect- 
monitor\blockfactory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxGetM_800 referenced in function "public: __thiscall mxpp::M 
xArray::MxArray(struct mxArray_tag const *,bool)" (??0MxArray@mxpp@@QAE@PBUmxArray_tag@@_N@Z) [F:\simconnect-monitor\b 
lockfactory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxGetFieldNameByNumber_800 referenced in function "public: bo 
ol __thiscall mxpp::MxArray::asMxStruct(class std::unordered_map<class std::basic_string<char,struct std::char_traits< 
char>,class std::allocator<char> >,class std::shared_ptr<class mxpp::MxArray>,struct std::hash<class std::basic_string 
<char,struct std::char_traits<char>,class std::allocator<char> > >,struct std::equal_to<class std::basic_string<char,s 
truct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_str 
ing<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::shared_ptr<class mxpp::MxArray>  
> > > &)" (?asMxStruct@MxArray@mxpp@@QAE_NAAV?$unordered_map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@ 
std@@V?$shared_ptr@VMxArray@mxpp@@@2@U?$hash@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@U?$equal 
_to@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char 
_traits@D@std@@V?$allocator@D@2@@std@@V?$shared_ptr@VMxArray@mxpp@@@2@@std@@@2@@std@@@Z) [F:\simconnect-monitor\blockf 
actory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxGetFieldByNumber_800 referenced in function "public: bool _ 
_thiscall mxpp::MxArray::asMxStruct(class std::unordered_map<class std::basic_string<char,struct std::char_traits<char 
>,class std::allocator<char> >,class std::shared_ptr<class mxpp::MxArray>,struct std::hash<class std::basic_string<cha 
r,struct std::char_traits<char>,class std::allocator<char> > >,struct std::equal_to<class std::basic_string<char,struc 
t std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string< 
char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::shared_ptr<class mxpp::MxArray> > >  
> &)" (?asMxStruct@MxArray@mxpp@@QAE_NAAV?$unordered_map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@ 
@V?$shared_ptr@VMxArray@mxpp@@@2@U?$hash@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@U?$equal_to@ 
V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_tra 
its@D@std@@V?$allocator@D@2@@std@@V?$shared_ptr@VMxArray@mxpp@@@2@@std@@@2@@std@@@Z) [F:\simconnect-monitor\blockfacto 
ry\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxGetCell_800 referenced in function "public: bool __thiscall 
 mxpp::MxArray::asMxCell(class std::vector<class std::shared_ptr<class mxpp::MxArray>,class std::allocator<class std:: 
shared_ptr<class mxpp::MxArray> > > &)" (?asMxCell@MxArray@mxpp@@QAE_NAAV?$vector@V?$shared_ptr@VMxArray@mxpp@@@std@@V 
?$allocator@V?$shared_ptr@VMxArray@mxpp@@@std@@@2@@std@@@Z) [F:\simconnect-monitor\blockfactory\build\deps\mxpp\mxpp.v 
cxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxGetClassID_800 referenced in function "public: __thiscall m 
xpp::MxArray::MxArray(struct mxArray_tag const *,bool)" (??0MxArray@mxpp@@QAE@PBUmxArray_tag@@_N@Z) [F:\simconnect-mon 
itor\blockfactory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxIsNumeric_800 referenced in function "public: bool __thisca 
ll mxpp::MxArray::Impl::asScalar(double &)" (?asScalar@Impl@MxArray@mxpp@@QAE_NAAN@Z) [F:\simconnect-monitor\blockfact 
ory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxIsScalar_800 referenced in function "public: __thiscall mxp 
p::MxArray::MxArray(struct mxArray_tag const *,bool)" (??0MxArray@mxpp@@QAE@PBUmxArray_tag@@_N@Z) [F:\simconnect-monit 
or\blockfactory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxIsComplex_800 referenced in function "public: bool __thisca 
ll mxpp::MxArray::asVectorDouble(class std::vector<double,class std::allocator<double> > &)" (?asVectorDouble@MxArray@ 
mxpp@@QAE_NAAV?$vector@NV?$allocator@N@std@@@std@@@Z) [F:\simconnect-monitor\blockfactory\build\deps\mxpp\mxpp.vcxproj 
]
MxArray.obj : error LNK2019: unresolved external symbol _mxIsDouble_800 referenced in function "public: bool __thiscal 
l mxpp::MxArray::asVectorDouble(class std::vector<double,class std::allocator<double> > &)" (?asVectorDouble@MxArray@m 
xpp@@QAE_NAAV?$vector@NV?$allocator@N@std@@@std@@@Z) [F:\simconnect-monitor\blockfactory\build\deps\mxpp\mxpp.vcxproj] 
MxArray.obj : error LNK2019: unresolved external symbol _mxGetNumberOfElements_800 referenced in function "public: __t 
hiscall mxpp::MxArray::MxArray(struct mxArray_tag const *,bool)" (??0MxArray@mxpp@@QAE@PBUmxArray_tag@@_N@Z) [F:\simco 
nnect-monitor\blockfactory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxGetScalar_800 referenced in function "public: bool __thisca 
ll mxpp::MxArray::Impl::asScalar(double &)" (?asScalar@Impl@MxArray@mxpp@@QAE_NAAN@Z) [F:\simconnect-monitor\blockfact 
ory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxGetN_800 referenced in function "public: __thiscall mxpp::M 
xArray::MxArray(struct mxArray_tag const *,bool)" (??0MxArray@mxpp@@QAE@PBUmxArray_tag@@_N@Z) [F:\simconnect-monitor\b 
lockfactory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxGetPr_800 referenced in function "public: bool __thiscall m 
xpp::MxArray::asVectorDouble(class std::vector<double,class std::allocator<double> > &)" (?asVectorDouble@MxArray@mxpp    
@@QAE_NAAV?$vector@NV?$allocator@N@std@@@std@@@Z) [F:\simconnect-monitor\blockfactory\build\deps\mxpp\mxpp.vcxproj]       
MxArray.obj : error LNK2019: unresolved external symbol _mxGetNumberOfFields_800 referenced in function "public: bool     
__thiscall mxpp::MxArray::asMxStruct(class std::unordered_map<class std::basic_string<char,struct std::char_traits<cha    
r>,class std::allocator<char> >,class std::shared_ptr<class mxpp::MxArray>,struct std::hash<class std::basic_string<ch    
ar,struct std::char_traits<char>,class std::allocator<char> > >,struct std::equal_to<class std::basic_string<char,stru    
ct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string    
<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::shared_ptr<class mxpp::MxArray> > >    
 > &)" (?asMxStruct@MxArray@mxpp@@QAE_NAAV?$unordered_map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std    
@@V?$shared_ptr@VMxArray@mxpp@@@2@U?$hash@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@U?$equal_to    
@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_tr    
aits@D@std@@V?$allocator@D@2@@std@@V?$shared_ptr@VMxArray@mxpp@@@2@@std@@@2@@std@@@Z) [F:\simconnect-monitor\blockfact    
ory\build\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxIsLogicalScalar_800 referenced in function "public: bool __    
thiscall mxpp::MxArray::asBool(bool &)" (?asBool@MxArray@mxpp@@QAE_NAA_N@Z) [F:\simconnect-monitor\blockfactory\build\    
deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxIsLogicalScalarTrue_800 referenced in function "public: boo    
l __thiscall mxpp::MxArray::asBool(bool &)" (?asBool@MxArray@mxpp@@QAE_NAA_N@Z) [F:\simconnect-monitor\blockfactory\bu    
ild\deps\mxpp\mxpp.vcxproj]
MxArray.obj : error LNK2019: unresolved external symbol _mxArrayToString_800 referenced in function "public: bool __th    
iscall mxpp::MxArray::asString(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >    
 &)" (?asString@MxArray@mxpp@@QAE_NAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) [F:\simconnect-    
monitor\blockfactory\build\deps\mxpp\mxpp.vcxproj]
D:\MATLAB\R2021a\extern\lib\win64\microsoft\libmx.lib : warning LNK4272: library machine type 'x64' conflicts with tar    
get machine type 'x86' [F:\simconnect-monitor\blockfactory\build\deps\mxpp\mxpp.vcxproj]
F:\simconnect-monitor\blockfactory\build\bin\Debug\mxppd.dll : fatal error LNK1120: 20 unresolved externals [F:\simcon    
nect-monitor\blockfactory\build\deps\mxpp\mxpp.vcxproj]
  Auto build dll exports
  SimulinkCoder.vcxproj -> F:\simconnect-monitor\blockfactory\build\bin\Debug\BlockFactorySimulinkCoderd.dll
  blockfactory-exists.vcxproj -> F:\simconnect-monitor\blockfactory\build\bin\Debug\blockfactory-exists.exe

Not sure what is wrong now.

traversaro commented 2 years ago

The problem is more clear for this error: your target/platform is x86 (i.e. 32-bit) while the MATLAB libraries are for 64-bit.

kevinwidjaja21 commented 2 years ago

Ok, that is weird. I am on 64-bit windows 10, with 64-bit MatLab and CMake. The only thing that is 32-bit is visual studio but 64-bit only just come this year. Is that the issue?

traversaro commented 2 years ago

I may be wrong, but on VS2017 CMake still defaults to generate 32-bit projects by default (they switched to 64-bit by default in VS2019). You probably just need to pass -A x64 option to CMake first configuration to make sure you generate a 64-bit project.

kevinwidjaja21 commented 2 years ago

Well, that seems to solve the issue. I guess you can close the issue now. Thanks.