@@ -69,6 +69,26 @@ if (NOT TARGET vix::core)
6969 endif ()
7070endif ()
7171
72+ # Utils dependency
73+ if (NOT TARGET vix::utils)
74+ if (EXISTS "${CMAKE_CURRENT_LIST_DIR} /../utils/CMakeLists.txt" )
75+ message (STATUS "[websocket] Adding utils from umbrella: ../utils" )
76+ add_subdirectory ("${CMAKE_CURRENT_LIST_DIR} /../utils" "utils" )
77+ elseif (VIX_WEBSOCKET_FETCH_UTILS)
78+ include (FetchContent )
79+ message (STATUS "[websocket] Fetching vix::utils via FetchContent" )
80+ FetchContent_Declare (vix_utils
81+ GIT_REPOSITORY https://github.com/vixcpp/utils.git
82+ GIT_TAG dev
83+ )
84+ FetchContent_MakeAvailable (vix_utils)
85+ else ()
86+ message (FATAL_ERROR
87+ "vix::utils not found. Provide vix::utils before websocket "
88+ "or enable VIX_WEBSOCKET_FETCH_UTILS=ON." )
89+ endif ()
90+ endif ()
91+
7292set (VIX_CORE_TARGET vix::core)
7393set (VIX_UTILS_TARGET vix::utils)
7494
@@ -110,32 +130,50 @@ endfunction()
110130if (WEBSOCKET_SOURCES)
111131 message (STATUS "[websocket] Building STATIC library with detected sources." )
112132
113- find_package (SQLite3 REQUIRED )
114133 add_library (vix_websocket STATIC ${WEBSOCKET_SOURCES} )
115134 add_library (vix::websocket ALIAS vix_websocket )
116135 add_library (vix::ws ALIAS vix_websocket )
117136 target_compile_features (vix_websocket PUBLIC cxx_std_20 )
118137
119- if (TARGET vix_warnings)
120- target_link_libraries (vix_websocket PUBLIC vix_warnings )
138+ # SQLite
139+ find_package (SQLite3 REQUIRED )
140+
141+ # Normalize to SQLite::SQLite3 everywhere
142+ if (TARGET SQLite::SQLite3)
143+ # ok
144+ elseif (TARGET SQLite3::SQLite3)
145+ add_library (SQLite::SQLite3 ALIAS SQLite3::SQLite3 )
146+ elseif (TARGET sqlite3)
147+ add_library (SQLite::SQLite3 ALIAS sqlite3 )
121148 endif ()
122149
123- if (TARGET vix_sanitizers )
124- target_link_libraries ( vix_websocket PUBLIC vix_sanitizers )
150+ if (NOT TARGET SQLite::SQLite3 )
151+ message ( FATAL_ERROR "[websocket] SQLite requested but no usable SQLite target was found." )
125152 endif ()
126153
154+ # includes
127155 target_include_directories (vix_websocket
128156 PUBLIC
129157 $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR} /include >
130158 $<INSTALL_INTERFACE :${CMAKE_INSTALL_INCLUDEDIR} >
131159 )
132160
161+ # link deps
133162 target_link_libraries (vix_websocket
134163 PUBLIC
135164 ${VIX_CORE_TARGET}
165+ ${VIX_UTILS_TARGET}
136166 SQLite::SQLite3
137167 )
138168
169+ if (TARGET vix_warnings)
170+ target_link_libraries (vix_websocket PUBLIC vix_warnings )
171+ endif ()
172+
173+ if (TARGET vix_sanitizers)
174+ target_link_libraries (vix_websocket PUBLIC vix_sanitizers )
175+ endif ()
176+
139177 vix_websocket_try_link_json (vix_websocket PUBLIC )
140178
141179 set_target_properties (vix_websocket PROPERTIES
@@ -152,12 +190,13 @@ if (WEBSOCKET_SOURCES)
152190 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
153191 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
154192 )
155- install (DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
156- FILES_MATCHING
157- PATTERN "*.hpp"
158- PATTERN "*.h"
159- PATTERN "*.inc" )
160193
194+ install (DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
195+ FILES_MATCHING
196+ PATTERN "*.hpp"
197+ PATTERN "*.h"
198+ PATTERN "*.inc"
199+ )
161200# HEADER-ONLY
162201else ()
163202 message (STATUS "[websocket] Building HEADER-ONLY library (no sources)." )
0 commit comments