diff --git a/CMakeLists.txt b/CMakeLists.txt index 246c386..cbb9b8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,8 @@ set(PROXYRES_HDRS include/proxyres/config.h include/proxyres/log.h include/proxyres/proxyres.h - include/proxyres/resolver.h) + include/proxyres/resolver.h + ${PROJECT_BINARY_DIR}/proxyres_config.h) if(PROXYRES_EXECUTE) list(APPEND PROXYRES_HDRS include/proxyres/execute.h) @@ -254,6 +255,13 @@ if(PROXYRES_USE_CXX) endif() endif() +if(NOT WIN32) + check_include_file("net/if_arp.h" HAVE_NET_IF_ARP_H) + check_include_file("netdb.h" HAVE_NETDB_H) +endif() + +configure_file(proxyres_config.h.in proxyres_config.h @ONLY NEWLINE_STYLE UNIX) + add_library(proxyres ${PROXYRES_HDRS} ${PROXYRES_SRCS} ${PROXYRES_C_SRCS}) set_property(TARGET proxyres PROPERTY C_STANDARD 11 CXX_STANDARD 11) if(PROXYRES_BUILD_TESTS) @@ -261,17 +269,11 @@ if(PROXYRES_BUILD_TESTS) endif() target_include_directories(proxyres PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include/proxyres) + ${CMAKE_CURRENT_SOURCE_DIR}/include/proxyres + ${PROJECT_BINARY_DIR}) target_include_directories(proxyres PUBLIC $) -if(NOT WIN32) - check_include_file("net/if_arp.h" HAVE_NET_IF_ARP_H) - if(HAVE_NET_IF_ARP_H) - target_compile_definitions(proxyres PRIVATE HAVE_NET_IF_ARP_H) - endif() -endif() - if(PROXYRES_CURL AND (PROXYRES_EXECUTE OR PROXYRES_BUILD_CLI)) if(NOT TARGET CURL::libcurl) include(FetchContent) diff --git a/fetch_posix.c b/fetch_posix.c index bf4f0a9..95584ba 100644 --- a/fetch_posix.c +++ b/fetch_posix.c @@ -1,3 +1,5 @@ +#include "proxyres_config.h" + #include #include #include @@ -6,13 +8,16 @@ #include #include +#if HAVE_NETDB_H +# include +#endif + #ifdef _WIN32 # include # include #else # include # include -# include # include #endif diff --git a/net_adapter_linux.c b/net_adapter_linux.c index 3725ff1..3cfa2d1 100644 --- a/net_adapter_linux.c +++ b/net_adapter_linux.c @@ -1,12 +1,17 @@ +#include "proxyres_config.h" + #include #include #include #include #include +#if HAVE_NETDB_H +# include +#endif + #include #include -#include #include #include #include diff --git a/net_adapter_mac.c b/net_adapter_mac.c index b49d3f6..ec46e03 100644 --- a/net_adapter_mac.c +++ b/net_adapter_mac.c @@ -1,3 +1,5 @@ +#include "proxyres_config.h" + #include #include #include diff --git a/net_util.c b/net_util.c index 43fcb22..833e986 100644 --- a/net_util.c +++ b/net_util.c @@ -1,3 +1,5 @@ +#include "proxyres_config.h" + #include #include #include @@ -6,6 +8,10 @@ #include #include +#if HAVE_NETDB_H +# include +#endif + #ifdef _WIN32 # include # include @@ -13,7 +19,6 @@ # include # include # include -# include # include #endif diff --git a/proxyres_config.h.in b/proxyres_config.h.in new file mode 100644 index 0000000..2158a11 --- /dev/null +++ b/proxyres_config.h.in @@ -0,0 +1,5 @@ +// Define to 1 if you have the header file. +#cmakedefine HAVE_NET_IF_ARP_H 1 + +// Define to 1 if you have the header file. +#cmakedefine HAVE_NETDB_H 1 diff --git a/wpad_dhcp_posix.c b/wpad_dhcp_posix.c index cf0c430..407e036 100644 --- a/wpad_dhcp_posix.c +++ b/wpad_dhcp_posix.c @@ -1,3 +1,5 @@ +#include "proxyres_config.h" + #include #include #include @@ -7,6 +9,10 @@ #include #include +#if HAVE_NETDB_H +# include +#endif + #ifdef _WIN32 # include # include @@ -15,7 +21,6 @@ # include # include # include -# include # include #endif diff --git a/wpad_dns.c b/wpad_dns.c index 09d650a..8c783d9 100644 --- a/wpad_dns.c +++ b/wpad_dns.c @@ -1,3 +1,5 @@ +#include "proxyres_config.h" + #include #include #include @@ -6,6 +8,10 @@ #include #include +#if HAVE_NETDB_H +# include +#endif + #ifdef _WIN32 # include # include @@ -13,7 +19,6 @@ #else # include # include -# include # include #endif