Skip to content

Commit dd74007

Browse files
committed
Moving on to v5.
1 parent f556f73 commit dd74007

15 files changed

+1548
-1026
lines changed

CMakeLists.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(ProtocolToolkit
3+
VERSION 1.0.0
4+
DESCRIPTION "Protocol Toolkit - Event-driven framework for industrial network protocols"
5+
LANGUAGES C
6+
)
7+
8+
# Set C standard
9+
set(CMAKE_C_STANDARD 99)
10+
set(CMAKE_C_STANDARD_REQUIRED ON)
11+
12+
# Determine if this is the root project or a submodule
13+
set(PTK_IS_ROOT_PROJECT OFF)
14+
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
15+
set(PTK_IS_ROOT_PROJECT ON)
16+
endif()
17+
18+
# Configure output directories to build/ (only when root project)
19+
if(PTK_IS_ROOT_PROJECT)
20+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
21+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
22+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
23+
endif()
24+
25+
# Configure object file output
26+
set(CMAKE_OBJECT_PATH_MAX 260)
27+
28+
# Compiler flags
29+
if(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
30+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic")
31+
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -DDEBUG")
32+
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
33+
endif()
34+
35+
# Build options (only available when root project)
36+
if(PTK_IS_ROOT_PROJECT)
37+
option(PTK_BUILD_EXAMPLES "Build example programs" ON)
38+
option(PTK_BUILD_TESTS "Build test programs" ON)
39+
else()
40+
# When used as submodule, always OFF
41+
set(PTK_BUILD_EXAMPLES OFF)
42+
set(PTK_BUILD_TESTS OFF)
43+
endif()
44+
45+
option(ENABLE_MACOS "Build macOS kevent implementation" ON)# Platform detection
46+
if(APPLE AND ENABLE_MACOS)
47+
set(PLATFORM_DIR "macos")
48+
set(PLATFORM_NAME "macOS")
49+
else()
50+
message(FATAL_ERROR "No supported platform implementation available")
51+
endif()
52+
53+
# Include the platform-specific implementation
54+
add_subdirectory(${PLATFORM_DIR})
55+
56+
# Build examples if requested (only when root project)
57+
if(PTK_IS_ROOT_PROJECT AND PTK_BUILD_EXAMPLES)
58+
add_subdirectory(examples)
59+
endif()
60+
61+
# Build tests if requested (only when root project)
62+
if(PTK_IS_ROOT_PROJECT AND PTK_BUILD_TESTS)
63+
enable_testing()
64+
add_subdirectory(tests)
65+
endif()
66+
67+
# Print configuration summary (only when root project)
68+
if(PTK_IS_ROOT_PROJECT)
69+
message(STATUS "")
70+
message(STATUS "Protocol Toolkit Configuration:")
71+
message(STATUS " Version: ${PROJECT_VERSION}")
72+
message(STATUS " Platform: ${PLATFORM_NAME}")
73+
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
74+
message(STATUS " C Compiler: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}")
75+
message(STATUS " C Flags: ${CMAKE_C_FLAGS}")
76+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
77+
message(STATUS " Debug flags: ${CMAKE_C_FLAGS_DEBUG}")
78+
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
79+
message(STATUS " Release flags: ${CMAKE_C_FLAGS_RELEASE}")
80+
endif()
81+
message(STATUS " Install prefix: ${CMAKE_INSTALL_PREFIX}")
82+
message(STATUS " Build examples: ${PTK_BUILD_EXAMPLES}")
83+
message(STATUS " Build tests: ${PTK_BUILD_TESTS}")
84+
message(STATUS " Output directories:")
85+
message(STATUS " Binaries: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
86+
message(STATUS " Libraries: ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
87+
message(STATUS "")
88+
else()
89+
message(STATUS "Protocol Toolkit: Building as submodule (library only)")
90+
endif()

0 commit comments

Comments
 (0)