-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
105 lines (94 loc) · 3.28 KB
/
CMakeLists.txt
File metadata and controls
105 lines (94 loc) · 3.28 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
cmake_minimum_required(VERSION 3.15)
project(artnet-examples VERSION 0.3.13 LANGUAGES C)
# Set C standard
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
# Compiler flags
if(MSVC)
add_compile_options(/W4)
else()
add_compile_options(-Wall -Werror)
endif()
# Detect operating system
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(OS_LINUX TRUE)
add_definitions(-DOS_LINUX)
message(STATUS "Operating system: Linux")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(OS_DARWIN TRUE)
add_definitions(-DOS_DARWIN)
message(STATUS "Operating system: Darwin/MacOS X")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(OS_WINDOWS TRUE)
add_definitions(-DOS_WINDOWS)
message(STATUS "Operating system: Windows")
else()
message(FATAL_ERROR "Unsupported operating system: ${CMAKE_SYSTEM_NAME}")
endif()
# Options
option(BUILD_NCURSES_PROGS "Build ncurses-based programs" ON)
# Find libartnet library
find_package(PkgConfig)
if(PkgConfig_FOUND)
pkg_check_modules(LIBARTNET libartnet>=1.1.0)
endif()
if(NOT LIBARTNET_FOUND)
include(FetchContent)
message(STATUS "Fetching libartnet from GitHub...")
FetchContent_Declare(
libartnet
GIT_REPOSITORY https://github.com/OpenLightingProject/libartnet.git
GIT_TAG master
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(libartnet)
# Set variables for the fetched libartnet
# Assuming libartnet creates a target named 'artnet'
if(TARGET artnet)
set(LIBARTNET_LIBRARIES artnet)
get_target_property(LIBARTNET_INCLUDE_DIRS artnet INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "Using FetchContent libartnet target: artnet")
elseif(TARGET libartnet)
set(LIBARTNET_LIBRARIES libartnet)
get_target_property(LIBARTNET_INCLUDE_DIRS libartnet INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "Using FetchContent libartnet target: libartnet")
else()
# Fallback: assume standard build structure
set(LIBARTNET_INCLUDE_DIRS ${libartnet_SOURCE_DIR}/include)
set(LIBARTNET_LIBRARIES artnet)
message(STATUS "Using FetchContent libartnet with manual paths")
endif()
else()
message(STATUS "Found libartnet via pkg-config: ${LIBARTNET_LIBRARIES}")
endif()
# Check for ncurses
if(BUILD_NCURSES_PROGS)
if(UNIX)
find_library(CURSES_LIBRARIES NAMES ncurses curses)
find_path(CURSES_INCLUDE_DIRS NAMES ncurses.h curses.h)
if(CURSES_LIBRARIES)
set(HAVE_NCURSES TRUE)
message(STATUS "Found ncurses: ${CURSES_LIBRARIES}")
else()
set(HAVE_NCURSES FALSE)
message(STATUS "ncurses not found, skipping ncurses-based programs")
endif()
else()
set(HAVE_NCURSES FALSE)
message(STATUS "ncurses programs not available on this platform")
endif()
else()
set(HAVE_NCURSES FALSE)
endif()
# Find pthread for artnet-usb on Linux
if(OS_LINUX)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
endif()
# Include subdirectory
add_subdirectory(src)
# Installation
install(FILES README AUTHORS COPYING ChangeLog NEWS
DESTINATION share/doc/artnet-examples
)