Skip to content

[build][CMake] GFLW not linked when raylib declared as dependency for vcpkg #6193

Description

@batabutter

Issue description

I created a standard build config using CMake and vcpkg using manifest mode, glfw was unable to link properly. It seems as so for some reason, glfw gets dropped during the creation of raylib-targets.cmake.

When using,

find_package(raylib CONFIG REQUIRED)
target_link_libraries(out PRIVATE raylib)

glfw does not get added into the linkage stage after calling cmake --build build, even though your system requires that external linkage, and it should propagate. I was able to fix this issue simply by adding

find_package(raylib CONFIG REQUIRED)
find_package(glfw3 CONFIG REQUIRED)
target_link_libraries(out PRIVATE raylib glfw)

This suggests something might be wrong with how glfw is specified to link during the creation of raylib-targets.cmake.

Environment

Platform: Linux
OS: Ubuntu
OpenGL: 4.5

Issue Screenshot

Image

Code Example

Basic starter code:

#include <raylib.h>

const int SCREEN_WIDTH = 800;
const int SCREEN_HEIGHT = 800;
const int TARGET_FPS = 60;

int main() {

  InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "QuadTree Visualizer");
  SetTargetFPS(TARGET_FPS);

  while(!WindowShouldClose()) {

    BeginDrawing();
    
    
    EndDrawing();
  }

  CloseWindow();

  return 0;
}

My Original CMakeLists.txt:

cmake_minimum_required(VERSION 3.28)

project(QuadTreeVisualizer)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(raylib CONFIG REQUIRED)

add_executable(out src/main.cpp)

target_sources(out
  PRIVATE
  FILE_SET 
    utils TYPE CXX_MODULES 
    BASE_DIRS 
      utils
    FILES 
      utils/quadtree.cppm   
)

target_link_libraries(out PRIVATE raylib)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions