summaryrefslogtreecommitdiff
path: root/lib9p/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/CMakeLists.txt')
-rw-r--r--lib9p/CMakeLists.txt71
1 files changed, 61 insertions, 10 deletions
diff --git a/lib9p/CMakeLists.txt b/lib9p/CMakeLists.txt
index 488cff9..cff07ad 100644
--- a/lib9p/CMakeLists.txt
+++ b/lib9p/CMakeLists.txt
@@ -1,17 +1,68 @@
-# lib9p/CMakeLists.txt - TODO
+# lib9p/CMakeLists.txt - A 9P protocol and server library
#
-# Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+# Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
-add_library(lib9p INTERFACE)
-target_include_directories(lib9p SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
-target_sources(lib9p INTERFACE
- 9p.generated.c
- 9p.c
+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
+)
+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 INTERFACE
+target_link_libraries(lib9p_srv INTERFACE
+ lib9p_core
libcr_ipc
- libmisc
- libhw
)
+
+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")
+
+ set(cfg_matrix
+ "CONFIG_9P_SRV_DEBUG;[0;1]"
+ "CONFIG_9P_ENABLE_9P2000;[0;1]"
+ "CONFIG_9P_ENABLE_9P2000_u;[0;1]"
+ "CONFIG_9P_ENABLE_9P2000_e;[0;1]"
+ "CONFIG_9P_ENABLE_9P2000_L;[0;1]"
+ "CONFIG_9P_ENABLE_9P2000_p9p;[0;1]"
+ )
+ function(add_compile_test n defs)
+ add_executable("test_compile${n}" "tests/test_compile.c")
+ target_link_libraries("test_compile${n}" lib9p_srv)
+ target_include_directories("test_compile${n}" PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_compile_config)
+ target_compile_definitions("test_compile${n}" PUBLIC "${defs}")
+ # Don't bother running it (don't bother calling add_test())
+ endfunction()
+ apply_matrix(add_compile_test "${cfg_matrix}")
+endif()