# CMakeFiles for 3rd vendor library

include(ExternalProject)

### OpenSSL 1.1.1
ExternalProject_Add(OpenSSL PREFIX openssl
        URL ${CMAKE_CURRENT_SOURCE_DIR}/openssl-1.1.1l.tar.gz
        URL_MD5 ac0d4387f3ba0ad741b0580dd45f6ff3
        CONFIGURE_COMMAND ./Configure enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers linux-x86_64 --prefix=<INSTALL_DIR> --openssldir=<INSTALL_DIR>/lib/ssl
							enable-ec_nistp_64_gcc_128 no-shared
		BUILD_COMMAND ${MAKE_COMMAND}
		INSTALL_COMMAND make install_sw
        BUILD_IN_SOURCE 1)

ExternalProject_Get_Property(OpenSSL INSTALL_DIR)
set(OPENSSL_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
set(OPENSSL_LINK_DIRECTORIES ${INSTALL_DIR}/lib)
set(OPENSSL_PKGCONFIG_PATH ${INSTALL_DIR}/lib/pkgconfig/)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

add_library(openssl-crypto-static STATIC IMPORTED GLOBAL)
add_dependencies(openssl-crypto-static OpenSSL)
set_property(TARGET openssl-crypto-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libcrypto.a)
set_property(TARGET openssl-crypto-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

add_library(openssl-ssl-static STATIC IMPORTED GLOBAL)
add_dependencies(openssl-ssl-static OpenSSL)
set_property(TARGET openssl-ssl-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libssl.a)
set_property(TARGET openssl-ssl-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

### Libevent 2.1.8
ExternalProject_Add(libevent PREFIX libevent
        URL ${CMAKE_CURRENT_SOURCE_DIR}/libevent-2.1.8-stable.tar.gz
        URL_MD5 f3eeaed018542963b7d2416ef1135ecc
        CONFIGURE_COMMAND PKG_CONFIG_PATH=${OPENSSL_PKGCONFIG_PATH}
		                  ./configure --prefix=<INSTALL_DIR> --disable-shared --disable-samples
        BUILD_COMMAND make LDFLAGS="-ldl"
        BUILD_IN_SOURCE 1
		DEPENDS OpenSSL)

ExternalProject_Get_Property(libevent INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

add_library(libevent-static STATIC IMPORTED GLOBAL)
add_dependencies(libevent-static libevent)
set_property(TARGET libevent-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libevent.a)
set_property(TARGET libevent-static PROPERTY IMPORTED_INTERFACE_LINK_LIBRARIES pthread crypto)
set_property(TARGET libevent-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

add_library(libevent-static-openssl STATIC IMPORTED GLOBAL)
add_dependencies(libevent-static-openssl libevent)
set_property(TARGET libevent-static-openssl PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libevent_openssl.a)
set_property(TARGET libevent-static-openssl PROPERTY IMPORTED_INTERFACE_LINK_LIBRARIES pthread crypto)
set_property(TARGET libevent-static-openssl PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

add_library(libevent-static-pthreads STATIC IMPORTED GLOBAL)
add_dependencies(libevent-static-pthreads libevent)
set_property(TARGET libevent-static-pthreads PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libevent_pthreads.a)
set_property(TARGET libevent-static-pthreads PROPERTY IMPORTED_INTERFACE_LINK_LIBRARIES pthread crypto)
set_property(TARGET libevent-static-pthreads PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

### http parser
ExternalProject_Add(http-parser PREFIX http-parser
        URL ${CMAKE_CURRENT_SOURCE_DIR}/http-parser-2.9.0.tar.gz
        URL_MD5 203c6fbb7e24714fd22398f2a9c5c210
        CONFIGURE_COMMAND ""
        BUILD_COMMAND make package
        INSTALL_COMMAND ""
        BUILD_IN_SOURCE 1)

ExternalProject_Get_Property(http-parser SOURCE_DIR)
set(HTTP_PARSER_INCLUDE_DIRECTORIES ${SOURCE_DIR})
file(MAKE_DIRECTORY ${HTTP_PARSER_INCLUDE_DIRECTORIES})

add_library(http-parser-static STATIC IMPORTED GLOBAL)
add_dependencies(http-parser-static http-parser)
set_property(TARGET http-parser-static PROPERTY IMPORTED_LOCATION ${SOURCE_DIR}/libhttp_parser.a)
set_property(TARGET http-parser-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR})

### nghttp2
ExternalProject_Add(nghttp2
        PREFIX nghttp2
        URL ${CMAKE_CURRENT_SOURCE_DIR}/nghttp2-1.24.0.tar.gz
		URL_MD5 3827e6feed304f09442336dbf781e023
        CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR> --disable-shared
        BUILD_IN_SOURCE 1)

ExternalProject_Get_Property(nghttp2 INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
file(MAKE_DIRECTORY ${INSTALL_DIR}/src/nghttp2/lib)

add_library(nghttp2-static STATIC IMPORTED GLOBAL)
add_dependencies(nghttp2-static nghttp2)
set_property(TARGET nghttp2-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libnghttp2.a)
set_property(TARGET nghttp2-static APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include;${INSTALL_DIR}/src/nghttp2/lib)

### ratelimiter
ExternalProject_Add(ratelimiter PREFIX ratelimiter
        URL ${CMAKE_CURRENT_SOURCE_DIR}/ratelimiter-1.1.0-x86_64.tar.gz
		URL_MD5 6e4b9b31c70b9e84e2a6434fab6268f9
		CONFIGURE_COMMAND ""
		BUILD_COMMAND make
        BUILD_IN_SOURCE 1)

ExternalProject_Get_Property(ratelimiter INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

add_library(ratelimiter-static STATIC IMPORTED GLOBAL)
add_dependencies(ratelimiter-static ratelimiter)
set_property(TARGET ratelimiter-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libratelimiter.a)
set_property(TARGET ratelimiter-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

#### GoogleTest
ExternalProject_Add(googletest PREFIX googletest
        URL ${CMAKE_CURRENT_SOURCE_DIR}/googletest-release-1.8.0.tar.gz
        URL_MD5 16877098823401d1bf2ed7891d7dce36
        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})

ExternalProject_Get_Property(googletest INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

add_library(gtest STATIC IMPORTED GLOBAL)
add_dependencies(gtest googletest)
set_property(TARGET gtest PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libgtest.a)
set_property(TARGET gtest PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
set_property(TARGET gtest PROPERTY INTERFACE_LINK_LIBRARIES pthread)

add_library(gmock STATIC IMPORTED GLOBAL)
add_dependencies(gmock googletest)
set_property(TARGET gmock PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libgmock.a)
set_property(TARGET gmock PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)


### MESA Framework
# Consider the MESA Framework is installed in the system. We declare a imported target instead of
# ExternalProject target. we may retrive the MESAFramework source code from git.mesalab.cn and
# compile staticly to TFE binarys in the future.

set(MESA_FRAMEWORK_LIB_DIR /opt/MESA/lib)
set(MESA_FRAMEWORK_INCLUDE_DIR /opt/MESA/include)
set(MRZCPD_LIB_DIR /opt/mrzcpd/lib)
set(MRZCPD_INCLUDE_DIR /opt/mrzcpd/include)

add_library(MESA_handle_logger SHARED IMPORTED GLOBAL)
set_property(TARGET MESA_handle_logger PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libMESA_handle_logger.so)
set_property(TARGET MESA_handle_logger PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})

add_library(MESA_prof_load SHARED IMPORTED GLOBAL)
set_property(TARGET MESA_prof_load PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libMESA_prof_load.so)
set_property(TARGET MESA_prof_load PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})

add_library(wiredcfg SHARED IMPORTED GLOBAL)
set_property(TARGET wiredcfg PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libwiredcfg.so)
set_property(TARGET wiredcfg PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})

add_library(MESA_htable SHARED IMPORTED GLOBAL)
set_property(TARGET MESA_htable PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libMESA_htable.so)
set_property(TARGET MESA_htable PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})

add_library(wiredLB SHARED IMPORTED GLOBAL)
set_property(TARGET wiredLB PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libWiredLB.so)
set_property(TARGET wiredLB PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})

add_library(maatframe SHARED IMPORTED GLOBAL)
set_property(TARGET maatframe PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libmaat4.so)
set_property(TARGET maatframe PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})

add_library(MESA_field_stat SHARED IMPORTED GLOBAL)
set_property(TARGET MESA_field_stat PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libMESA_field_stat2.so)
set_property(TARGET MESA_field_stat PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})

add_library(fieldstat3 SHARED IMPORTED GLOBAL)
set_property(TARGET fieldstat3 PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libfieldstat3.so)
set_property(TARGET fieldstat3 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})

add_library(rdkafka SHARED IMPORTED GLOBAL)
set_property(TARGET rdkafka PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/librdkafka.so)
set_property(TARGET rdkafka PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR}/MESA)

add_library(tsglua SHARED IMPORTED GLOBAL)
set_property(TARGET tsglua PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libelua.so)
set_property(TARGET tsglua PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})

add_library(mrzcpd SHARED IMPORTED GLOBAL)
set_property(TARGET mrzcpd PROPERTY IMPORTED_LOCATION ${MRZCPD_LIB_DIR}/libmarsio.so)
set_property(TARGET mrzcpd PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MRZCPD_INCLUDE_DIR})

add_library(breakpad_mini SHARED IMPORTED GLOBAL)
set_property(TARGET breakpad_mini PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libbreakpad_mini.so)
set_property(TARGET breakpad_mini PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})

### cJSON
ExternalProject_Add(cJSON PREFIX cJSON
        URL ${CMAKE_CURRENT_SOURCE_DIR}/cJSON-1.7.7.tar.gz
        URL_MD5 715009c99728bf81d6c97352718650ff
        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
				   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
				   -DBUILD_SHARED_AND_STATIC_LIBS=1)

ExternalProject_Get_Property(cJSON INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

add_library(cjson SHARED IMPORTED GLOBAL)
add_dependencies(cjson cJSON)
set_property(TARGET cjson PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib64/libcjson.a)
set_property(TARGET cjson PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

#### librdkafka
#ExternalProject_Add(librdkafka PREFIX librdkafka
#        URL ${CMAKE_CURRENT_SOURCE_DIR}/librdkafka-0.11.5.tar.gz
#        URL_MD5 90bb43499252317ae55723d32ccacf18
#        CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR>
#        BUILD_IN_SOURCE 1)
#ExternalProject_Get_Property(librdkafka INSTALL_DIR)
#file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
#
#add_library(librdkafka-static STATIC IMPORTED GLOBAL)
#add_dependencies(librdkafka-static librdkafka)
#set_property(TARGET librdkafka-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/librdkafka.a)
#set_property(TARGET librdkafka-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
#set_property(TARGET librdkafka-static PROPERTY INTERFACE_LINK_LIBRARIES ssl crypto sasl2 m z dl pthread rt)

### ctemplate
ExternalProject_Add(ctemplate PREFIX ctemplate
        URL ${CMAKE_CURRENT_SOURCE_DIR}/ctemplate-2.3.tar.gz
        URL_MD5 3b91f3c1e7aa55cb4c2957acf77d6b9a
        PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_LIST_DIR}/patch/compile_ctemplate_use_centos8_with_gcc7.patch
        BUILD_COMMAND sh autogen.sh
        CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR>
        BUILD_IN_SOURCE 1)

ExternalProject_Get_Property(ctemplate INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

add_library(ctemplate-static STATIC IMPORTED GLOBAL)
add_dependencies(ctemplate-static ctemplate)
set_property(TARGET ctemplate-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libctemplate.a)
set_property(TARGET ctemplate-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

### pcre2
ExternalProject_Add(pcre2 PREFIX pcre2
        URL ${CMAKE_CURRENT_SOURCE_DIR}/pcre2-10.32.tar.gz
        URL_MD5 a660db882ff171e6a0de5fb1decd5ff5
        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})

ExternalProject_Get_Property(pcre2 INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

add_library(pcre2-static STATIC IMPORTED GLOBAL)
add_dependencies(pcre2-static pcre2)
set_property(TARGET pcre2-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libpcre2-8.a)
set_property(TARGET pcre2-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

### libxml2
ExternalProject_Add(libxml2
        PREFIX libxml2
        URL ${CMAKE_CURRENT_SOURCE_DIR}/libxml2-2.9.2.tar.gz
        URL_MD5 9e6a9aca9d155737868b3dc5fd82f788
        CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR> --disable-shared --without-python
        BUILD_IN_SOURCE 1)

ExternalProject_Get_Property(libxml2 INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include/libxml2/)

add_library(libxml2-static STATIC IMPORTED GLOBAL)
add_dependencies(libxml2-static libxml2)
set_property(TARGET libxml2-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libxml2.a)
set_property(TARGET libxml2-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include/libxml2/)

### libcurl
ExternalProject_Add(libcurl
        PREFIX libcurl
        URL ${CMAKE_CURRENT_SOURCE_DIR}/curl-7.59.0.tar.gz
        URL_MD5 a44f98c25c7506e7103039b542aa5ad8
        CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR> --disable-shared --without-libidn2 --without-ssl --disable-ldap
        BUILD_IN_SOURCE 1)

ExternalProject_Get_Property(libcurl INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

add_library(libcurl-static STATIC IMPORTED GLOBAL)
add_dependencies(libcurl-static libcurl)
set_property(TARGET libcurl-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libcurl.a)
set_property(TARGET libcurl-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

### hiredis
ExternalProject_Add(hiredisCluster PREFIX hiredisCluster
        URL ${CMAKE_CURRENT_SOURCE_DIR}/hiredis-vip-0.3.0.zip
        URL_MD5 8d0636f911d4a4a6ec8aeff2abb5bc0f
        CONFIGURE_COMMAND ""
        BUILD_COMMAND make
        INSTALL_COMMAND make install
        BUILD_IN_SOURCE 1)

ExternalProject_Get_Property(hiredisCluster SOURCE_DIR)
set(HIREDIS_INCLUDE_DIRECTORIES ${SOURCE_DIR}/out/include/)
file(MAKE_DIRECTORY ${HIREDIS_INCLUDE_DIRECTORIES})

add_library(hiredis-static STATIC IMPORTED GLOBAL)
add_dependencies(libcurl-static hiredisCluster)
set_property(TARGET hiredis-static PROPERTY IMPORTED_LOCATION ${SOURCE_DIR}/libhiredis_vip.a)
set_property(TARGET hiredis-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${HIREDIS_INCLUDE_DIRECTORIES})

### dablooms
ExternalProject_Add(dablooms PREFIX dablooms
        URL ${CMAKE_CURRENT_SOURCE_DIR}/dablooms-0.9.2.tar.gz
        URL_MD5 5280ba7388ec901d9721cd497e45be37
        CONFIGURE_COMMAND ""
        BUILD_COMMAND make
        INSTALL_COMMAND make install prefix=<INSTALL_DIR>
        BUILD_IN_SOURCE 1)

ExternalProject_Get_Property(dablooms INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

add_library(libdablooms SHARED IMPORTED GLOBAL)
add_dependencies(libdablooms dablooms)
set_property(TARGET libdablooms PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libdablooms.a)
set_property(TARGET libdablooms PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

#### Brotli
ExternalProject_Add(brotli PREFIX brotli
		URL ${CMAKE_CURRENT_SOURCE_DIR}/brotli-1.0.7.tar.gz
		URL_MD5 7b6edd4f2128f22794d0ca28c53898a5
		CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})

ExternalProject_Get_Property(brotli INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

add_library(brotlicommon-static STATIC IMPORTED GLOBAL)
add_dependencies(brotlicommon-static brotli)
set_property(TARGET brotlicommon-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib64/libbrotlicommon-static.a)
set_property(TARGET brotlicommon-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

add_library(brotlidec-static STATIC IMPORTED GLOBAL)
add_dependencies(brotlidec-static brotli)
set_property(TARGET brotlidec-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib64/libbrotlidec-static.a)
set_property(TARGET brotlidec-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
target_link_libraries(brotlidec-static INTERFACE brotlicommon-static)

add_library(brotlienc-static STATIC IMPORTED GLOBAL)
add_dependencies(brotlienc-static brotli)
set_property(TARGET brotlienc-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib64/libbrotlienc-static.a)
set_property(TARGET brotlienc-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
target_link_libraries(brotlienc-static INTERFACE brotlicommon-static)

### libnetfilter_queue
ExternalProject_Add(libnetfilter_queue PREFIX libnetfilter_queue
        URL ${CMAKE_CURRENT_SOURCE_DIR}/libnetfilter_queue-1.0.5.tar.bz2
        URL_MD5 ce807654358481efaa826fec33c89b6a
        CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR> --enable-static=yes --enable-shared=no
        BUILD_IN_SOURCE 1)

ExternalProject_Get_Property(libnetfilter_queue INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

add_library(libnetfilter_queue-static STATIC IMPORTED GLOBAL)
add_dependencies(libnetfilter_queue-static libnetfilter_queue)
set_property(TARGET libnetfilter_queue-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libnetfilter_queue.a)
set_property(TARGET libnetfilter_queue-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

### gperftools
#ExternalProject_Add(gperftools
#        PREFIX gperftools
#        URL ${CMAKE_CURRENT_SOURCE_DIR}/gperftools-2.8.tar.gz
#        URL_MD5 ea61ad1e886f53e4069873ce52cae7df
#        PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_LIST_DIR}/patch/gperftools-fix_too_small_heap_profile_buffer_size.patch
#        CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR> --disable-shared
#        BUILD_IN_SOURCE 1)

#ExternalProject_Get_Property(gperftools INSTALL_DIR)
#file(MAKE_DIRECTORY ${INSTALL_DIR}/include)

#add_library(gperftools-static STATIC IMPORTED GLOBAL)
#add_dependencies(gperftools-static gperftools)
#set_property(TARGET gperftools-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libtcmalloc.a)
#set_property(TARGET gperftools-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
