From 0ee21848b5a42b9ef94d811c3a0e32d80fd0d9bd Mon Sep 17 00:00:00 2001 From: Shiqing Fan Date: Thu, 2 Jul 2009 14:38:55 +0000 Subject: [PATCH] Check the socket data types more properly. This commit was SVN r21585. --- .../win32/CMakeModules/check_c_type_exists.cmake | 15 ++++++++++++--- .../CMakeModules/ompi_check_Microsoft.cmake | 16 ++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/contrib/platform/win32/CMakeModules/check_c_type_exists.cmake b/contrib/platform/win32/CMakeModules/check_c_type_exists.cmake index 8abef6f2f2..ad3065c201 100644 --- a/contrib/platform/win32/CMakeModules/check_c_type_exists.cmake +++ b/contrib/platform/win32/CMakeModules/check_c_type_exists.cmake @@ -9,8 +9,10 @@ # # -# Try to compile and run a test program. -# If the type is defined, then return the size of the type. +# Some data types are defined in SDK headers, but the SDK include path +# is only reachable from Visual Studio ENV. So try to compile and run a test +# program to check if the data types is defined in SDK headers. +# If the type is defined, also return the size of the type. # # TYPE: the type to check # TYPE_NAME: the uppercase of the type, with underlines if necessary. @@ -23,8 +25,15 @@ MACRO(CHECK_C_TYPE_EXISTS TYPE TYPE_NAME INCLUDE_HEADERS) MESSAGE( STATUS "Checking for ${TYPE}...") + SET(INCLUDE "") + FOREACH(HEADER ${INCLUDE_HEADERS}) + SET(INCLUDE ${INCLUDE} "#include <${HEADER}>\n") + ENDFOREACH(HEADER ${INCLUDE_HEADERS}) + + STRING(REPLACE ";" "" INCLUDE ${INCLUDE}) + FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_${TYPE_NAME}.c" - "${INCLUDE_HEADERS} + "${INCLUDE} int main(){ ${TYPE} test; return sizeof(${TYPE});}") TRY_RUN(SIZEOF_${TYPE_NAME} COMPILE_RESULT "${CMAKE_BINARY_DIR}" diff --git a/contrib/platform/win32/CMakeModules/ompi_check_Microsoft.cmake b/contrib/platform/win32/CMakeModules/ompi_check_Microsoft.cmake index 02454f1c14..f73b2fe3d1 100644 --- a/contrib/platform/win32/CMakeModules/ompi_check_Microsoft.cmake +++ b/contrib/platform/win32/CMakeModules/ompi_check_Microsoft.cmake @@ -120,13 +120,17 @@ MACRO(OMPI_MICROSOFT_COMPILER) ENDFOREACH(${FUNCTION}) INCLUDE(check_c_type_exists) - CHECK_C_TYPE_EXISTS(socklen_t SOCKLEN_T - "#include \n" - "#include \n") + CHECK_C_TYPE_EXISTS(socklen_t SOCKLEN_T + "winsock2.h;ws2tcpip.h") - CHECK_C_TYPE_EXISTS("struct sockaddr_in" STRUCT_SOCKADDR_IN - "#include \n" - "#include \n") + CHECK_C_TYPE_EXISTS("struct sockaddr_in" STRUCT_SOCKADDR_IN + "winsock2.h") + + CHECK_C_TYPE_EXISTS("struct sockaddr_in6" STRUCT_SOCKADDR_IN6 + "ws2tcpip.h") + + CHECK_C_TYPE_EXISTS("struct sockaddr_storage" STRUCT_SOCKADDR_STORAGE + "winsock2.h;ws2tcpip.h") ELSE(CL_EXE_OK) MESSAGE(FATAL_ERROR "No working Microsoft compiler found. Please check if Visual Studio VC is correctly installed.")