R
R
raster2021-12-18 02:58:17
CMake
raster, 2021-12-18 02:58:17

How to add a library to a Visual Studio CMake project?

Good evening, I found an interesting library on github for working with xlsx documents ( https://github.com/troldal/OpenXLSX ). I ran into a problem connecting it to a CMake project in Visual Studio.
In the paragraph describing the connection, the following instructions are given:

cmake_minimum_required(VERSION 3.15)
project(MyProject)

set(CMAKE_CXX_STANDARD 17)

# Set the build output location to a common directory
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output)

add_subdirectory(OpenXLSX)

add_executable(MyProject main.cpp)
target_link_libraries(MyProject OpenXLSX::OpenXLSX)

Can you explain where this library should be, as I understand it, just in the project folder. And also, what to pass to each set command? And, if possible, share a link to good basic CMake tutorials :)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question