Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindMFC.cmake
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 #=============================================================================
8 # Copyright 2002-2009 Kitware, Inc.
9 #
10 # Distributed under the OSI-approved BSD License (the "License");
11 # see accompanying file Copyright.txt for details.
12 #
13 # This software is distributed WITHOUT ANY WARRANTY; without even the
14 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 # See the License for more information.
16 #=============================================================================
17 # (To distribute this file outside of CMake, substitute the full
18 #  License text for the above reference.)
19
20 # Assume no MFC support
21 set(MFC_FOUND "NO")
22
23 # Only attempt the try_compile call if it has a chance to succeed:
24 set(MFC_ATTEMPT_TRY_COMPILE 0)
25 if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW)
26   set(MFC_ATTEMPT_TRY_COMPILE 1)
27 endif()
28
29 if(MFC_ATTEMPT_TRY_COMPILE)
30   if("MFC_HAVE_MFC" MATCHES "^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(STATUS "Looking for MFC")
35     try_compile(MFC_HAVE_MFC
36       ${CMAKE_BINARY_DIR}
37       ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx
38       CMAKE_FLAGS
39       -DCMAKE_MFC_FLAG:STRING=2
40       -DCOMPILE_DEFINITIONS:STRING=-D_AFXDLL
41       OUTPUT_VARIABLE OUTPUT)
42     if(MFC_HAVE_MFC)
43       message(STATUS "Looking for MFC - found")
44       set(MFC_HAVE_MFC 1 CACHE INTERNAL "Have MFC?")
45       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
46         "Determining if MFC exists passed with the following output:\n"
47         "${OUTPUT}\n\n")
48     else()
49       message(STATUS "Looking for MFC - not found")
50       set(MFC_HAVE_MFC 0 CACHE INTERNAL "Have MFC?")
51       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
52         "Determining if MFC exists failed with the following output:\n"
53         "${OUTPUT}\n\n")
54     endif()
55   endif()
56
57   if(MFC_HAVE_MFC)
58     set(MFC_FOUND "YES")
59   endif()
60 endif()