Skip to content

Commit

Permalink
Create static dns library
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Vlasov authored and Sergey Vlasov committed Mar 20, 2024
1 parent 949e260 commit 61b3d49
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
14 changes: 4 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ cmake_minimum_required(VERSION 3.16)

set(CMAKE_COMPILE_WARNING_AS_ERROR ON)

find_package(jsoncpp CONFIG REQUIRED)

add_executable(dns_server
server.cpp
dns.cpp dns.h
add_executable(dns_server
server.cpp
)

target_link_libraries(dns_server PRIVATE JsonCpp::JsonCpp)

if(WIN32)
target_link_libraries(dns_server PRIVATE wsock32 ws2_32)
endif()
target_link_libraries(dns_server PRIVATE dns)

add_subdirectory(libdns)
add_subdirectory(tests)
10 changes: 10 additions & 0 deletions libdns/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
find_package(jsoncpp CONFIG REQUIRED)

add_library(dns STATIC dns.cpp dns.h)

target_include_directories(dns PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(dns PRIVATE JsonCpp::JsonCpp)

if(WIN32)
target_link_libraries(dns PUBLIC wsock32 ws2_32)
endif()
File renamed without changes.
File renamed without changes.
13 changes: 5 additions & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ enable_testing()

find_package(GTest REQUIRED)

include_directories("..")

add_executable(
tst_dns
tst_dns.cpp
../dns.cpp ../dns.h
)

target_link_libraries(
tst_dns
GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main
dns
GTest::gtest
GTest::gtest_main
GTest::gmock
GTest::gmock_main
)

if(WIN32)
target_link_libraries(tst_dns wsock32 ws2_32)
endif()

0 comments on commit 61b3d49

Please sign in to comment.