mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
FindMFC: Check for static MFC variant
Some CMake applications can set /MT without setting CMAKE_MFC_FLAG. This change lets FindMFC work in those situations.
This commit is contained in:
@@ -31,6 +31,7 @@ if(MFC_ATTEMPT_TRY_COMPILE)
|
||||
configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx)
|
||||
message(STATUS "Looking for MFC")
|
||||
# Try both shared and static as the root project may have set the /MT flag
|
||||
try_compile(MFC_HAVE_MFC
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx
|
||||
@@ -38,6 +39,16 @@ if(MFC_ATTEMPT_TRY_COMPILE)
|
||||
-DCMAKE_MFC_FLAG:STRING=2
|
||||
-DCOMPILE_DEFINITIONS:STRING=-D_AFXDLL
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
if(NOT MFC_HAVE_MFC)
|
||||
configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx)
|
||||
try_compile(MFC_HAVE_MFC
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx
|
||||
CMAKE_FLAGS
|
||||
-DCMAKE_MFC_FLAG:STRING=1
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
endif()
|
||||
if(MFC_HAVE_MFC)
|
||||
message(STATUS "Looking for MFC - found")
|
||||
set(MFC_HAVE_MFC 1 CACHE INTERNAL "Have MFC?")
|
||||
|
||||
@@ -45,6 +45,11 @@ set(files
|
||||
|
||||
set(CMAKE_MFC_FLAG "@CMAKE_MFC_FLAG_VALUE@")
|
||||
|
||||
FIND_PACKAGE(MFC)
|
||||
IF (NOT MFC_FOUND)
|
||||
MESSAGE(FATAL_ERROR "MFC Could not be found during the MFC test")
|
||||
ENDIF()
|
||||
|
||||
if("${CMAKE_MFC_FLAG}" STREQUAL "1")
|
||||
msvc_link_to_static_crt()
|
||||
else()
|
||||
|
||||
Reference in New Issue
Block a user