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

This question already has answers here:
Getting a CMake Error: Cannot specify link libraries for target which is not built by the project
(4 answers)
Closed 14 days ago.
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!

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)!

Related

CLion does not recognize CMakeLists.txt file

I am currently trying to set up CLion, as I like IntelliJ a lot, and I ran into this seemingly very basic problem:
CMake Error: The source directory "/cygdrive/c/.../untitled" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
This happens even when building a clean C project from scratch in CLion, where a CMakeLists.txt file is present in exactly that directory. I use cygwin64 as compiler and work on a Windows x64 machine. I guess /cygdrive/ before c is due to that.
Sorry to bother you guys with that basic stuff, but I simply cannot work it out. I know there are a lot of similar questions around, unfortunately that did not help me.

Viewing CPython Code in CLion

Sorry for a question that might appear stupid to more experienced developers: I am still a newcomer to C and C++.
I come from Python/Java development land and am trying to get a better insight into C and C++. I installed JetBrains CLion and cloned CPython mercurial repository. However when I started looking at the source code, I realized that Clion was highlighting a lot of constructs that seemed to be working. For instance:
Or
As far as I can see, Clion seems the have problem with the identation style of Python, C code, but once again, I might be wrong.
How Clion configurations can be altered for it to properly parse the CPython code?
CPython uses GNU Autotools for the build, but that toolset is not supported by CLion. See issues CPP-494 and CPP-193. CLion currently supports only one build system - CMake.
You can create your own CMakeLists.txt file and list the sources in there. This will help CLion to understand the structure of the source tree and allow it to find the headers etc:
cmake_minimum_required(VERSION 3.0)
project(cpython)
file(GLOB SOURCE_FILES
Python/*.c
Parser/*.c
Objects/*.c
Modules/*.c)
include_directories(Include)
add_executable(cpython ${SOURCE_FILES})
For the actual build, use standard build tools from command line. Alternatively, custom command can be added to CMakeLists.txt to call make. See add_custom_command for that.
As mentioned in the above answer you need a CMake Project to allow CLion to build Python.
In fact there is already a CMakeList.txt-files for CPython, that is maintained independently from the official sources:
https://github.com/python-cmake-buildsystem/python-cmake-buildsystem
I didn't test it with CLion but it should do the job...

How to use CUDA 6.0 with XCODE 5

My question may completely be a noob. Sorry, for that but I have been trying to compile my first Cuda code in Xcode and I'm lost where and how I could set up the IDE to invoke NVCC.
I installed the latest CUDA toolkit CUDA 6.0 and have even installed GCC 4.8 using brew. I have XCODE 5.5
When I run my code from XCODE all the directives like global are marked as unidentified.
I don't where and to change the settings to invoke NVCC. I will be really thankful, if anyone could help me with this.
Further, when I created the XCODE project, I created it as a C project. So, I placed the CUDA code in this C file, which is what is giving me the above mentioned errors. I tried to replace this .C file with a .cu file (just change the extension), which too failed badly - XCODE didn't even know what to do with the .cu files
COuld anyone please help me?
Thanks in Advance
I have given it a try. Although I have not completely succeeded I thought I'd post my progress here in hopes of helping others. The steps I took were inspired by this page.
Create a new Xcode project
Under Build Settings add a new user defined setting CC with the value /usr/local/cuda/bin/nvcc.
Add /usr/local/cuda/include to Header Search Paths under Build Settings.
Set Enable Modules (C and Objective-C) to No.
Add /usr/local/cuda/lib/libcuda.dylib to Link Binary With Libraries under Build Phases.
For any C files you create set their extension to .cu in the File Inspector, after you have done that you have to set the type of that file to C source to get syntax highlighting, by going to Editor->Syntax Coloring->C.
Problems with this setup:
- Xcode can't run the executable, at least nog if it is compiled for debugging. However you can make it copy the executable to some reasonable location and run it in the terminal.
- Whenever you try 'Build for running' sometimes Xcode magically destroys the whole project.

Making libcurl CodeLite Project

I have downloaded Curl and would like to add libcurl only (no other stuffs) to my CodeLite Workspace. I have seen VC Project files but I do not use VC (and I use Primarily Ubuntu).
So I need help to know which files to Include and any pre-processor that I need to include for the library to compile.
I have tried adding all *.c/*.h files but I keep getting errors (if those errors can be of help I will post them). Add the include folder in curl root directory does not help either.
Thanks
I ended up with compiling library with terminal and just tell CL to find it there!

CMake commands list for C/C++

I usually work with qmake for my C and C++ projects but recently thought to learn CMake. A nice thing about qmake is that they have a variable reference here: http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html
I was searching for something similar for CMake but could not find one :( . Can someone please point me to one?
Does this one fit your needs:
http://www.cmake.org/cmake/help/v2.8.8/cmake.html ?
I recently set up a sample project for cmake. Probably it helps you to get startet:
https://github.com/moooeeeep/cmake_sample
The path to the cmake reference manual changed to http://www.cmake.org/cmake/help/v2.8.8/cmake.html

Resources