From 42b29fbb634345dc57c5a5965e3a06527e6bf979 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Mon, 27 Nov 2017 12:13:04 +0800 Subject: [PATCH] Fix cmake builds --- CMakeLists.txt | 3 ++- cmake/config.h.cmake | 6 ++++++ cmake/configure.cmake | 5 +++-- src/local.c | 2 -- src/netutils.h | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04e8ad22..1f94daa8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,8 @@ option(WITH_STATIC "build with static libraries." ON) # Run platform tests include(${CMAKE_SOURCE_DIR}/cmake/configure.cmake) -configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_SOURCE_DIR}/src/config.h) +configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_BINARY_DIR}/src/config.h) +add_definitions(-I$(CMAKE_BINARY_DIR)/src) add_definitions(-DHAVE_CONFIG_H) # pkg-config diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 3b7b6ff3..3a627f7c 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -53,6 +53,12 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LINUX_IF_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LINUX_TCP_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETINET_TCP_H + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LINUX_NETFILTER_IPV4_H 1 diff --git a/cmake/configure.cmake b/cmake/configure.cmake index 97fb814a..2a8660e6 100644 --- a/cmake/configure.cmake +++ b/cmake/configure.cmake @@ -43,6 +43,8 @@ check_function_exists(memset HAVE_MEMSET) check_include_files(netdb.h HAVE_NETDB_H) check_include_files(netinet/in.h HAVE_NETINET_IN_H) +check_include_files(netinet/tcp.h HAVE_NETINET_TCP_H) +check_include_files(linux/tcp.h HAVE_LINUX_TCP_H) check_include_files(net/if.h HAVE_NET_IF_H) check_include_files(pcre.h HAVE_PCRE_H) check_include_files(pcre/pcre.h HAVE_PCRE_PCRE_H) @@ -87,8 +89,7 @@ set(NDEBUG 1) set(PACKAGE ${PROJECT_NAME}) set(PACKAGE_BUGREPORT max.c.lv@gmail.com) set(PACKAGE_NAME ${PROJECT_NAME}) -#set(PACKAGE_VERSION ${PROJECT_VERSION}) -set(PACKAGE_VERSION 3.0.2) +set(PACKAGE_VERSION ${PROJECT_VERSION}) set(PACKAGE_STRING "${PROJECT_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME ${PROJECT_NAME}) set(PACKAGE_URL "") diff --git a/src/local.c b/src/local.c index e9ca4f88..5bf12e6e 100644 --- a/src/local.c +++ b/src/local.c @@ -38,10 +38,8 @@ #include #include #include -#include #ifdef LIB_ONLY -#include #include "shadowsocks.h" #endif diff --git a/src/netutils.h b/src/netutils.h index 80dcb221..aa8386a9 100644 --- a/src/netutils.h +++ b/src/netutils.h @@ -25,7 +25,7 @@ #include -#if HAVE_LINUX_TCP_H +#ifdef HAVE_LINUX_TCP_H #include #elif defined(HAVE_NETINET_TCP_H) #include