-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCMakeLists.txt
175 lines (149 loc) · 6.39 KB
/
CMakeLists.txt
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#
# (C) Copyright 2011-2024 Johns Hopkins University (JHU), All Rights Reserved.
#
# --- begin cisst license - do not edit ---
#
# This software is provided "as is" under an open source license, with
# no warranty. The complete license can be found in license.txt and
# http://www.cisst.org/cisst/license.txt.
#
# --- end cisst license ---
cmake_minimum_required (VERSION 3.10)
project (Amp1394 VERSION 2.2.0)
# Set the version number
set (Amp1394_VERSION "${Amp1394_VERSION_MAJOR}.${Amp1394_VERSION_MINOR}.${Amp1394_VERSION_PATCH}")
# If LIBRARY_OUTPUT_PATH is not defined, define it here (note that if this
# is built within cisst, then LIBRARY_OUTPUT_PATH is defined by cisst).
if (NOT LIBRARY_OUTPUT_PATH)
set (LIBRARY_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/lib")
endif (NOT LIBRARY_OUTPUT_PATH)
# If EXECUTABLE_OUTPUT_PATH is not defined, define it here (note that if this
# is built within cisst, then EXECUTABLE_OUTPUT_PATH is defined by cisst).
if (NOT EXECUTABLE_OUTPUT_PATH)
set (EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/bin")
endif (NOT EXECUTABLE_OUTPUT_PATH)
# Set ARM32 when cross-compiling for Zynq
if (Arch STREQUAL "arm32")
set (ARM32 ON)
else ()
set (ARM32 OFF)
endif ()
# TODO: Move include files to Amp1394 subdirectory, i.e., lib/Amp1394 or lib/include/Amp1394.
set (Amp1394_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib;${Amp1394_BINARY_DIR}")
set (Amp1394_LIBRARY_DIR ${LIBRARY_OUTPUT_PATH})
set (Amp1394_LIBRARIES Amp1394)
set (Amp1394Console_LIBRARIES Amp1394Console)
set (Amp1394Console_EXTRA_LIBRARIES "")
if (WIN32)
# On Windows, can build with WinPcap or Npcap (Ethernet support)
# Use WinPcap for Windows XP and earlier (no longer maintained)
# Use Npcap for Windows 7 and higher (use Npcap SDK)
# OFF by default because UDP interface is preferred
option (Amp1394_HAS_PCAP "Build Amp1394 with Ethernet support (winpcap or npcap)" OFF)
if (Amp1394_HAS_PCAP)
# Need to specify where WinPcap Developer's Pack or Npcap SDK is installed
find_path (PCAP_INCLUDE_DIR pcap.h)
# In addition to wpcap, need Packet library for PacketOpenAdapter and PacketReqest
# Make sure to use correct version (32 or 64 bit)
find_path (PCAP_LIBRARY_DIR "wpcap.lib" DOC "Path to WinPcap/Npcap wpcap and Packet libraries")
set (PCAP_LIBRARIES "wpcap" "Packet")
endif (Amp1394_HAS_PCAP)
# Disable annoying warnings
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
else ()
# On other platforms (mostly Linux), can build with pcap and/or libraw1394
# On Zynq (embedded Linux), use EMIO interface to FPGA
if (ARM32)
option (Amp1394_HAS_EMIO "Build Amp1394 with Zynq EMIO support" ON)
else ()
option (Amp1394_HAS_PCAP "Build Amp1394 with Ethernet support (pcap)" OFF)
if (NOT APPLE)
option (Amp1394_HAS_RAW1394 "Build Amp1394 with FireWire support (libraw1394)" ON)
endif (NOT APPLE)
endif ()
if (Amp1394_HAS_PCAP)
# For now, assume pcap is installed somewhere standard
# To install: sudo apt-get install libpcap-dev
set (PCAP_INCLUDE_DIR "")
set (PCAP_LIBRARIES "pcap")
endif (Amp1394_HAS_PCAP)
option (Amp1394Console_HAS_CURSES "Build Amp1394 console library with curses (OFF --> VT100 mode)" ON)
if (Amp1394Console_HAS_CURSES)
find_package (Curses)
if (CURSES_FOUND)
set (Amp1394Console_EXTRA_LIBRARIES ${Amp1394Console_EXTRA_LIBRARIES} ${CURSES_LIBRARIES})
else (CURSES_FOUND)
message (STATUS "Cannot find Curses library, changing to VT100 mode")
endif (CURSES_FOUND)
endif (Amp1394Console_HAS_CURSES)
endif ()
# TODO: Determine whether it is necessary to have separate EXTRA variables for LIBRARY_DIR
# and LIBRARIES. Currently, it seems that both are always used together.
# The Amp1394_EXTRA_INCLUDE_DIR should be separate since it is only needed when
# building Amp1394.
set (Amp1394_EXTRA_INCLUDE_DIR "")
set (Amp1394_EXTRA_LIBRARY_DIR "")
set (Amp1394_EXTRA_LIBRARIES "")
if (Amp1394_HAS_RAW1394)
# Assume libraw1394 is installed in standard include/lib directories
set (Amp1394_EXTRA_LIBRARIES ${Amp1394_EXTRA_LIBRARIES} raw1394)
endif (Amp1394_HAS_RAW1394)
if (Amp1394_HAS_PCAP)
set (Amp1394_EXTRA_INCLUDE_DIR ${PCAP_INCLUDE_DIR})
set (Amp1394_EXTRA_LIBRARY_DIR ${PCAP_LIBRARY_DIR})
set (Amp1394_EXTRA_LIBRARIES ${Amp1394_EXTRA_LIBRARIES} ${PCAP_LIBRARIES})
if (NOT WIN32)
# Check if pcap_set_immediate_mode is available.
# This may not be needed on Windows; if needed, would probably have to
# specify PCAP_INCLUDE_DIR and PCAP_LIBRARY_DIR.
include (CheckCXXSourceCompiles)
set (CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARIES})
check_cxx_source_compiles ("#include <pcap.h>
int main()
{ pcap_set_immediate_mode(0, 0); }"
PCAP_HAS_IMMEDIATE_MODE)
if (PCAP_HAS_IMMEDIATE_MODE)
add_definitions (-DPCAP_HAS_IMMEDIATE_MODE)
endif ()
endif ()
endif (Amp1394_HAS_PCAP)
if (WIN32)
# for Windows, need WinSock, Iphlpapi (for getting interface info) and Ws2_32 (for WSAIoctl)
set (Amp1394_EXTRA_LIBRARIES ${Amp1394_EXTRA_LIBRARIES} WSOCK32 Iphlpapi Ws2_32)
endif (WIN32)
if (Amp1394_HAS_EMIO)
set (Amp1394_EXTRA_LIBRARIES ${Amp1394_EXTRA_LIBRARIES} "fpgav3")
endif (Amp1394_HAS_EMIO)
# Generate Amp1394Config.cmake
set (CONF_INCLUDE_DIR ${Amp1394_INCLUDE_DIR})
set (CONF_LIBRARY_DIR ${Amp1394_LIBRARY_DIR} ${Amp1394_EXTRA_LIBRARY_DIR})
set (CONF_LIBRARIES ${Amp1394_LIBRARIES} ${Amp1394_EXTRA_LIBRARIES})
set (CONF_CONSOLE_LIBRARIES ${Amp1394Console_LIBRARIES} ${Amp1394Console_EXTRA_LIBRARIES})
configure_file (Amp1394Config.cmake.in
"${Amp1394_BINARY_DIR}/Amp1394Config.cmake" @ONLY)
if (UNIX)
# Add some warnings
include (CheckCXXCompilerFlag)
check_cxx_compiler_flag ("-Wextra" CXX_SUPPORTS_WEXTRA)
if (CXX_SUPPORTS_WEXTRA)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
endif ()
check_cxx_compiler_flag ("-Wall" CXX_SUPPORTS_WALL)
if (CXX_SUPPORTS_WALL)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif ()
check_cxx_compiler_flag ("-fPIC" CXX_SUPPORTS_FPIC)
if (CXX_SUPPORTS_FPIC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif ()
endif (UNIX)
# Utilities to test libraw1394
if (Amp1394_HAS_RAW1394)
add_subdirectory (util)
endif (Amp1394_HAS_RAW1394)
# Code for library Amp1394
add_subdirectory (lib)
# Test programs
add_subdirectory (tests)
# Utility to flash/test board
add_subdirectory (programmer)