1# Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2# file Copyright.txt or https://cmake.org/licensing for details. 3 4#[=======================================================================[.rst: 5FindMFC 6------- 7 8Find Microsoft Foundation Class Library (MFC) on Windows 9 10Find the native MFC - i.e. decide if an application can link to the 11MFC libraries. 12 13:: 14 15 MFC_FOUND - Was MFC support found 16 17You don't need to include anything or link anything to use it. 18#]=======================================================================] 19 20# Assume no MFC support 21set(MFC_FOUND "NO") 22 23# Only attempt the try_compile call if it has a chance to succeed: 24set(MFC_ATTEMPT_TRY_COMPILE 0) 25if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW) 26 set(MFC_ATTEMPT_TRY_COMPILE 1) 27endif() 28 29if(MFC_ATTEMPT_TRY_COMPILE) 30 if(NOT DEFINED MFC_HAVE_MFC) 31 set(CHECK_INCLUDE_FILE_VAR "afxwin.h") 32 configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in 33 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) 34 message(CHECK_START "Looking for MFC") 35 # Try both shared and static as the root project may have set the /MT flag 36 try_compile(MFC_HAVE_MFC 37 ${CMAKE_BINARY_DIR} 38 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx 39 CMAKE_FLAGS 40 -DCMAKE_MFC_FLAG:STRING=2 41 -DCOMPILE_DEFINITIONS:STRING=-D_AFXDLL 42 OUTPUT_VARIABLE OUTPUT) 43 if(NOT MFC_HAVE_MFC) 44 configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in 45 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) 46 try_compile(MFC_HAVE_MFC 47 ${CMAKE_BINARY_DIR} 48 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx 49 CMAKE_FLAGS 50 -DCMAKE_MFC_FLAG:STRING=1 51 OUTPUT_VARIABLE OUTPUT) 52 endif() 53 if(MFC_HAVE_MFC) 54 message(CHECK_PASS "found") 55 set(MFC_HAVE_MFC 1 CACHE INTERNAL "Have MFC?") 56 file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 57 "Determining if MFC exists passed with the following output:\n" 58 "${OUTPUT}\n\n") 59 else() 60 message(CHECK_FAIL "not found") 61 set(MFC_HAVE_MFC 0 CACHE INTERNAL "Have MFC?") 62 file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 63 "Determining if MFC exists failed with the following output:\n" 64 "${OUTPUT}\n\n") 65 endif() 66 endif() 67 68 if(MFC_HAVE_MFC) 69 set(MFC_FOUND "YES") 70 endif() 71endif() 72