summaryrefslogtreecommitdiff
path: root/lib9p/CMakeLists.txt
blob: 543d01a2f786afdbcf2222d07e6d47ed4cf3b74a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# lib9p/CMakeLists.txt - A 9P protocol and server library
#
# Copyright (C) 2024-2025  Luke T. Shumaker <lukeshu@lukeshu.com>
# SPDX-License-Identifier: AGPL-3.0-or-later

add_library(lib9p_core INTERFACE)
target_include_directories(lib9p_core PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/core_include)
target_sources(lib9p_core INTERFACE
	core.c
	core_generated.c
	core_tables.c
)
target_link_libraries(lib9p_core INTERFACE
	libfmt
	libhw_generic
	libmisc
)

add_library(lib9p_srv INTERFACE)
target_include_directories(lib9p_srv PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/srv_include)
target_sources(lib9p_srv INTERFACE
	srv.c
)
target_link_libraries(lib9p_srv INTERFACE
	lib9p_core
	libcr_ipc
)

if (ENABLE_TESTS)
	add_subdirectory(tests/test_server)

	function(add_lib9p_executable arg_testname)
		add_executable("${arg_testname}" "tests/${arg_testname}.c")
		target_link_libraries("${arg_testname}" lib9p_core)
		target_include_directories("${arg_testname}" PRIVATE
			${CMAKE_CURRENT_SOURCE_DIR}/tests
			${CMAKE_CURRENT_SOURCE_DIR}/tests/client_config
		)
	endfunction()
	function(add_lib9p_test arg_testscript)
		get_filename_component(tmp_basename "${arg_testscript}" "NAME")
		add_test(
			NAME    "lib9p/${tmp_basename}"
			COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tests/runtest" "${arg_testscript}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/${tmp_basename}.explog"
		)
	endfunction()

	add_lib9p_test("${CMAKE_CURRENT_SOURCE_DIR}/tests/testclient-p9p")

	add_lib9p_executable("testclient-sess")
	add_lib9p_test("./testclient-sess")

	add_lib_test(lib9p_core test_compile)
	target_include_directories(test_compile PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_compile_config)
endif()