ccurlcmakecmakelists-options

Cannot specify link libraries for target "curl-demo" which is not built by this project


I started using CMake for my project, but now when I want to use libcurl, it doesn't work. Here is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.24)
project(getter C)

set(CMAKE_C_STANDARD 11)

find_package(CURL REQUIRED)

add_executable(getter main.c brute.c brute.h)

target_link_libraries(curl-demo CURL::libcurl)

When I tried to run this, it said Cannot specify link libraries for target "curl-demo" which is not built by this project.

And I don't have any idea what that means... I searched everywhere but couldn't find any cases like this. Can someone please help me??

Thanks!


Solution

  • Ok I'm just stupid. curl-demo isn't supposed to be some kind of command - it's your project name. So when I start with project(getter C), I have to use target_link_libraries(getter CURL::libcurl)!