Browse code

CMake: Fix libclamav pcre2 include path issue

The pcre2.h header dependency is propagated to the bytecode runtime,
lzma_sdk, yara, and regex build targets within the libclamav build
because it is included by matcher.h which is included all over the
place.

This patch adds the pcre2 dependency to the affected build targets so
that systems where pcre2 isn't in the standard include path can still
build.

Also removed CMake `PCRE2_DIR` from documentation, as it doesn't apply
to this PCRE2 detection logic that we settled on.

Micah Snyder (micasnyd) authored on 2020/08/28 04:29:37
Showing 2 changed files
... ...
@@ -413,14 +413,6 @@ on Windows, you may need to use the following options...
413 413
 
414 414
 ##### libpcre2
415 415
 
416
-Hints to find libcpre2 package:
417
-
418
-```sh
419
-  -DPCRE2_DIR="_path to libpcre2 install root_"
420
-```
421
-
422
-Or, explicitly set header & library paths:
423
-
424 416
 ```sh
425 417
   -DPCRE2_INCLUDE_DIR="_filepath of libpcre2 header directory_"
426 418
   -DPCRE2_LIBRARY="_filepath of libcpre2 library_"
... ...
@@ -43,6 +43,7 @@ set_target_properties(regex PROPERTIES
43 43
     COMPILE_FLAGS "${WARNCFLAGS}")
44 44
 target_link_libraries( regex
45 45
     PRIVATE
46
+        PCRE2::pcre2
46 47
         JSONC::jsonc )
47 48
 
48 49
 add_library( lzma_sdk OBJECT )
... ...
@@ -99,6 +100,7 @@ set_target_properties(lzma_sdk PROPERTIES
99 99
     COMPILE_FLAGS "${WARNCFLAGS}")
100 100
 target_link_libraries( lzma_sdk
101 101
     PRIVATE
102
+        PCRE2::pcre2
102 103
         JSONC::jsonc )
103 104
 
104 105
 bison_target( yara_grammar
... ...
@@ -135,6 +137,7 @@ set_target_properties(yara PROPERTIES
135 135
     COMPILE_FLAGS "${WARNCFLAGS}")
136 136
 target_link_libraries( yara
137 137
     PRIVATE
138
+        PCRE2::pcre2
138 139
         JSONC::jsonc )
139 140
 
140 141
 add_library( tomsfastmath OBJECT )
... ...
@@ -230,6 +233,35 @@ target_include_directories( tomsfastmath
230 230
 set_target_properties(tomsfastmath PROPERTIES
231 231
     COMPILE_FLAGS "${WARNCFLAGS}")
232 232
 
233
+# Bytecode Runtime
234
+add_library( bytecode_runtime OBJECT )
235
+if(LLVM_FOUND)
236
+    target_sources( bytecode_runtime
237
+        PRIVATE
238
+            c++/detect.cpp
239
+            c++/ClamBCRTChecks.cpp
240
+            c++/bytecode2llvm.cpp
241
+            bytecode_priv.h
242
+            bytecode.h )
243
+    set_target_properties(bytecode_runtime PROPERTIES
244
+        COMPILE_FLAGS "${WARNCXXFLAGS} ${CXX1XCXXFLAGS}")
245
+else()
246
+    target_sources( bytecode_runtime
247
+        PRIVATE
248
+            bytecode_nojit.c
249
+            bytecode_priv.h
250
+            bytecode.h )
251
+    set_target_properties(bytecode_runtime PROPERTIES
252
+        COMPILE_FLAGS "${WARNCFLAGS}")
253
+endif()
254
+target_include_directories( bytecode_runtime
255
+    PRIVATE ${CMAKE_BINARY_DIR}
256
+    PUBLIC  ${CMAKE_CURRENT_SOURCE_DIR} )
257
+target_link_libraries( bytecode_runtime
258
+    PRIVATE
259
+        PCRE2::pcre2
260
+        JSONC::jsonc )
261
+
233 262
 # clamav clamav_obj
234 263
 add_library( clamav_obj OBJECT )
235 264
 target_sources( clamav_obj
... ...
@@ -446,34 +478,6 @@ if(WIN32)
446 446
     target_sources( clamav_obj PRIVATE libclamav_main.c )
447 447
 endif()
448 448
 
449
-# Bytecode Runtime
450
-add_library( bytecode_runtime OBJECT )
451
-if(LLVM_FOUND)
452
-    target_sources( bytecode_runtime
453
-        PRIVATE
454
-            c++/detect.cpp
455
-            c++/ClamBCRTChecks.cpp
456
-            c++/bytecode2llvm.cpp
457
-            bytecode_priv.h
458
-            bytecode.h )
459
-    set_target_properties(bytecode_runtime PROPERTIES
460
-        COMPILE_FLAGS "${WARNCXXFLAGS} ${CXX1XCXXFLAGS}")
461
-else()
462
-    target_sources( bytecode_runtime
463
-        PRIVATE
464
-            bytecode_nojit.c
465
-            bytecode_priv.h
466
-            bytecode.h )
467
-    set_target_properties(bytecode_runtime PROPERTIES
468
-        COMPILE_FLAGS "${WARNCFLAGS}")
469
-endif()
470
-target_include_directories( bytecode_runtime
471
-    PRIVATE ${CMAKE_BINARY_DIR}
472
-    PUBLIC  ${CMAKE_CURRENT_SOURCE_DIR} )
473
-target_link_libraries( bytecode_runtime
474
-    PRIVATE
475
-        JSONC::jsonc )
476
-
477 449
 target_include_directories( clamav_obj
478 450
     PRIVATE   ${CMAKE_BINARY_DIR} ${JSONC_INCLUDE_DIRS}
479 451
     PUBLIC    ${CMAKE_CURRENT_SOURCE_DIR}