转载请注明出处。https://rhirufxmbcyj.gitlab.io
建立CMake目录,编写CMakeLists.txt
目录结构
|-- CMakeLists.txt
|-- src
| |-- CMakeLists.txt
|-- build
- 外层CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(test)
set(CMAKE_MFC_FLAG 1)
add_definitions(-DUNICODE -D_UNICODE)
add_definitions(-D_AFXDLL)
link_directories(${CMAKE_SOURCE_DIR}/lib)
add_subdirectory(src)
关于CMAKE_MFC_FLAG官网的解释
It should be set to 1 for the static MFC library, and 2 for the shared MFC library.
- src中的CMakeLists.txt
FILE(GLOB SRC_FILES "./*.cpp")
FILE(GLOB HEAD_FILES "./*.h")
FILE(GLOB RC_FILES "./*.rc")
add_executable(test ${SRC_FILES} ${HEAD_FIL