FindMFC.cmake 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # - Find MFC on Windows
  2. # Find the native MFC - i.e. decide if an application can link to the MFC
  3. # libraries.
  4. # MFC_FOUND - Was MFC support found
  5. # You don't need to include anything or link anything to use it.
  6. #=============================================================================
  7. # Copyright 2002-2009 Kitware, Inc.
  8. #
  9. # Distributed under the OSI-approved BSD License (the "License");
  10. # see accompanying file Copyright.txt for details.
  11. #
  12. # This software is distributed WITHOUT ANY WARRANTY; without even the
  13. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. # See the License for more information.
  15. #=============================================================================
  16. # (To distributed this file outside of CMake, substitute the full
  17. # License text for the above reference.)
  18. # Assume no MFC support
  19. SET(MFC_FOUND "NO")
  20. # Only attempt the try_compile call if it has a chance to succeed:
  21. SET(MFC_ATTEMPT_TRY_COMPILE 0)
  22. IF(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW)
  23. SET(MFC_ATTEMPT_TRY_COMPILE 1)
  24. ENDIF(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW)
  25. IF(MFC_ATTEMPT_TRY_COMPILE)
  26. IF("MFC_HAVE_MFC" MATCHES "^MFC_HAVE_MFC$")
  27. SET(CHECK_INCLUDE_FILE_VAR "afxwin.h")
  28. CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
  29. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx)
  30. MESSAGE(STATUS "Looking for MFC")
  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(MFC_HAVE_MFC)
  39. MESSAGE(STATUS "Looking for MFC - found")
  40. SET(MFC_HAVE_MFC 1 CACHE INTERNAL "Have MFC?")
  41. FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  42. "Determining if MFC exists passed with the following output:\n"
  43. "${OUTPUT}\n\n")
  44. ELSE(MFC_HAVE_MFC)
  45. MESSAGE(STATUS "Looking for MFC - not found")
  46. SET(MFC_HAVE_MFC 0 CACHE INTERNAL "Have MFC?")
  47. FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  48. "Determining if MFC exists failed with the following output:\n"
  49. "${OUTPUT}\n\n")
  50. ENDIF(MFC_HAVE_MFC)
  51. ENDIF("MFC_HAVE_MFC" MATCHES "^MFC_HAVE_MFC$")
  52. IF(MFC_HAVE_MFC)
  53. SET(MFC_FOUND "YES")
  54. ENDIF(MFC_HAVE_MFC)
  55. ENDIF(MFC_ATTEMPT_TRY_COMPILE)