2011-10-25 00:55:52 +04:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
project(mfc1)
|
|
|
|
|
|
|
|
macro(replace_flags var these those)
|
|
|
|
if("${${var}}" MATCHES "${these}")
|
|
|
|
string(REGEX REPLACE "${these}" "${those}" ${var} "${${var}}")
|
|
|
|
#message(STATUS "info: ${var} changed to '${${var}}'")
|
|
|
|
endif()
|
2011-11-02 16:03:12 +04:00
|
|
|
message(STATUS "info: ${var}='${${var}}'")
|
2011-10-25 00:55:52 +04:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(msvc_link_to_static_crt)
|
|
|
|
if(MSVC)
|
2011-11-02 16:03:12 +04:00
|
|
|
set(has_correct_flag 0)
|
2011-10-25 00:55:52 +04:00
|
|
|
foreach(lang C CXX)
|
|
|
|
foreach(suffix "" _DEBUG _MINSIZEREL _RELEASE _RELWITHDEBINFO)
|
|
|
|
replace_flags("CMAKE_${lang}_FLAGS${suffix}" "/MD" "/MT")
|
2011-11-02 16:03:12 +04:00
|
|
|
if(CMAKE_${lang}_FLAGS${suffix} MATCHES "/MT")
|
|
|
|
set(has_correct_flag 1)
|
|
|
|
endif()
|
2011-10-25 00:55:52 +04:00
|
|
|
endforeach()
|
|
|
|
endforeach()
|
2011-11-02 16:03:12 +04:00
|
|
|
if(NOT has_correct_flag)
|
|
|
|
message(FATAL_ERROR "no CMAKE_*_FLAGS var contains /MT")
|
|
|
|
endif()
|
2011-10-25 00:55:52 +04:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
set(files
|
|
|
|
ChildFrm.cpp
|
|
|
|
ChildFrm.h
|
|
|
|
MainFrm.cpp
|
|
|
|
MainFrm.h
|
|
|
|
mfc1.cpp
|
|
|
|
mfc1.h
|
|
|
|
mfc1.rc
|
|
|
|
mfc1Doc.cpp
|
|
|
|
mfc1Doc.h
|
|
|
|
mfc1View.cpp
|
|
|
|
mfc1View.h
|
|
|
|
Resource.h
|
|
|
|
stdafx.cpp
|
|
|
|
stdafx.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(CMAKE_MFC_FLAG "@CMAKE_MFC_FLAG_VALUE@")
|
|
|
|
|
|
|
|
if("${CMAKE_MFC_FLAG}" STREQUAL "1")
|
|
|
|
msvc_link_to_static_crt()
|
2011-11-02 16:03:12 +04:00
|
|
|
else()
|
|
|
|
# VS generators add this automatically based on the CMAKE_MFC_FLAG value,
|
|
|
|
# but generators matching "Make" require:
|
|
|
|
add_definitions(-D_AFXDLL)
|
2011-10-25 00:55:52 +04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_executable(mfc1 WIN32 ${files})
|
|
|
|
install(TARGETS mfc1 DESTINATION bin)
|
|
|
|
|
|
|
|
if("${CMAKE_MFC_FLAG}" STREQUAL "2")
|
|
|
|
set(CMAKE_INSTALL_MFC_LIBRARIES ON)
|
|
|
|
include(InstallRequiredSystemLibraries)
|
|
|
|
endif()
|