@@ -14,7 +14,7 @@ option(USE_ASAN "Build with Address Sanitizer" OFF)
1414
1515# NOTE: MBEDTLS_CONFIG_FILE is not only required to compile the mbedtls subset in others, but also
1616# when their headers are included while compiling libModSecurity
17- add_compile_definitions (WIN32 _CRT_SECURE_NO_WARNINGS MBEDTLS_CONFIG_FILE="mbed-tls-config .h" )
17+ add_compile_definitions (WIN32 _CRT_SECURE_NO_WARNINGS MBEDTLS_CONFIG_FILE="mbedtls/mbedtls_config .h" )
1818
1919# set standards conformance preprocessor & compiler to align with cross-compiled codebase
2020# NOTE: otherwise visual c++'s default compiler/preprocessor behaviour generates C4067 warnings
@@ -30,15 +30,41 @@ endif()
3030
3131project (libinjection C)
3232
33- add_library (libinjection STATIC ${BASE_DIR} /others/libinjection/src/libinjection_sqli.c ${BASE_DIR} /others/libinjection/src/libinjection_xss.c ${BASE_DIR} /others/libinjection/src/libinjection_html5.c )
33+ set (LIBINJECTION_DIR ${BASE_DIR} /others/libinjection)
3434
35- # mbedtls
35+ add_library (libinjection STATIC ${LIBINJECTION_DIR} /src/libinjection_sqli.c ${LIBINJECTION_DIR} /src/libinjection_xss.c ${LIBINJECTION_DIR} /src/libinjection_html5.c)
3636
37- project (mbedtls C)
37+ # get libinjection version with git describe
38+ execute_process (
39+ COMMAND git describe
40+ WORKING_DIRECTORY ${LIBINJECTION_DIR}
41+ OUTPUT_VARIABLE LIBINJECTION_VERSION
42+ OUTPUT_STRIP_TRAILING_WHITESPACE
43+ )
44+
45+ message ("-- Detecting libinjection version - ${LIBINJECTION_VERSION} " )
46+
47+ target_compile_definitions (libinjection PRIVATE LIBINJECTION_VERSION="${LIBINJECTION_VERSION} " )
48+
49+ # mbedtls (mbedcrypto)
50+
51+ project (mbedcrypto C)
3852
39- add_library (mbedtls STATIC ${BASE_DIR} /others/mbedtls/base64.c ${BASE_DIR} /others/mbedtls/sha1.c ${BASE_DIR} /others/mbedtls/md5.c)
53+ set (MBEDTLS_DIR ${BASE_DIR} /others/mbedtls)
54+
55+ add_library (mbedcrypto STATIC ${MBEDTLS_DIR} /library/base64.c ${MBEDTLS_DIR} /library/sha1.c ${MBEDTLS_DIR} /library/md5.c ${MBEDTLS_DIR} /library/platform_util.c ${MBEDTLS_DIR} /library/constant_time.c)
56+
57+ target_include_directories (mbedcrypto PRIVATE ${MBEDTLS_DIR} /include )
58+
59+ # get mbedtls version with git describe
60+ execute_process (
61+ COMMAND git describe
62+ WORKING_DIRECTORY ${MBEDTLS_DIR}
63+ OUTPUT_VARIABLE MBEDTLS_VERSION
64+ OUTPUT_STRIP_TRAILING_WHITESPACE
65+ )
4066
41- target_include_directories (mbedtls PRIVATE ${BASE_DIR} /others )
67+ message ( "-- Detecting Mbed TLS version - ${MBEDTLS_VERSION} " )
4268
4369#
4470# libModSecurity
@@ -112,8 +138,8 @@ file(GLOB_RECURSE libModSecuritySources ${BASE_DIR}/src/*.cc)
112138add_library (libModSecurity SHARED ${libModSecuritySources} )
113139
114140target_compile_definitions (libModSecurity PRIVATE WITH_PCRE2)
115- target_include_directories (libModSecurity PRIVATE ${BASE_DIR} ${BASE_DIR} /headers ${BASE_DIR} /others)
116- target_link_libraries (libModSecurity PRIVATE pcre2::pcre2 pthreads4w::pthreads4w libinjection mbedtls Poco::Poco Iphlpapi.lib)
141+ target_include_directories (libModSecurity PRIVATE ${BASE_DIR} ${BASE_DIR} /headers ${BASE_DIR} /others ${MBEDTLS_DIR} / include )
142+ target_link_libraries (libModSecurity PRIVATE pcre2::pcre2 pthreads4w::pthreads4w libinjection mbedcrypto Poco::Poco Iphlpapi.lib)
117143
118144macro (add_package_dependency project compile_definition link_library flag)
119145 if (${flag} )
0 commit comments