我很难在MFC CMake项目中打开交互式资源编辑器,否则该项目可以编译并运行正常。
项目文件的布局如下:
.
├── CMakeLists.txt
├── inc
│ ├── <...>
│ ├── resource.h
├── res
│ ├── MyApp.ico
│ ├── MyApp.rc
│ └── MyApp.rc2
└── src
├── CMakeLists.txt
└── <...>
顶部CMakeLists.txt:
cmake_minimum_required(VERSION 3.5)
project(MyProject)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 14)
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4715") # makes missing return as error
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # parallel build
endif()
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/output)
# MFC
add_definitions(-D_AFXDLL)
set(CMAKE_MFC_FLAG 1)
add_subdirectory(src)
src CMakeLists.txt:
include_directories(${CMAKE_SOURCE_DIR}/inc)
include_directories(${CMAKE_SOURCE_DIR}/res)
include_directories(${CMAKE_SOURCE_DIR})
set(SOURCES
<...>
)
set(HEADERS
<...>
)
add_executable(
${PROJECT_NAME}
WIN32
${SOURCES}
${HEADERS}
${CMAKE_SOURCE_DIR}/res/MyApp.rc
${CMAKE_SOURCE_DIR}/res/MyApp.rc2
)
install(TARGETS MyApp
RUNTIME DESTINATION .)
在Visual Studio(Pro)中,项目可以正常加载并针对我需要的每种配置进行编译,但是如果我尝试打开.rc文件,则会在MFC和ATL缺少标头的情况下出错(afxres.h
,{ {1}},winres.h
,...)。资源文件不会像在VS解决方案中那样在资源编辑器中打开。
我想念什么吗?这有可能吗?