RC: Resource-only plugins fail with confusing errors
Configuration fails for a project containing a Windows Resource file when configuring with the "CodeBlocks - NMake Makefiles" generator:
-- Configuring done
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_RC_CREATE_SHARED_MODULE
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
Tested with Visual Studio 2019 Community, Windows SDK 10.0.19041.0, and CMake 3.21.1, 3.20.5, and 3.9.0-rc5.
Steps to reproduce:
- Create a CMakeLists.txt as follows:
project(test LANGUAGES C)
add_library(resources MODULE resources.rc)
- Create an empty file
resources.rc
. - Create a Visual Studio command line environment with NMAKE, CL and RC working. That is, run
"%VS140COMNTOOLS%vsvars32.bat"
in a Windows command prompt. - Configure the project with the
-G "CodeBlocks - NMake Makefiles"
option.
A Note on VS Build Environment
VS2019's vsvars32.bat was broken for me. There was a line which added the Windows SDK bin directory to the path:
@if not "%WindowsSdkDir%" == "" @set PATH=%WindowsSdkDir%bin\x86;%PATH%
However in my case the Program Files (x86)\Windows Kits\bin\x86
was almost empty. All the actual SDK files were in Program Files (x86)\Windows Kits\bin\10.0.19041.0\x86
. To fix this I modified my vsvars32.bat such that the above line now reads
@if not "%WindowsSdkDir%" == "" @set PATH=%WindowsSdkDir%bin\%WindowsSDKVersion%x86;%PATH%
Edited by Brad King