How to get rid of link error in FreeGLUT MS Visual Studio project build with Cmake + Conan?

  c++, cmake, conan, visual-studio

Im trying build freeGLUT project with cmake and conan for MS Visual Studio, but when I build it return link error LNK1104 "Cant open file "freeglut.lib" for Release and "Cant open file "freeglutd.lib" for Debug.

Visual Studio 16 2019
Cmake 3.20.3
Conan 1.39.0

Project Tree

CMakeLists.txt

cmake_minimum_required(VERSION 3.20)
project(OpenGLConan)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)

add_subdirectory(src)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(FreeGLUT)

target_include_directories(${PROJECT_NAME} PUBLIC ${FreeGLUT_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${FreeGLUT_LIBRARIES})

conanfile.txt

[requires]
freeglut/3.2.1

[generators]
cmake_find_package
cmake_paths

src/CMakeLists.txt

add_executable(${PROJECT_NAME} main.cpp)

src/main.cpp

#include <iostream>
#include <GL/glut.h>

int main(int argc, char** argv)
{
    glutInit(&argc, argv);

    /* Create a single window with a keyboard and display callback */
    glutCreateWindow("GLUT Test");

    /* Run the GLUT event loop */
    glutMainLoop();

    return EXIT_SUCCESS;
}

Source: Windows Questions C++

LEAVE A COMMENT