]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/tools/vcpkg/ports/libmodbus/CMakeLists.txt
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / tools / vcpkg / ports / libmodbus / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.0)
2 project(libmodbus VERSION 3.1.6)
3
4 set(LIBMODBUS_VERSION ${PROJECT_VERSION})
5 set(LIBMODBUS_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
6 set(LIBMODBUS_VERSION_MINOR ${PROJECT_VERSION_MINOR})
7 set(LIBMODBUS_VERSION_MICRO ${PROJECT_VERSION_PATCH})
8 configure_file(src/modbus-version.h.in ${CMAKE_CURRENT_BINARY_DIR}/modbus-version.h)
9
10 if(WIN32)
11 set(HAVE_ERRNO_H 1)
12 set(HAVE_FCNTL_H 1)
13 set(HAVE_LIMITS_H 1)
14 set(HAVE_SYS_TYPES_H 1)
15 set(HAVE_TIME_H 1)
16 set(HAVE_MALLOC 1)
17 set(HAVE_MEMSET 1)
18 set(HAVE_STRERROR 1)
19 else()
20 include(CheckIncludeFile)
21 check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
22 check_include_file(byteswap.h HAVE_BYTESWAP_H)
23 check_include_file(errno.h HAVE_ERRNO_H)
24 check_include_file(fcntl.h HAVE_FCNTL_H)
25 check_include_file(limits.h HAVE_LIMITS_H)
26 check_include_file(linux/serial.h HAVE_LINUX_SERIAL_H)
27 check_include_file(netdb.h HAVE_NETDB_H)
28 check_include_file(netinet/in.h HAVE_NETINET_IN_H)
29 check_include_file(netinet/tcp.h HAVE_NETINET_TCP_H)
30 check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
31 check_include_file(sys/params.h HAVE_SYS_PARAMS_H)
32 check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
33 check_include_file(sys/time.h HAVE_SYS_TIME_H)
34 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
35 check_include_file(termios.h HAVE_TERMIOS_H)
36 check_include_file(time.h HAVE_TIME_H)
37 check_include_file(unistd.h HAVE_UNISTD_H)
38
39 include(CheckFunctionExists)
40 check_function_exists(accept4 HAVE_ACCEPT4)
41 check_function_exists(fork HAVE_FORK)
42 check_function_exists(getaddrinfo HAVE_GETADDRINFO)
43 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
44 check_function_exists(inet_ntoa HAVE_INET_NTOA)
45 check_function_exists(malloc HAVE_MALLOC)
46 check_function_exists(memset HAVE_MEMSET)
47 check_function_exists(select HAVE_SELECT)
48 check_function_exists(socket HAVE_SOCKET)
49 check_function_exists(strerror HAVE_STRERROR)
50 check_function_exists(strlcpy HAVE_STRLCPY)
51
52 include(CheckSymbolExists)
53 check_symbol_exists(TIOCSRS485 sys/ioctl.h HAVE_TIOCRS485)
54 check_symbol_exists(TIOCM_RTS sys/ioctl.h HAVE_TIOCM_RTS)
55 endif()
56
57 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
58
59
60 if(BUILD_SHARED_LIBS)
61 add_compile_options(-DDLLBUILD=ON)
62 else()
63 add_compile_options(-DLIBBUILD=ON)
64 endif()
65
66 set(MODBUS_PUBLIC_HEADERS
67 src/modbus-rtu.h
68 src/modbus-tcp.h
69 src/modbus.h
70 ${CMAKE_CURRENT_BINARY_DIR}/modbus-version.h
71 )
72
73 add_library(modbus
74 src/modbus-data.c
75 src/modbus-rtu.c
76 src/modbus-tcp.c
77 src/modbus.c)
78
79 target_include_directories(modbus PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
80 target_include_directories(modbus INTERFACE
81 $<INSTALL_INTERFACE:include>
82 )
83 set_target_properties(modbus PROPERTIES PUBLIC_HEADER "${MODBUS_PUBLIC_HEADERS}")
84
85 if(CMAKE_COMPILER_IS_GNUCC)
86 target_compile_options(modbus PRIVATE -D_GNU_SOURCE)
87 endif()
88
89 if(WIN32)
90 target_link_libraries(modbus wsock32 ws2_32)
91 endif()
92
93 set(LIBMODBUS_SOVERSION_VERSION 5.1.0)
94 set(LIBMODBUS_SOVERSION_SOVERSION 5)
95
96
97 set_target_properties(modbus PROPERTIES
98 VERSION ${LIBMODBUS_SOVERSION_VERSION}
99 SOVERSION ${LIBMODBUS_SOVERSION_SOVERSION})
100
101
102 install(
103 TARGETS modbus
104 EXPORT libmodbusConfig
105 RUNTIME DESTINATION bin
106 LIBRARY DESTINATION lib
107 ARCHIVE DESTINATION lib
108 )
109 install(EXPORT libmodbusConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
110
111
112 if(NOT DISABLE_INSTALL_HEADERS)
113 install(FILES ${MODBUS_PUBLIC_HEADERS} DESTINATION include/)
114 endif()