@@ -61,6 +61,8 @@ if (NOT HAS_STDBOOL AND NOT MSVC)
6161endif (NOT HAS_STDBOOL AND NOT MSVC )
6262source_group ("Header Files" FILES "${Header_Files} " )
6363
64+ option (DEBUG_TOKENISER "OFF" )
65+
6466function (generate_source_file_from_header_only filepath header_filepath source_filepath)
6567 # This function parses a header-only library file and creates a header and source file.
6668 # Care is taken so that the same conditions hold, e.g., #if FEATURE\n#include "s.h"\n#endif /* FEATURE */
@@ -172,8 +174,10 @@ function (generate_source_file_from_header_only filepath header_filepath source_
172174 OR prev_prev_char STREQUAL ":" # label (incl. case & default)
173175 ))
174176 if (line_len)
175- message (STATUS "full_line = \" ${line} \" " )
176- message (STATUS "prev_prev_char = '${prev_prev_char} '; prev_char = '${prev_char} '; char = '${char} '" )
177+ if (DEBUG_TOKENISER)
178+ message (STATUS "full_line = \" ${line} \" " )
179+ message (STATUS "prev_prev_char = '${prev_prev_char} '; prev_char = '${prev_char} '; char = '${char} '" )
180+ endif (DEBUG_TOKENISER)
177181 math (EXPR line_no "${line_no} + 1" )
178182 if (line MATCHES "^#.*endif" )
179183 list (POP_BACK conditions)
@@ -182,9 +186,12 @@ function (generate_source_file_from_header_only filepath header_filepath source_
182186 list (APPEND end_impl "${line} " )
183187 list (APPEND end_line_impl "${line_no} " )
184188 list (SUBLIST "${contents} " "${start_line_impl} " "${end_line_impl} " new_contents_l)
185- message (STATUS "start_line_impl = ${start_line_impl} " )
186- message (STATUS "end_line_impl = ${end_line_impl} " )
187- message (STATUS "new_contents_l = ${new_contents_l} " )
189+ if (DEBUG_TOKENISER)
190+ message (STATUS "start_line_impl = ${start_line_impl} " )
191+ message (STATUS "end_line_impl = ${end_line_impl} " )
192+ message (STATUS "new_contents_l = ${new_contents_l} " )
193+ endif (DEBUG_TOKENISER)
194+
188195 #string(SUBSTRING "${contents}" "${start_line_impl}" "${end_line_impl}" source_contents)
189196 set (eat_source "OFF" )
190197 set (eat_header "ON" )
@@ -193,12 +200,16 @@ function (generate_source_file_from_header_only filepath header_filepath source_
193200 elseif (line MATCHES "^#.*if" )
194201 list (APPEND conditions "${line} " )
195202 list (APPEND conditions_line "${line_no} " )
196- message (STATUS "[${line_no} ] conditions = ${conditions} " )
197- message (STATUS "[${line_no} ] conditions_line = ${conditions_line} " )
203+ if (DEBUG_TOKENISER)
204+ message (STATUS "[${line_no} ] conditions = ${conditions} " )
205+ message (STATUS "[${line_no} ] conditions_line = ${conditions_line} " )
206+ endif (DEBUG_TOKENISER)
198207 if (line MATCHES ".*LIBACQUIRE_IMPLEMENTATION.*" )
199208 list (APPEND start_impl "${line} " )
200209 list (APPEND start_line_impl "${line_no} " )
201- message (STATUS "start_impl = ${start_impl} " )
210+ if (DEBUG_TOKENISER)
211+ message (STATUS "start_impl = ${start_impl} " )
212+ endif (DEBUG_TOKENISER)
202213 set (eat_from_line_no "${line_no} " )
203214 set (eat_source "ON" )
204215 set (eat_header "OFF" )
@@ -252,11 +263,14 @@ else ()
252263
253264 add_library ("${LIBRARY_NAME} _lib" SHARED "${gen_header_files} " "${gen_source_files} " )
254265
255- find_package (LibBSD)
256- if (LibBSD_FOUND)
257- target_link_directories ("${LIBRARY_NAME} _lib" PUBLIC "${BSD_LIBRARY} " )
258- target_compile_definitions ("${LIBRARY_NAME} _lib" PUBLIC HAVE_STRNSTR=1)
259- endif (LibBSD_FOUND)
266+ if (NOT BSD)
267+ find_package (LibBSD)
268+ if (LibBSD_FOUND)
269+ target_link_directories ("${LIBRARY_NAME} _lib" PUBLIC "${BSD_LIBRARY} " )
270+ target_compile_definitions ("${LIBRARY_NAME} _lib" PUBLIC HAVE_STRNSTR=1)
271+ target_compile_definitions ("${LIBRARY_NAME} _lib" PUBLIC HAVE_LIBBSD=1)
272+ endif (LibBSD_FOUND)
273+ endif (NOT BSD)
260274
261275 message (STATUS "${LIBRARY_NAME} _lib::CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR} " )
262276 target_include_directories (
0 commit comments