Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment thread
nmoinvaz marked this conversation as resolved.
if(PROXYRES_EXECUTE)
list(APPEND PROXYRES_HDRS
include/proxyres/execute.h)
Expand Down Expand Up @@ -254,24 +255,25 @@ 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)
Comment thread
sergio-nsk marked this conversation as resolved.
endif()

configure_file(proxyres_config.h.in proxyres_config.h @ONLY NEWLINE_STYLE UNIX)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is roxyres_config.h.in defined?

@sergio-nsk sergio-nsk Mar 28, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proxyres_config.h.in - is a new file in the commit.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about the name build_config.h?

@sergio-nsk sergio-nsk Mar 30, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other projects use such template <project>_config.h because build_config.h from distinct client projects would conflict. build_config.h is a free name in our code, but proxyres is OSS and we can break other user projects.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I wonder about this now that I approved it, because proxyres_config.h is only used internally. Not externally. But you are suggesting that it would be used externally?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't suggest it, and -I${PROJECT_BINARY_DIR} is in the private target properties. User -I order is unpredictable, so it's better to use a more unique header name than a less unique one.


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)
target_compile_definitions(proxyres PRIVATE PROXYRES_TESTING)
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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)

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)
Expand Down
7 changes: 6 additions & 1 deletion fetch_posix.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "proxyres_config.h"

#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
Expand All @@ -6,13 +8,16 @@
#include <string.h>
#include <errno.h>

#if HAVE_NETDB_H
# include <netdb.h>
#endif
Comment thread
sergio-nsk marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.

#ifdef _WIN32
# include <winsock2.h>
# include <ws2tcpip.h>
#else
# include <sys/types.h>
# include <sys/socket.h>
# include <netdb.h>
# include <unistd.h>
#endif

Expand Down
7 changes: 6 additions & 1 deletion net_adapter_linux.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#include "proxyres_config.h"

#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#if HAVE_NETDB_H
# include <netdb.h>
#endif

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
#include <ifaddrs.h>
#include <net/if.h>
Expand Down
2 changes: 2 additions & 0 deletions net_adapter_mac.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "proxyres_config.h"

#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
Expand Down
7 changes: 6 additions & 1 deletion net_util.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "proxyres_config.h"

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
Expand All @@ -6,14 +8,17 @@
#include <string.h>
#include <errno.h>

#if HAVE_NETDB_H
# include <netdb.h>
#endif
Comment thread
sergio-nsk marked this conversation as resolved.

#ifdef _WIN32
# include <winsock2.h>
# include <ws2tcpip.h>
#else
# include <arpa/inet.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netdb.h>
# include <unistd.h>
#endif

Expand Down
5 changes: 5 additions & 0 deletions proxyres_config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Define to 1 if you have the <net/if_arp.h> header file.
#cmakedefine HAVE_NET_IF_ARP_H 1

// Define to 1 if you have the <netdb.h> header file.
#cmakedefine HAVE_NETDB_H 1
Comment thread
sergio-nsk marked this conversation as resolved.
7 changes: 6 additions & 1 deletion wpad_dhcp_posix.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "proxyres_config.h"

#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
Expand All @@ -7,6 +9,10 @@
#include <time.h>
#include <errno.h>

#if HAVE_NETDB_H
# include <netdb.h>
#endif

#ifdef _WIN32
# include <winsock2.h>
# include <ws2tcpip.h>
Expand All @@ -15,7 +21,6 @@
# include <arpa/inet.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netdb.h>
# include <unistd.h>
#endif

Expand Down
7 changes: 6 additions & 1 deletion wpad_dns.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "proxyres_config.h"

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
Expand All @@ -6,14 +8,17 @@
#include <string.h>
#include <errno.h>

#if HAVE_NETDB_H
# include <netdb.h>
#endif

#ifdef _WIN32
# include <winsock2.h>
# include <ws2tcpip.h>
# include <windows.h>
#else
# include <sys/types.h>
# include <sys/socket.h>
# include <netdb.h>
# include <unistd.h>
#endif

Expand Down
Loading