1
0

FindMFC.cmake 2.2 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 distribute 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()
  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()
  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()
  51. endif()
  52. if(MFC_HAVE_MFC)
  53. set(MFC_FOUND "YES")
  54. endif()
  55. endif()