I'm writing my own minecraft launcher in c++ with Visual Studio 2019 IDE. I want it to be a cross-platform project. I decided to use CMake for this, but I have some problems with third party libraries.
FILE STRUCTURE
root
|---MyProject
| |---build
| | |---Debug
| | |---Release
| |---include
| | |---MyProject.hpp
| |---src
| | |---MyProject.cpp
| | |---CMakeLists.txt
| |---CMakeLists.txt
|---Vendor
| |---CURL
| | |--- // source downloaded from https://curl.haxx.se/download/curl-7.64.1.tar.gz
| |---CMakeLists.txt
|---CMakeLists.txt
I have some experience with linking libraries in visual studio's solutions, but I don't know how to do it in CMake.
I have two folders:
I want to link CMake projects in 'Vendor' to 'MyProject' to be able to use it in 'MyProject.cpp' and build it.
Example usage:
'MyProject.hpp':
#pragma once
#include <iostream>
#inlcude "curl/curl.h"
'MyProject.cpp':
int main() {
// Hello World
std::cout << "Hello world" << std::endl;
// Some Curl stuff
CURL* curl;
...
}
I tried something like this:
add_subdirectory("Vendor/CURL")
include_directories("Vendor/CURL/include")
I'm new to CMake and don't know how to do it... I was googling it for more than one hour, but I didn't find anything. BTW: Sorry for my english.
To link to a 3rd party library you will need to specify the path and name of the library.
I have some experience with linking libraries in visual studio's solutions, but I don't know how to do it in CMake.
CMake link_directories maps to VS Properties->Linker->General->Additional Library Directories
CMake target_link_libraries maps to VS Properties->Linker->Input->Additional Dependencies
I'm new to CMake and don't know how to do it.
Take a look at CMake and Visual Studio which explains CMake in the context of Visual Studio with an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With