Skip to content

Commit

Permalink
cmake: introduce cmake support
Browse files Browse the repository at this point in the history
Cmake is used by NBS releases, so allow building the library with it.

To build the library with cmake:
  cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER=clang && ninja -C build

Signed-off-by: Anton Kuchin <[email protected]>
  • Loading branch information
aikuchin committed Mar 1, 2024
1 parent 77ec0b5 commit 0ecf59a
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 3.15)

project(yc-libvhost-server)

if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()

if(NOT LINUX)
message(FATAL_ERROR "Unsupported platform")
endif()

SET(libvhost_log_verbosity "LOG_INFO" CACHE STRING "Libvhost log verbosity")
message("Compiler ${CMAKE_C_COMPILER}")
message("Libvhost log verbosity: ${libvhost_log_verbosity}")

add_library(vhost-server)
add_compile_definitions(_GNU_SOURCE LOG_VERBOSITY=${libvhost_log_verbosity})
target_compile_options(vhost-server PRIVATE
-Wall
-Werror
-Wextra
-Wno-unused-parameter
-g
-O2

-Wno-error=unused-value
-Wno-error=unused-result
-Wno-error=strict-aliasing
)
target_include_directories(vhost-server PUBLIC
./include
)
target_include_directories(vhost-server PRIVATE
./
)
target_link_libraries(vhost-server PUBLIC
contrib-libs-linux-headers
contrib-libs-cxxsupp
yutil
)
target_sources(vhost-server PRIVATE
./blockdev.c
./event.c
./fs.c
./logging.c
./memlog.c
./memmap.c
./server.c
./vdev.c
./virtio/virt_queue.c
./virtio/virtio_blk.c
./virtio/virtio_fs.c
)

0 comments on commit 0ecf59a

Please sign in to comment.