[cmake-developers] Cannot Find MFC on Visual Studio 2013
Brad King
brad.king at kitware.com
Mon Nov 17 11:12:53 EST 2014
On 11/16/2014 04:12 AM, ゑ wrote:
> I tried to 'FIND_PACKAGE(MFC)' on VS2013(community), but MFC not found.
> VS2013 has no mfc120.dll but has mfc120u.dll,
> so I make a patch for FindMFC.cmake,
This is not just the community edition but any VS 2013. The MBCS
(non-unicode) versions of the MFC libraries are no longer installed
by default but can be downloaded separately. This was fixed for the
InstallRequiredSystemLibraries module here:
InstallRequiredSystemLibraries: MBCS MFC is optional on VS 12 (#14903)
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c0a6646d
Thanks for looking into it for FindMFC.
> + -DCOMPILE_DEFINITIONS:STRING=-D_UNICODE
This works for VS 2013, but it breaks on older VS versions that do
not have a unicode MFC library available. Also, an application cannot
simply start using the unicode MFC if the application itself is not
built with _UNICODE.
I think we actually need two separate checks for the two separate
libraries. The FindMFC module should be taught to check for the
libraries with a separate MFC_HAVE_MFC_UNICODE cache entry. The
old check can be renamed to MFC_HAVE_MFC_MBCS (and MFC_HAVE_MFC
set to a copy of that result for compatibility with applications
that look for it).
Then the only problem is how to set MFC_FOUND based on the two results.
For this we could use the COMPONENTS mechanism of find_package. Then
an application could do one of:
find_package(MFC) # found if mbcs libs are found
find_package(MFC COMPONENTS mbcs) # found if mbcs libs are found
find_package(MFC COMPONENTS unicode) # found if unicode libs are found
find_package(MFC COMPONENTS mbcs unicode) # found if both are found
The find module can check the MFC_FIND_COMPONENTS variable to see which
parts the application wants.
Thanks,
-Brad
More information about the cmake-developers
mailing list