I'm having a hard time opening the interactive resource editor in a MFC CMake project that otherwise compiles and runs just fine.
The project files are laid out as follows:
.
├── CMakeLists.txt
├── inc
│ ├── <...>
│ ├── resource.h
├── res
│ ├── MyApp.ico
│ ├── MyApp.rc
│ └── MyApp.rc2
└── src
├── CMakeLists.txt
└── <...>
Top 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 .)
In Visual Studio (Pro) the project loads just fine and compiles for every configuration I need, but if I try to open an .rc file I get errors on missing headers from MFC and ATL (afxres.h
, winres.h
, dde.rh
, ...). The resource file won't open in the resource editor like it does on a VS solution.
The mssage happens when double-clicking on MyApp.rc, and I get
fatal error RC1015: cannot open include file 'afxres.h'.
I use the latest VS version available as of today which is 15.8.5, and this happens when opening the CMake project in Visual Studio.
I have already installed the ATL/MFC components in my Visual Studio installation. Like I said, it compiles just fine so dependencies are resolved correctly.
Am I missing something? Is this even possible?