@@ -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
@@ -46,13 +46,25 @@ message("-- Detecting libinjection version - ${LIBINJECTION_VERSION}")
4646
4747target_compile_definitions (libinjection PRIVATE LIBINJECTION_VERSION="${LIBINJECTION_VERSION} " )
4848
49- # mbedtls
49+ # mbedtls (mbedcrypto)
5050
51- project (mbedtls C)
51+ project (mbedcrypto C)
5252
53- 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)
5454
55- target_include_directories (mbedtls PRIVATE ${BASE_DIR} /others)
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+ )
66+
67+ message ("-- Detecting Mbed TLS version - ${MBEDTLS_VERSION} " )
5668
5769#
5870# libModSecurity
@@ -126,8 +138,8 @@ file(GLOB_RECURSE libModSecuritySources ${BASE_DIR}/src/*.cc)
126138add_library (libModSecurity SHARED ${libModSecuritySources} )
127139
128140target_compile_definitions (libModSecurity PRIVATE WITH_PCRE2)
129- target_include_directories (libModSecurity PRIVATE ${BASE_DIR} ${BASE_DIR} /headers ${BASE_DIR} /others)
130- 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)
131143
132144macro (add_package_dependency project compile_definition link_library flag)
133145 if (${flag} )
0 commit comments