Questions tagged [target-link-libraries]

21 questions
14
votes
1 answer

How to retrieve cmake target names from vcpkg?

After installing a package, vcppkg very helpfully displays the relevant CMake targets... The package libwebp:x64-windows provides CMake targets: find_package(WebP CONFIG REQUIRED) target_link_libraries(main PRIVATE WebP::webp WebP::webpdemux…
Thomas Sharpless
  • 949
  • 1
  • 8
  • 14
5
votes
2 answers

Force CMake target_link_libraries to fail when adding nonexistent target

CMake has an irritating default (I presume, I see nothing magical in my CMake config, but I could be wrong since I know very little about CMake) behavior that he silently ignores when you add a target to your project even if that target does not…
NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277
2
votes
1 answer

cmake target_link_libraries(), when should we use?

I am new to CMake and just want to understand some details about how target_link_libraries works. To include a library, let's say boost. We can simply do include_directories(BOOST_LIBRARY_PATH). This allows my project to compile correctly and no…
PleaseHelpppp
  • 75
  • 1
  • 6
2
votes
0 answers

Is there any way to accomplish target conditioned library interfacing in CMake?

I am compiling multiple C++ applications (app1,app2) linking libif. libif interfaces a library which is available in two versions (libV1 libV2). Depending on the application that links to it I need libif to interface libV1 (for app1) xor libV2 (for…
1
vote
1 answer

When should I use CMake's add_dependencies instead of target_link_libraries?

I'm used to defining CMake target dependencies using the target_link_libraries() command. Recently, though, I've noticed the existence of another command, add_dependencies(). When should I use the latter rather than the former? Note: I tried reading…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
1
vote
1 answer

Run a script upon linking to a CMake target

I have a situation where I need to run a script when a CMake target is linked-to so that it can automatically generate files in the current project directory that are used to interface with the library. I know when you link to a CMake target it…
tjwrona1992
  • 8,614
  • 8
  • 35
  • 98
1
vote
1 answer

CMake: target_link_libraries based on flag

There are 4 libs linked already and want to link a new library if FLAG is ON. target_link_libraries (lib1 lib2 lib3 lib4 ${CMAKE_DL_LIBS}) I want it to be something like target_link_libraries (lib1 lib2 lib3 lib4 if(FLAG) lib5 endif()…
Ashwini
  • 11
  • 2
0
votes
0 answers

how to include .node extentions in cmake

can I kindly ask you what all do i need to put into cmakelists.txt if i have fresh project? I have compiled node-rfc extention of node.js so now i have the build folder (c:\Qt\nodejs\node_modules\npm\node_modules\node-rfc\build\Release) with files…
0
votes
1 answer

Can't link built static library CMake

I've my discord bot project. The file structure of the relevant files are listed as below: include/ cpp-dotenv/ dotenv.h lib/ libcpp_dotenv.a src/ CMakeLists.txt My simplified CMakeLists.txt: cmake_minimum_required(VERSION…
0
votes
0 answers

how to Link Libraries in xcode?

how can I add a library in Xcode's target Link Binary With Libraries under Build Phases? "react": "18.2.0", "react-native": "0.71.8", "xcode": "14.3" when I add libReact-RCTText.a to Link Binary With Libraries, it was throwing error: Library…
0
votes
1 answer

CMake `add_executable` and `target_link_libraries` throwing linking error

I am following Asio tutorial by javidx9 and using CMake to link my executables and libraries. Complete source code is available in this repository. I am facing a linking error with the executables Server.cpp and Client.cpp in folder - Source ----…
Rusty
  • 1,086
  • 2
  • 13
  • 27
0
votes
1 answer

Unable to link NLohmann json library using cmake

I am trying to link the NLohmann json library to my json interpreter via cmake. I keep getting the error : fatal error: 'nlohmann/json.hpp' file not found #include From the file : #include #include…
0
votes
0 answers

Howto: Adding custom made library to CMakeLists.txt in another project

I want to include the software for a video device to my docker-project. The camera-software is a SDK (https://thermalcapture.com/software-sdk-thermalcapture-grabber-usb/) that I built with make + cmake. I append the CMakeLists.txt from that SDK…
kremerf
  • 21
  • 5
0
votes
1 answer

CMake link libraries no header found

Here is my directory tree I implemented accident component which have to be a standalone library. Here is CMakeLists.txt for it set (ACCIDENT accident) file (GLOB SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") file (GLOB HEADER_FILES…
NiklasMan
  • 43
  • 5
0
votes
1 answer

CMake target_link_libraries public inheritance

I am educating myself on a CMakeLists.txt of implot library. The imgui library, which is a library on which implot is based, declares the link libraries to be of type PUBLIC, as shown below. # ... add_library(imgui ${IMGUI_HEADERS}…
afp_2008
  • 1,940
  • 1
  • 19
  • 46
1
2