Revision: 77779
http://sourceforge.net/p/brlcad/code/77779
Author: starseeker
Date: 2020-11-21 02:40:37 +0000 (Sat, 21 Nov 2020)
Log Message:
-----------
Use cmake_host_system_information to replace code for getting hostname
Modified Paths:
--------------
brlcad/branches/extbuild/CMakeLists.txt
Modified: brlcad/branches/extbuild/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/CMakeLists.txt 2020-11-21 02:32:30 UTC (rev
77778)
+++ brlcad/branches/extbuild/CMakeLists.txt 2020-11-21 02:40:37 UTC (rev
77779)
@@ -1843,63 +1843,8 @@
endif(HAVE_UNISTD_H)
# HOST
-if(HAVE_GETHOSTNAME)
- set(GETHOSTNAME_DEF "-DHAVE_GETHOSTNAME")
-endif(HAVE_GETHOSTNAME)
-if(HAVE_DECL_GETHOSTNAME)
- set(GETHOSTNAME_DECL_DEF "-DHAVE_DECL_GETHOSTNAME")
-endif(HAVE_DECL_GETHOSTNAME)
-
-set(report_hostname_src "
-#include <stdio.h>
-#ifdef HAVE_UNISTD_H
- #include <unistd.h>
- #define GETHOSTNAME_ERROR -1
-#else
- #include <WinSock2.h>
- #define GETHOSTNAME_ERROR SOCKET_ERROR
-#endif
-
-#define MAX_HOSTNAME 2048
-
-/* strict c89 doesn't declare gethostname() */
-#if defined(HAVE_GETHOSTNAME) && !defined(HAVE_DECL_GETHOSTNAME) &&
!defined(__cplusplus) && !defined(_WINSOCKAPI_)
-extern int gethostname(char *name, size_t len);
-#endif
-
-int main(void) {
-#if defined(HAVE_GETHOSTNAME)
-{
- int ret; char hostname[MAX_HOSTNAME];
- #if !defined(HAVE_UNISTD_H)
- WORD wVersionRequested; WSADATA wsaData;
- wVersionRequested = MAKEWORD(1, 1); WSAStartup(wVersionRequested,
&wsaData);
- #endif
- ret = gethostname(hostname, MAX_HOSTNAME);
- if (ret != GETHOSTNAME_ERROR) {printf(\"%s\", hostname);} else {
printf(\"unknown\"); }
-}
-#else
- printf(\"unknown\");
-#endif
- return 0;
-}
-")
-
-file(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/report_hostname.c"
"${report_hostname_src}")
-try_run(RH_RESULT RH_COMPILED "${CMAKE_BINARY_DIR}/CMakeTmp"
- "${CMAKE_BINARY_DIR}/CMakeTmp/report_hostname.c"
- COMPILE_DEFINITIONS "${UNISTD_DEF}" "${GETHOSTNAME_DEF}"
"${GETHOSTNAME_DECL_DEF}"
- LINK_LIBRARIES "${WS2_32_LIBRARY}"
- COMPILE_OUTPUT_VARIABLE RH_COMPILE_MSGS
- RUN_OUTPUT_VARIABLE BRLCAD_COMPILE_HOSTNAME)
-if(NOT RH_COMPILED)
- message(FATAL_ERROR "Could not build hostname reporting utility:
${RH_COMPILE_MSGS}")
-endif(NOT RH_COMPILED)
-if(RH_RESULT)
- message(FATAL_ERROR "Could not run hostname reporting utility:
${BRLCAD_COMPILE_HOSTNAME}")
-endif(RH_RESULT)
+cmake_host_system_information(RESULT BRLCAD_COMPILE_HOSTNAME QUERY HOSTNAME)
string(STRIP ${BRLCAD_COMPILE_HOSTNAME} BRLCAD_COMPILE_HOSTNAME)
-file(REMOVE "${CMAKE_BINARY_DIR}/CMakeTmp/report_hostname.c")
# USER
set(report_username_src "
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits