-project(meshlink-tiny)
+project(meshlink)
cmake_minimum_required(VERSION 3.12)
set(THREADS_PREFER_PTHREAD_FLAG ON)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
add_subdirectory(src)
-enable_testing()
-add_subdirectory(test)
+
+if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
+ enable_testing()
+ add_subdirectory(test)
+endif()
#include(GenerateExportHeader)
#generate_export_header(meshlink BASE_NAME meshlink)
-add_library(meshlink SHARED
+set(MESHLINK_SOURCES
adns.c
buffer.c
chacha-poly1305/chacha-poly1305.c
../include/meshlink++.h
)
+add_library(meshlink ${MESHLINK_SOURCES})
+
target_compile_features(meshlink PUBLIC c_std_11)
target_include_directories(meshlink PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
$<INSTALL_INTERFACE:include/meshlink>
)
target_link_libraries(meshlink PRIVATE Threads::Threads)
-set_target_properties(meshlink PROPERTIES PUBLIC_HEADER "${MESHLINK_PUBLIC_HEADERS}")
-set_property(TARGET meshlink PROPERTY C_VISIBILITY_PRESET hidden)
-set_property(TARGET meshlink PROPERTY C_STANDARD 11)
+set_target_properties(meshlink PROPERTIES
+ PUBLIC_HEADER "${MESHLINK_PUBLIC_HEADERS}"
+ C_VISIBILITY_PRESET hidden
+ C_STANDARD 11
+)
include(GNUInstallDirs)
install(TARGETS meshlink
target_link_libraries(${name} meshlink)
add_test(NAME ${name} COMMAND ${name})
set_tests_properties(${name} PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 30)
+ target_compile_features(${name} PUBLIC c_std_11)
endfunction()
add_executable(stream stream.c)