@@ -4,15 +4,27 @@ cmake_minimum_required(VERSION 3.5)
44project (openFPGALoader VERSION "1.0.0" LANGUAGES CXX)
55add_definitions (-DVERSION=\"v${PROJECT_VERSION} \")
66
7- option (ENABLE_OPTIM "Enable build with -O3 optimization level" ON )
8- option (BUILD_STATIC "Whether or not to build with static libraries" OFF )
7+ ####################################################################################################
8+ # Generics Options
9+ ####################################################################################################
910
10- # set all cable on by default
11- option (ENABLE_CABLE_ALL "Enable all cables" ON )
11+ option (ENABLE_OPTIM "Enable build with -O3 optimization level" ON )
12+ option (BUILD_STATIC "Whether or not to build with static libraries" OFF )
13+ option (USE_PKGCONFIG "Use pkgconfig to find libraries" ON )
14+ option (LINK_CMAKE_THREADS "Use CMake find_package to link the threading library" OFF )
1215
13- # set dependencies
14- set (USE_LIBUSB OFF )
15- set (USE_LIBFTDI OFF )
16+ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
17+ set (ENABLE_UDEV OFF )
18+ else ()
19+ option (ENABLE_UDEV "use udev to search JTAG adapter from /dev/xx" ON )
20+ endif ()
21+
22+ ####################################################################################################
23+ # CABLES Options
24+ ####################################################################################################
25+
26+ # set all cable on by default
27+ option (ENABLE_CABLE_ALL "Enable all cables" ON )
1628
1729option (ENABLE_CMSISDAP "enable cmsis DAP interface (requires hidapi)" ${ENABLE_CABLE_ALL} )
1830option (ENABLE_DFU ${ENABLE_CABLE_ALL} )
@@ -21,33 +33,46 @@ option(ENABLE_GOWIN_GWU2X "enable Gowin GWU2X interface" ${
2133option (ENABLE_USB_BLASTERI ${ENABLE_CABLE_ALL} )
2234option (ENABLE_USB_BLASTERII ${ENABLE_CABLE_ALL} )
2335
36+ set (BLASTERII_PATH "" CACHE STRING "usbBlasterII firmware directory" )
37+ set (ISE_PATH "/opt/Xilinx/14.7" CACHE STRING "ise root directory (default: /opt/Xilinx/14.7)" )
38+
39+ # Libgpiod, XVC and RemoteBitbang are only available on Linux OS.
2440if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
2541 option (ENABLE_LIBGPIOD "enable libgpiod bitbang driver (requires libgpiod)" ${ENABLE_CABLE_ALL} )
2642 option (ENABLE_REMOTEBITBANG "enable remote bitbang driver" ${ENABLE_CABLE_ALL} )
43+ option (ENABLE_XILINX_VIRTUAL_CABLE "enable Xilinx Virtual Cable (XVC) support" ${ENABLE_CABLE_ALL} )
2744else ()
2845 set (ENABLE_LIBGPIOD OFF )
2946 set (ENABLE_REMOTEBITBANG OFF )
47+ set (ENABLE_XILINX_VIRTUAL_CABLE OFF )
3048endif ()
3149
50+ ####################################################################################################
51+ # Variables
52+ ####################################################################################################
53+
54+ # set dependencies
55+ set (USE_LIBUSB OFF )
56+ set (USE_LIBFTDI OFF )
57+
3258# Only adds libftdi as dependency when a cable
3359# need this library.
34- if (ENABLE_FTDI_BASED_CABLE OR ENABLE_USB_BLASTERI)
60+ if (ENABLE_FTDI_BASED_CABLE OR ENABLE_USB_BLASTERI OR ENABLE_XILINX_VIRTUAL_CABLE )
3561 set (USE_LIBFTDI ON )
3662else ()
3763 message ("disabled all cables based on FTDI devices" )
38- endif (ENABLE_FTDI_BASED_CABLE OR ENABLE_USB_BLASTERI)
64+ endif (ENABLE_FTDI_BASED_CABLE OR ENABLE_USB_BLASTERI OR ENABLE_XILINX_VIRTUAL_CABLE )
3965
40- if (${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
41- set (ENABLE_UDEV OFF )
66+ # Only adds libusb as dependency when a cable need this library
67+ if (ENABLE_DFU)
68+ set (ENABLE_LIBUSB ON )
4269else ()
43- option (ENABLE_UDEV "use udev to search JTAG adapter from /dev/xx" ON )
44- endif ()
70+ message ( "disabled all cables using libUSB." )
71+ endif (ENABLE_DFU )
4572
46-
47- option (USE_PKGCONFIG "Use pkgconfig to find libraries" ON )
48- option (LINK_CMAKE_THREADS "Use CMake find_package to link the threading library" OFF )
49- set (BLASTERII_PATH "" CACHE STRING "usbBlasterII firmware directory" )
50- set (ISE_PATH "/opt/Xilinx/14.7" CACHE STRING "ise root directory (default: /opt/Xilinx/14.7)" )
73+ ####################################################################################################
74+ # Build options
75+ ####################################################################################################
5176
5277## specify the C++ standard
5378set (CMAKE_CXX_STANDARD 11)
@@ -68,6 +93,10 @@ add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\")
6893
6994add_definitions (-DISE_DIR=\"${ISE_PATH} \")
7095
96+ ####################################################################################################
97+ # Dependencies check/search
98+ ####################################################################################################
99+
71100if (USE_PKGCONFIG)
72101 find_package (PkgConfig REQUIRED)
73102
@@ -122,7 +151,13 @@ if (USE_PKGCONFIG)
122151 endif ()
123152endif ()
124153
154+ ####################################################################################################
155+ # FILES
156+ ####################################################################################################
157+
158+ # ===========================
125159# Core Classes
160+ # ===========================
126161set (OPENFPGALOADER_SOURCE
127162 src/common.cpp
128163 src/configBitstreamParser.cpp
@@ -140,20 +175,45 @@ set(OPENFPGALOADER_HEADERS
140175 src/cxxopts.hpp
141176 src/device.hpp
142177 src/display.hpp
178+ src/gpio_ll.hpp
143179 src/part.hpp
144180 src/progressBar.hpp
145181)
146182
183+ # ===========================
184+ # Parsers classes
185+ # ===========================
147186list (APPEND OPENFPGALOADER_SOURCE
148- src/anlogic.cpp
149187 src/anlogicBitParser.cpp
188+ src/bitparser.cpp
189+ src/fsparser.cpp
190+ src/ihexParser.cpp
191+ src/mcsParser.cpp
192+ src/pofParser.cpp
193+ src/rawParser.cpp
194+ src/xilinxMapParser.cpp
195+ )
196+
197+ list (APPEND OPENFPGALOADER_HEADERS
198+ src/anlogicBitParser.hpp
199+ src/bitparser.hpp
200+ src/fsparser.hpp
201+ src/ihexParser.hpp
202+ src/mcsParser.hpp
203+ src/pofParser.hpp
204+ src/rawParser.hpp
205+ src/xilinxMapParser.hpp
206+ )
207+
208+ # ===========================
209+ # To be sorted
210+ # ===========================
211+ list (APPEND OPENFPGALOADER_SOURCE
212+ src/anlogic.cpp
150213 src/anlogicCable.cpp
151214 src/dirtyJtag.cpp
152215 src/ch347jtag.cpp
153216 src/fx2_ll.cpp
154- src/ihexParser.cpp
155- src/pofParser.cpp
156- src/rawParser.cpp
157217 src/spiFlash.cpp
158218 src/spiInterface.cpp
159219 src/epcq.cpp
@@ -162,41 +222,29 @@ list(APPEND OPENFPGALOADER_SOURCE
162222 src/libusb_ll.cpp
163223 src/gowin.cpp
164224 src/jlink.cpp
165- src/fsparser.cpp
166- src/mcsParser.cpp
167225 src/altera.cpp
168- src/bitparser.cpp
169226 src/xilinx.cpp
170- src/xilinxMapParser.cpp
171227 src/esp_usb_jtag.cpp
172228)
173229
174230list (APPEND OPENFPGALOADER_HEADERS
175231 src/altera.hpp
176232 src/anlogic.hpp
177- src/anlogicBitParser.hpp
178233 src/anlogicCable.hpp
179234 src/dirtyJtag.hpp
180235 src/ch347jtag.hpp
181236 src/fx2_ll.hpp
182- src/ihexParser.hpp
183- src/pofParser.hpp
184- src/rawParser.hpp
185- src/bitparser.hpp
186237 src/jlink.hpp
187238 src/jtag.hpp
188239 src/jtagInterface.hpp
189240 src/libusb_ll.hpp
190- src/fsparser.hpp
191- src/mcsParser.hpp
192241 src/spiFlash.hpp
193242 src/spiFlashdb.hpp
194243 src/epcq.hpp
195244 src/spiInterface.hpp
196245 src/svf_jtag.hpp
197246 src/gowin.hpp
198247 src/xilinx.hpp
199- src/xilinxMapParser.hpp
200248 src/esp_usb_jtag.hpp
201249)
202250
@@ -404,7 +452,7 @@ if (ENABLE_CMSISDAP)
404452 endif ()
405453endif (ENABLE_CMSISDAP)
406454
407- if (( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" ) AND USE_LIBFTDI )
455+ if (ENABLE_XILINX_VIRTUAL_CABLE )
408456 add_definitions (-DENABLE_XVC=1)
409457 target_sources (openFPGALoader PRIVATE src/xvc_client.cpp src/xvc_server.cpp)
410458 list (APPEND OPENFPGALOADER_HEADERS src/xvc_client.hpp src/xvc_server.hpp)
@@ -443,12 +491,16 @@ if (USE_LIBFTDI)
443491 list (GET VERSION_LIST 0 LIBFTDI_VERSION_MAJOR)
444492 list (GET VERSION_LIST 1 LIBFTDI_VERSION_MINOR)
445493 math (EXPR FTDI_VAL "${LIBFTDI_VERSION_MAJOR} * 100 + ${LIBFTDI_VERSION_MINOR} " )
494+ add_definitions (-DFTDI_VERSION=${FTDI_VAL} )
446495endif ()
447496
448- add_definitions (-DFTDI_VERSION=${FTDI_VAL} )
449497
450498install (TARGETS openFPGALoader DESTINATION bin)
451499
500+ ####################################################################################################
501+ # SPIOverJtag bitstreams install
502+ ####################################################################################################
503+
452504file (GLOB GZ_FILES spiOverJtag/spiOverJtag_*.*.gz)
453505
454506# Compress rbf and bit files present into repository
0 commit comments