comparison OrthancFramework/Resources/CMake/UuidConfiguration.cmake @ 4044:d25f4c0fa160 framework

splitting code into OrthancFramework and OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 20:30:34 +0200
parents Resources/CMake/UuidConfiguration.cmake@9c8e119d0c5b
children 05b8fd21089c
comparison
equal deleted inserted replaced
4043:6c6239aec462 4044:d25f4c0fa160
1 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
2
3 if (STATIC_BUILD OR NOT USE_SYSTEM_UUID)
4 SET(E2FSPROGS_SOURCES_DIR ${CMAKE_BINARY_DIR}/e2fsprogs-1.44.5)
5 SET(E2FSPROGS_URL "http://orthanc.osimis.io/ThirdPartyDownloads/e2fsprogs-1.44.5.tar.gz")
6 SET(E2FSPROGS_MD5 "8d78b11d04d26c0b2dd149529441fa80")
7
8 if (IS_DIRECTORY "${E2FSPROGS_SOURCES_DIR}")
9 set(FirstRun OFF)
10 else()
11 set(FirstRun ON)
12 endif()
13
14 DownloadPackage(${E2FSPROGS_MD5} ${E2FSPROGS_URL} "${E2FSPROGS_SOURCES_DIR}")
15
16
17 ##
18 ## Patch for OS X, in order to be compatible with Cocoa (used in Stone)
19 ##
20
21 execute_process(
22 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
23 ${ORTHANC_ROOT}/Resources/Patches/e2fsprogs-1.44.5-apple.patch
24 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
25 RESULT_VARIABLE Failure
26 )
27
28 if (FirstRun AND Failure)
29 message(FATAL_ERROR "Error while patching a file")
30 endif()
31
32
33 include_directories(
34 BEFORE ${E2FSPROGS_SOURCES_DIR}/lib
35 )
36
37 set(UUID_SOURCES
38 #${E2FSPROGS_SOURCES_DIR}/lib/uuid/tst_uuid.c
39 #${E2FSPROGS_SOURCES_DIR}/lib/uuid/uuid_time.c
40 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/clear.c
41 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/compare.c
42 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/copy.c
43 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/gen_uuid.c
44 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/isnull.c
45 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/pack.c
46 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/parse.c
47 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/unpack.c
48 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/unparse.c
49 )
50
51 check_include_file("net/if.h" HAVE_NET_IF_H)
52 check_include_file("net/if_dl.h" HAVE_NET_IF_DL_H)
53 check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
54 check_include_file("stdlib.h" HAVE_STDLIB_H)
55 check_include_file("sys/file.h" HAVE_SYS_FILE_H)
56 check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
57 check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H)
58 check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
59 check_include_file("sys/sockio.h" HAVE_SYS_SOCKIO_H)
60 check_include_file("sys/syscall.h" HAVE_SYS_SYSCALL_H)
61 check_include_file("sys/time.h" HAVE_SYS_TIME_H)
62 check_include_file("sys/un.h" HAVE_SYS_UN_H)
63 check_include_file("unistd.h" HAVE_UNISTD_H)
64
65 if (NOT HAVE_NET_IF_H) # This is the case of OpenBSD
66 unset(HAVE_NET_IF_H CACHE)
67 check_include_files("sys/socket.h;net/if.h" HAVE_NET_IF_H)
68 endif()
69
70 if (NOT HAVE_NETINET_TCP_H) # This is the case of OpenBSD
71 unset(HAVE_NETINET_TCP_H CACHE)
72 check_include_files("sys/socket.h;netinet/tcp.h" HAVE_NETINET_TCP_H)
73 endif()
74
75 if (NOT EXISTS ${E2FSPROGS_SOURCES_DIR}/lib/uuid/config.h)
76 file(WRITE ${E2FSPROGS_SOURCES_DIR}/lib/uuid/config.h.cmake "
77 #cmakedefine HAVE_NET_IF_H \@HAVE_NET_IF_H\@
78 #cmakedefine HAVE_NET_IF_DL_H \@HAVE_NET_IF_DL_H\@
79 #cmakedefine HAVE_NETINET_IN_H \@HAVE_NETINET_IN_H\@
80 #cmakedefine HAVE_STDLIB_H \@HAVE_STDLIB_H \@
81 #cmakedefine HAVE_SYS_FILE_H \@HAVE_SYS_FILE_H\@
82 #cmakedefine HAVE_SYS_IOCTL_H \@HAVE_SYS_IOCTL_H\@
83 #cmakedefine HAVE_SYS_RESOURCE_H \@HAVE_SYS_RESOURCE_H\@
84 #cmakedefine HAVE_SYS_SOCKET_H \@HAVE_SYS_SOCKET_H\@
85 #cmakedefine HAVE_SYS_SOCKIO_H \@HAVE_SYS_SOCKIO_H\@
86 #cmakedefine HAVE_SYS_SYSCALL_H \@HAVE_SYS_SYSCALL_H\@
87 #cmakedefine HAVE_SYS_TIME_H \@HAVE_SYS_TIME_H\@
88 #cmakedefine HAVE_SYS_UN_H \@HAVE_SYS_UN_H\@
89 #cmakedefine HAVE_UNISTD_H \@HAVE_UNISTD_H\@
90 ")
91 endif()
92
93 configure_file(
94 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/config.h.cmake
95 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/config.h
96 )
97
98 configure_file(
99 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/uuid.h.in
100 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/uuid.h
101 )
102
103 if (NOT EXISTS ${E2FSPROGS_SOURCES_DIR}/lib/uuid/uuid_types.h)
104 file(WRITE
105 ${E2FSPROGS_SOURCES_DIR}/lib/uuid/uuid_types.h
106 "#include <stdint.h>\n")
107 endif()
108
109 source_group(ThirdParty\\uuid REGULAR_EXPRESSION ${E2FSPROGS_SOURCES_DIR}/.*)
110
111 else()
112 CHECK_INCLUDE_FILE(uuid/uuid.h HAVE_UUID_H)
113 if (NOT HAVE_UUID_H)
114 message(FATAL_ERROR "Please install uuid-dev, e2fsprogs (OpenBSD) or e2fsprogs-libuuid (FreeBSD)")
115 endif()
116
117 find_library(LIBUUID uuid
118 PATHS
119 /usr/lib
120 /usr/local/lib
121 )
122
123 check_library_exists(${LIBUUID} uuid_generate_random "" HAVE_LIBUUID)
124 if (NOT HAVE_LIBUUID)
125 message(FATAL_ERROR "Unable to find the uuid library")
126 endif()
127
128 link_libraries(${LIBUUID})
129 endif()
130
131 endif()