-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
136 lines (116 loc) · 4.25 KB
/
CMakeLists.txt
File metadata and controls
136 lines (116 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
cmake_minimum_required(VERSION 3.18)
project(protocol_toolkit)
# Set C standard
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
# Set build type if not specified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Set output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Compiler-specific options
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
# GCC and Clang options
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter")
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
# MSVC options
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
set(CMAKE_C_FLAGS_DEBUG "/Zi /Od /DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "/O2 /DNDEBUG")
endif()
# Platform-specific settings
if(WIN32)
# Windows-specific settings
add_definitions(-D_WIN32_WINNT=0x0601) # Windows 7 and later
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
elseif(APPLE)
# macOS-specific settings
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
elseif(UNIX)
# Linux/BSD-specific settings
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
# Find required libraries
find_library(RT_LIBRARY rt)
if(RT_LIBRARY)
set(PLATFORM_LIBS ${PLATFORM_LIBS} ${RT_LIBRARY})
endif()
endif()
#=============================================================================
# PROTOCOL TOOLKIT LIBRARY
#=============================================================================
# Add protocol toolkit library
add_subdirectory(src/lib)
#=============================================================================
# EXAMPLES
#=============================================================================
# Add examples - temporarily disabled (use old allocator)
# Add examples
add_subdirectory(src/examples)
# add_subdirectory(tools/gen_codec/examples)
# Add tests
add_subdirectory(src/tests)
#=============================================================================
# INSTALLATION
#=============================================================================
# Install any targets that exist
# Note: modbus_server and modbus_client removed
# if(TARGET ethernetip_find_devices)
# install(TARGETS ethernetip_find_devices
# RUNTIME DESTINATION bin
# )
# endif()
# if(TARGET ethernetip_tag_server)
# install(TARGETS ethernetip_tag_server
# RUNTIME DESTINATION bin
# )
# endif()
install(FILES
src/include/ptk_buf.h
src/include/ptk_err.h
src/include/ptk_log.h
src/include/ptk_socket.h
src/include/ptk_thread.h
src/include/ptk_utils.h
DESTINATION include
)
#=============================================================================
# TESTING
#=============================================================================
# Add test targets
# add_custom_target(test_sockets
# COMMENT "Testing socket implementation"
# DEPENDS test_tcp_echo_abort test_udp_echo_abort
# )
#=============================================================================
# INFORMATION
#=============================================================================
# Print build information
message(STATUS "Building Protocol Toolkit")
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS " C Compiler: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}")
message(STATUS " Platform: ${CMAKE_SYSTEM_NAME}")
# Usage instructions
message(STATUS "")
message(STATUS "Build instructions:")
message(STATUS " mkdir build && cd build")
message(STATUS " cmake ..")
message(STATUS " make")
message(STATUS "")
message(STATUS "Libraries built:")
message(STATUS " - protocol_toolkit: Core utilities (buf, err, log, socket, thread, utils)")
message(STATUS "")
message(STATUS "Examples:")
message(STATUS " - ethernetip: EtherNet/IP device discovery tool")
message(STATUS " - modbus: Implementation guide and documentation")
message(STATUS "")
message(STATUS "Tests available:")
message(STATUS " - test_tcp_echo_abort: TCP socket abort functionality")
message(STATUS " - test_udp_echo_abort: UDP socket abort functionality")
message(STATUS "")