0

I have a simple cmake project with two libraries (lib, util). The util library has a windows resource file, which is not included in the output file. Only when I add the .rc file to the lib library it's included in the output.

src
|- lib
|- util

src/CMakeLists.txt:

cmake_minimum_required(VERSION 3.18)
project(MyLib LANGUAGES CXX RC)
add_subdirectory(lib)
add_subdirectory(util)

src/lib/CMakeLists.txt:

add_library(MyLib MODULE
        Main.cpp
        # ../util/Resource.rc  # This would work
        )

target_link_libraries(MyLib PUBLIC
        util
        )

src/util/CMakeLists.txt:

cmake_minimum_required(VERSION 3.13)

add_library(util STATIC
        Resource.rc  # This is not working
        Resource.h
        util.cpp util.h)

The content of the .h/.cpp files does not matter. I checked with ResEdit if the libMyLib.dll contains the resources defined in the .rc file.

Teharez
  • 501
  • 8
  • 25
  • According to [that question](https://stackoverflow.com/questions/531502/vc-resources-in-a-static-library) and its answers, a resource file cannot be embedded into the **static** library. – Tsyvarev Jun 16 '21 at 09:05
  • Ok so changing util from `STATIC` to `SHARED`, `MODULE` or `INTERFACE` does not work, however changing it to `OBJECT` does work. Not sure why but I take it. – Teharez Jun 16 '21 at 10:26

0 Answers0