项目目录下新建CMakeLists.txt,写入
- cmake_minimum_required (VERSION 2.6)
- project (test1)
- set (test1_VERSION_MAJOR 1)
- set (test1_VERSION_MINOR 0)
- add_definitions(-DUNICODE -D_UNICODE)
- add_definitions(-D_AFXDLL)
- set(CMAKE_MFC_FLAG 1)
- add_executable(test1 WIN32 MfcDialogTest.cpp MfcDialogTestDlg.cpp stdafx.cpp MfcDialogTest.rc)
打开命令提示符,进入到项目目录,运行cmake -G "Visual Studio 10" .,生成test1.sln和其他关联文件,打开test1.sln,编译
add_definitions(-DUNICODE -D_UNICODE) 默认字符串用UNICODE
set(CMAKE_MFC_FLAG 1) 静态链接mfc
转载于:https://blog.51cto.com/co63oc/1064358