FindMFC.cmake 2.3 KB

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