1
1

Check the socket data types more properly.

This commit was SVN r21585.
Этот коммит содержится в:
Shiqing Fan 2009-07-02 14:38:55 +00:00
родитель 22666721a5
Коммит 0ee21848b5
2 изменённых файлов: 22 добавлений и 9 удалений

Просмотреть файл

@ -9,8 +9,10 @@
# #
# #
# Try to compile and run a test program. # Some data types are defined in SDK headers, but the SDK include path
# If the type is defined, then return the size of the type. # 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: the type to check
# TYPE_NAME: the uppercase of the type, with underlines if necessary. # 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}...") 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" FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_${TYPE_NAME}.c"
"${INCLUDE_HEADERS} "${INCLUDE}
int main(){ ${TYPE} test; return sizeof(${TYPE});}") int main(){ ${TYPE} test; return sizeof(${TYPE});}")
TRY_RUN(SIZEOF_${TYPE_NAME} COMPILE_RESULT "${CMAKE_BINARY_DIR}" TRY_RUN(SIZEOF_${TYPE_NAME} COMPILE_RESULT "${CMAKE_BINARY_DIR}"

Просмотреть файл

@ -120,13 +120,17 @@ MACRO(OMPI_MICROSOFT_COMPILER)
ENDFOREACH(${FUNCTION}) ENDFOREACH(${FUNCTION})
INCLUDE(check_c_type_exists) INCLUDE(check_c_type_exists)
CHECK_C_TYPE_EXISTS(socklen_t SOCKLEN_T CHECK_C_TYPE_EXISTS(socklen_t SOCKLEN_T
"#include <winsock2.h>\n" "winsock2.h;ws2tcpip.h")
"#include <ws2tcpip.h>\n")
CHECK_C_TYPE_EXISTS("struct sockaddr_in" STRUCT_SOCKADDR_IN CHECK_C_TYPE_EXISTS("struct sockaddr_in" STRUCT_SOCKADDR_IN
"#include <winsock2.h>\n" "winsock2.h")
"#include <ws2tcpip.h>\n")
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) ELSE(CL_EXE_OK)
MESSAGE(FATAL_ERROR "No working Microsoft compiler found. Please check if Visual Studio VC is correctly installed.") MESSAGE(FATAL_ERROR "No working Microsoft compiler found. Please check if Visual Studio VC is correctly installed.")