Skip to content

Commit

Permalink
CMake: Ensure discovered include dirs are considered
Browse files Browse the repository at this point in the history
...during header checks. Otherwise some following header tests
(incorrectly) fail.

Closes #436
  • Loading branch information
jzakrzewski authored and bagder committed Sep 23, 2015
1 parent 7c478ca commit 4d60e12
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -355,19 +355,22 @@ if(NOT CURL_DISABLE_LDAP)
check_include_file_concat("winber.h" HAVE_WINBER_H)
endif()

set(CMAKE_REQUIRED_INCLUDES_BAK ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory")
if(CMAKE_LDAP_INCLUDE_DIR)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_LDAP_INCLUDE_DIR})
list(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_LDAP_INCLUDE_DIR})
endif()
check_include_file_concat("ldap.h" HAVE_LDAP_H)
check_include_file_concat("lber.h" HAVE_LBER_H)

if(NOT HAVE_LDAP_H)
message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON")
set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used
elseif(NOT HAVE_LIBLDAP)
message(STATUS "LDAP library '${CMAKE_LDAP_LIB}' not found CURL_DISABLE_LDAP set ON")
set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used
else()
if(CMAKE_USE_OPENLDAP)
set(USE_OPENLDAP ON)
Expand Down Expand Up @@ -448,6 +451,7 @@ if(CURL_ZLIB)
set(HAVE_LIBZ ON)
list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
include_directories(${ZLIB_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
endif()
endif()

Expand All @@ -463,7 +467,7 @@ if(CMAKE_USE_LIBSSH2)
if(LIBSSH2_FOUND)
list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY})
set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_LIBRARY})
set(CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}")
list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}")
include_directories("${LIBSSH2_INCLUDE_DIR}")
set(HAVE_LIBSSH2 ON)
set(USE_LIBSSH2 ON)
Expand Down Expand Up @@ -496,7 +500,7 @@ if(CMAKE_USE_GSSAPI)

message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"")

set(CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIR})
list(APPEND CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIRECTORIES})
check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H)
check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H)
check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H)
Expand Down Expand Up @@ -532,7 +536,7 @@ if(CMAKE_USE_GSSAPI)

endif()

include_directories(${GSS_INCLUDE_DIR})
include_directories(${GSS_INCLUDE_DIRECTORIES})
link_directories(${GSS_LINK_DIRECTORIES})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}")
Expand All @@ -552,6 +556,7 @@ else()
unset(USE_UNIX_SOCKETS CACHE)
endif()


# Check for header files
if(NOT UNIX)
check_include_file_concat("windows.h" HAVE_WINDOWS_H)
Expand Down

0 comments on commit 4d60e12

Please sign in to comment.