FindMFC.cmake 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #.rst:
  2. # FindMFC
  3. # -------
  4. #
  5. # Find MFC on Windows
  6. #
  7. # Find the native MFC - i.e. decide if an application can link to the
  8. # MFC libraries.
  9. #
  10. # ::
  11. #
  12. # MFC_FOUND - Was MFC support found
  13. #
  14. # You don't need to include anything or link anything to use it.
  15. #=============================================================================
  16. # Copyright 2002-2009 Kitware, Inc.
  17. #
  18. # Distributed under the OSI-approved BSD License (the "License");
  19. # see accompanying file Copyright.txt for details.
  20. #
  21. # This software is distributed WITHOUT ANY WARRANTY; without even the
  22. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  23. # See the License for more information.
  24. #=============================================================================
  25. # (To distribute this file outside of CMake, substitute the full
  26. # License text for the above reference.)
  27. # Assume no MFC support
  28. set(MFC_FOUND "NO")
  29. # Only attempt the try_compile call if it has a chance to succeed:
  30. set(MFC_ATTEMPT_TRY_COMPILE 0)
  31. if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW)
  32. set(MFC_ATTEMPT_TRY_COMPILE 1)
  33. endif()
  34. if(MFC_ATTEMPT_TRY_COMPILE)
  35. if(NOT DEFINED MFC_HAVE_MFC)
  36. set(CHECK_INCLUDE_FILE_VAR "afxwin.h")
  37. configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
  38. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx)
  39. message(STATUS "Looking for MFC")
  40. try_compile(MFC_HAVE_MFC
  41. ${CMAKE_BINARY_DIR}
  42. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx
  43. CMAKE_FLAGS
  44. -DCMAKE_MFC_FLAG:STRING=2
  45. -DCOMPILE_DEFINITIONS:STRING=-D_AFXDLL
  46. OUTPUT_VARIABLE OUTPUT)
  47. if(MFC_HAVE_MFC)
  48. message(STATUS "Looking for MFC - found")
  49. set(MFC_HAVE_MFC 1 CACHE INTERNAL "Have MFC?")
  50. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  51. "Determining if MFC exists passed with the following output:\n"
  52. "${OUTPUT}\n\n")
  53. else()
  54. message(STATUS "Looking for MFC - not found")
  55. set(MFC_HAVE_MFC 0 CACHE INTERNAL "Have MFC?")
  56. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  57. "Determining if MFC exists failed with the following output:\n"
  58. "${OUTPUT}\n\n")
  59. endif()
  60. endif()
  61. if(MFC_HAVE_MFC)
  62. set(MFC_FOUND "YES")
  63. endif()
  64. endif()