Files
DataRouter/CMakeLists.txt
T

23 lines
784 B
CMake

cmake_minimum_required(VERSION 3.10)
project(DataRouter C)
set(CMAKE_C_STANDARD 11)
add_library(DataRouter STATIC datarouter.c)
# 将库源码目录暴露给使用者,使其可通过 #include <datarouter_config.h>
# 从自身 include path 覆盖默认配置。如果使用者未提供,则回退到库自带版本。
target_include_directories(DataRouter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(BUILD_EXAMPLES OR NOT DEFINED BUILD_EXAMPLES)
add_executable(example example.c)
target_link_libraries(example DataRouter)
endif()
if(BUILD_TESTING OR NOT DEFINED BUILD_TESTING)
enable_testing()
add_executable(test_datarouter tests/test_datarouter.c)
target_link_libraries(test_datarouter DataRouter)
add_test(NAME datarouter COMMAND test_datarouter)
endif()