using CMake for making a project which includes MFC

cmake, mfc

Solution

You need to add `_AFXDLL` to the preprocessor definitions and set the CMake variable `CMAKE_MFC_FLAG` to `1` for the static MFC library, or `2` for the shared one.

add_definitions(-D_AFXDLL)
set(CMAKE_MFC_FLAG 1)

For further info run

cmake --help-variable CMAKE_MFC_FLAG

Problem

I have a project in which I have to use a COM Module which uses MFC. I use CMake for making my project. Can anybody tell me what I have to include into my CMakeLists.txt so that I can use MFC in my project?

Original source