88# Use of this source code is governed by a MIT license
99# that can be found in the LICENSE file.
1010#
11- # ====================================================================
12- # Vix.cpp - WebRPC Module
13- # ====================================================================
14- # Purpose:
15- # Minimal transport-agnostic WebRPC layer for Vix:
16- # - RPC envelope (request/response/error) over vix::json::Simple (header-only)
17- # - Method router + dispatcher
18- #
19- # Public Targets:
20- # - vix_webrpc : The actual library target (STATIC or INTERFACE)
21- # - vix::webrpc : Namespaced alias for consumers
22- #
23- # Dependencies:
24- # - None required at link time for the core (Simple.hpp is header-only)
25- #
26- # Options:
27- # - VIX_WEBRPC_BUILD_TESTS : Build module tests (default OFF)
28- # - VIX_WEBRPC_BUILD_EXAMPLES : Build module examples (default OFF)
29- #
30- # Notes:
31- # - WebRPC is deliberately independent from vix::core and vix::websocket.
32- # Bridges (HTTP/WS) can live in a separate submodule later.
33- # ====================================================================
11+ # Vix.cpp
3412
3513cmake_minimum_required (VERSION 3.20 )
3614project (vix_webrpc VERSION 0.1.0 LANGUAGES CXX )
@@ -41,91 +19,44 @@ set(CMAKE_CXX_STANDARD 20)
4119set (CMAKE_CXX_STANDARD_REQUIRED ON )
4220set (CMAKE_POSITION_INDEPENDENT_CODE ON )
4321
44- # ------------------------------------------------------
45- # Sources discovery
46- # ------------------------------------------------------
47- file (GLOB_RECURSE WEBRPC_SOURCES CONFIGURE_DEPENDS
48- "${CMAKE_CURRENT_SOURCE_DIR} /src/*.cpp"
22+ # ======================================================
23+ # Target (header-only)
24+ # ======================================================
25+
26+ add_library (vix_webrpc INTERFACE )
27+ add_library (vix::webrpc ALIAS vix_webrpc )
28+
29+ target_compile_features (vix_webrpc INTERFACE cxx_std_20 )
30+
31+ target_include_directories (vix_webrpc INTERFACE
32+ $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR} /include >
33+ $<INSTALL_INTERFACE :${CMAKE_INSTALL_INCLUDEDIR} >
4934)
5035
51- # ------------------------------------------------------
52- # Target
53- # ------------------------------------------------------
54- if (WEBRPC_SOURCES)
55- message (STATUS "[webrpc] Building STATIC library with detected sources." )
56-
57- add_library (vix_webrpc STATIC ${WEBRPC_SOURCES} )
58- add_library (vix::webrpc ALIAS vix_webrpc )
59-
60- target_compile_features (vix_webrpc PUBLIC cxx_std_20 )
61-
62- target_include_directories (vix_webrpc
63- PUBLIC
64- $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR} /include >
65- $<INSTALL_INTERFACE :${CMAKE_INSTALL_INCLUDEDIR} >
66- )
67-
68- # Optional umbrella helpers if present
69- if (TARGET vix_warnings)
70- target_link_libraries (vix_webrpc PUBLIC vix_warnings )
71- endif ()
72-
73- if (VIX_ENABLE_SANITIZERS AND TARGET vix_sanitizers)
74- target_link_libraries (vix_webrpc PUBLIC vix_sanitizers )
75- endif ()
76-
77- set_target_properties (vix_webrpc PROPERTIES
78- OUTPUT_NAME vix_webrpc
79- VERSION ${PROJECT_VERSION}
80- SOVERSION 0
81- EXPORT_NAME webrpc
82- )
83-
84- install (TARGETS vix_webrpc
85- EXPORT VixTargets
86- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
87- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
88- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
89- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
90- )
91-
92- else ()
93- message (STATUS "[webrpc] Building HEADER-ONLY library (no sources)." )
94-
95- add_library (vix_webrpc INTERFACE )
96- add_library (vix::webrpc ALIAS vix_webrpc )
97-
98- target_compile_features (vix_webrpc INTERFACE cxx_std_20 )
99-
100- target_include_directories (vix_webrpc INTERFACE
101- $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR} /include >
102- $<INSTALL_INTERFACE :${CMAKE_INSTALL_INCLUDEDIR} >
103- )
104-
105- # Optional umbrella helpers if present
106- if (TARGET vix_warnings)
107- target_link_libraries (vix_webrpc INTERFACE vix_warnings )
108- endif ()
109-
110- if (VIX_ENABLE_SANITIZERS AND TARGET vix_sanitizers)
111- target_link_libraries (vix_webrpc INTERFACE vix_sanitizers )
112- endif ()
113-
114- install (TARGETS vix_webrpc
115- EXPORT VixTargets
116- INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
117- )
36+ # Optional umbrella helpers (if the parent project provides them)
37+ if (TARGET vix_warnings)
38+ target_link_libraries (vix_webrpc INTERFACE vix_warnings )
11839endif ()
11940
120- # Install headers
41+ if (VIX_ENABLE_SANITIZERS AND TARGET vix_sanitizers)
42+ target_link_libraries (vix_webrpc INTERFACE vix_sanitizers )
43+ endif ()
44+
45+ # Install target + headers
46+ install (TARGETS vix_webrpc
47+ EXPORT VixTargets
48+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
49+ )
50+
12151install (DIRECTORY include/
12252 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
12353 FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h"
12454)
12555
126- # ------------------------------------------------------
56+ # ======================================================
12757# Tests
128- # ------------------------------------------------------
58+ # ======================================================
59+
12960option (VIX_WEBRPC_BUILD_TESTS "Build webrpc module tests" OFF )
13061
13162if (VIX_WEBRPC_BUILD_TESTS)
@@ -134,27 +65,25 @@ if (VIX_WEBRPC_BUILD_TESTS)
13465 add_subdirectory (tests )
13566endif ()
13667
137- # ------------------------------------------------------
68+ # ======================================================
13869# Examples
139- # ------------------------------------------------------
70+ # ======================================================
71+
14072option (VIX_WEBRPC_BUILD_EXAMPLES "Build webrpc module examples" OFF )
14173
14274if (VIX_WEBRPC_BUILD_EXAMPLES)
14375 add_subdirectory (examples )
14476endif ()
14577
146- # ------------------------------------------------------
78+ # ======================================================
14779# Summary
148- # ------------------------------------------------------
80+ # ======================================================
81+
14982message (STATUS "------------------------------------------------------" )
15083message (STATUS "vix::webrpc configured (${PROJECT_VERSION} )" )
151- if (WEBRPC_SOURCES)
152- message (STATUS "Mode: STATIC / sources found" )
153- else ()
154- message (STATUS "Mode: HEADER-ONLY / no sources" )
155- endif ()
156- message (STATUS "Include dir: ${CMAKE_CURRENT_SOURCE_DIR} /include" )
157- message (STATUS "Build type: ${CMAKE_BUILD_TYPE} " )
158- message (STATUS "Build tests: ${VIX_WEBRPC_BUILD_TESTS} " )
159- message (STATUS "Build examples: ${VIX_WEBRPC_BUILD_EXAMPLES} " )
84+ message (STATUS "Mode: HEADER-ONLY" )
85+ message (STATUS "Include dir: ${CMAKE_CURRENT_SOURCE_DIR} /include" )
86+ message (STATUS "Build type: ${CMAKE_BUILD_TYPE} " )
87+ message (STATUS "Build tests: ${VIX_WEBRPC_BUILD_TESTS} " )
88+ message (STATUS "Build examples: ${VIX_WEBRPC_BUILD_EXAMPLES} " )
16089message (STATUS "------------------------------------------------------" )
0 commit comments