forked from trabucayre/openFPGALoader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
208 lines (184 loc) · 5.22 KB
/
CMakeLists.txt
File metadata and controls
208 lines (184 loc) · 5.22 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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
cmake_minimum_required(VERSION 3.0)
# set the project name
project(openFPGALoader VERSION "0.5.0" LANGUAGES CXX)
add_definitions(-DVERSION=\"v${PROJECT_VERSION}\")
option(BUILD_STATIC "Whether or not to build with static libraries" OFF)
option(ENABLE_UDEV "use udev to search JTAG adapter from /dev/xx" ON)
option(ENABLE_CMSISDAP "enable cmsis DAP interface (requires hidapi)" ON)
option(USE_PKGCONFIG "Use pkgconfig to find libraries" ON)
option(LINK_CMAKE_THREADS "Use CMake find_package to link the threading library" OFF)
## specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra ${CMAKE_CXX_FLAGS_DEBUG}")
if (BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static ${CMAKE_EXE_LINKER_FLAGS}")
set(BUILD_SHARED_LIBS OFF)
endif()
include(GNUInstallDirs)
# By default: DATA_DIR="/usr/local/share"
add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\")
if(USE_PKGCONFIG)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBFTDI REQUIRED libftdi1)
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
pkg_check_modules(HIDAPI hidapi-libusb)
if(ENABLE_UDEV)
pkg_check_modules(LIBUDEV libudev)
if (LIBUDEV_FOUND)
add_definitions(-DUSE_UDEV)
else()
message("libudev not found, disabling udev support and -D parameter")
set(ENABLE_UDEV OFF)
endif()
endif()
endif()
set(OPENFPGALOADER_SOURCE
src/anlogic.cpp
src/anlogicBitParser.cpp
src/anlogicCable.cpp
src/dfu.cpp
src/dfuFileParser.cpp
src/dirtyJtag.cpp
src/efinix.cpp
src/efinixHexParser.cpp
src/fx2_ll.cpp
src/ice40.cpp
src/ihexParser.cpp
src/spiFlash.cpp
src/rawParser.cpp
src/usbBlaster.cpp
src/epcq.cpp
src/svf_jtag.cpp
src/jedParser.cpp
src/display.cpp
src/jtag.cpp
src/ftdiJtagBitbang.cpp
src/ftdiJtagMPSSE.cpp
src/configBitstreamParser.cpp
src/ftdipp_mpsse.cpp
src/xilinx.cpp
src/main.cpp
src/latticeBitParser.cpp
src/gowin.cpp
src/device.cpp
src/lattice.cpp
src/progressBar.cpp
src/fsparser.cpp
src/mcsParser.cpp
src/ftdispi.cpp
src/altera.cpp
src/bitparser.cpp
)
set(OPENFPGALOADER_HEADERS
src/altera.hpp
src/anlogic.hpp
src/anlogicBitParser.hpp
src/anlogicCable.hpp
src/cxxopts.hpp
src/dfu.hpp
src/dfuFileParser.hpp
src/dirtyJtag.hpp
src/efinix.hpp
src/efinixHexParser.hpp
src/fx2_ll.hpp
src/ice40.hpp
src/ihexParser.hpp
src/progressBar.hpp
src/rawParser.hpp
src/usbBlaster.hpp
src/bitparser.hpp
src/ftdiJtagBitbang.hpp
src/ftdiJtagMPSSE.hpp
src/jtag.hpp
src/jtagInterface.hpp
src/fsparser.hpp
src/part.hpp
src/board.hpp
src/jedParser.hpp
src/display.hpp
src/mcsParser.hpp
src/ftdipp_mpsse.hpp
src/spiFlash.hpp
src/epcq.hpp
src/spiInterface.hpp
src/svf_jtag.hpp
src/xilinx.hpp
src/configBitstreamParser.hpp
src/device.hpp
src/gowin.hpp
src/cable.hpp
src/ftdispi.hpp
src/lattice.hpp
src/latticeBitParser.hpp
)
add_executable(openFPGALoader
${OPENFPGALOADER_SOURCE}
${OPENFPGALOADER_HEADERS}
)
include_directories(
${LIBUSB_INCLUDE_DIRS}
${LIBFTDI_INCLUDE_DIRS}
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_library(LIBFTDI1STATIC libftdi1.a REQUIRED)
find_library(LIBUSB1STATIC libusb-1.0.a REQUIRED)
target_link_libraries(openFPGALoader ${LIBFTDI1STATIC} ${LIBUSB1STATIC})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreFoundation -framework IOKit")
link_directories(/usr/local/lib)
target_include_directories(openFPGALoader PRIVATE /usr/local/include)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set_target_properties(openFPGALoader PROPERTIES LINK_SEARCH_END_STATIC 1)
else()
target_link_libraries(openFPGALoader
${LIBUSB_LIBRARIES}
${LIBFTDI_LIBRARIES}
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
# winsock provides ntohs
target_link_libraries(openFPGALoader ws2_32)
endif()
# libusb_attach_kernel_driver is only available on Linux.
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_definitions(-DATTACH_KERNEL)
endif()
if(ENABLE_UDEV)
include_directories(${LIBUDEV_INCLUDE_DIRS})
target_link_libraries(openFPGALoader ${LIBUDEV_LIBRARIES})
endif()
if (BUILD_STATIC)
set_target_properties(openFPGALoader PROPERTIES LINK_SEARCH_END_STATIC 1)
endif()
if (ENABLE_CMSISDAP)
if (HIDAPI_FOUND)
include_directories(${HIDAPI_INCLUDE_DIRS})
target_link_libraries(openFPGALoader ${HIDAPI_LIBRARIES})
add_definitions(-DENABLE_CMSISDAP=1)
target_sources(openFPGALoader PRIVATE src/cmsisDAP.cpp)
list (APPEND OPENFPGALOADER_HEADERS src/cmsisDAP.hpp)
message("cmsis_dap support enabled")
else()
message("hidapi-libusb not found: cmsis_dap support disabled")
endif()
endif(ENABLE_CMSISDAP)
endif()
if (LINK_CMAKE_THREADS)
find_package(Threads REQUIRED)
target_link_libraries(openFPGALoader Threads::Threads)
endif()
# libftdi < 1.4 as no usb_addr
# libftdi >= 1.5 as purge_buffer obsolete
string(REPLACE "." ";" VERSION_LIST ${LIBFTDI_VERSION})
list(GET VERSION_LIST 0 LIBFTDI_VERSION_MAJOR)
list(GET VERSION_LIST 1 LIBFTDI_VERSION_MINOR)
math(EXPR FTDI_VAL "${LIBFTDI_VERSION_MAJOR} * 100 + ${LIBFTDI_VERSION_MINOR}")
add_definitions(-DFTDI_VERSION=${FTDI_VAL})
install(TARGETS openFPGALoader DESTINATION bin)
file(GLOB BITS_FILES spiOverJtag/spiOverJtag_*.bit)
file(GLOB RBF_FILES spiOverJtag/spiOverJtag_*.rbf)
install(FILES
test_sfl.svf
${BITS_FILES}
${RBF_FILES}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openFPGALoader
)