2020-01-27 09:47:42 +01:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
|
|
|
|
|
|
# set the project name
|
2022-03-19 10:15:38 +01:00
|
|
|
project(openFPGALoader VERSION "0.8.0" LANGUAGES CXX)
|
2020-12-17 13:58:30 +01:00
|
|
|
add_definitions(-DVERSION=\"v${PROJECT_VERSION}\")
|
2020-01-27 09:47:42 +01:00
|
|
|
|
2020-03-14 18:49:13 +01:00
|
|
|
option(BUILD_STATIC "Whether or not to build with static libraries" OFF)
|
2021-10-03 14:43:15 +02:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
2022-03-22 21:36:36 +01:00
|
|
|
set(ENABLE_UDEV OFF)
|
2021-10-03 14:43:15 +02:00
|
|
|
else()
|
2022-03-22 21:36:36 +01:00
|
|
|
option(ENABLE_UDEV "use udev to search JTAG adapter from /dev/xx" ON)
|
2021-10-03 14:43:15 +02:00
|
|
|
endif()
|
2021-06-19 17:28:48 +02:00
|
|
|
option(ENABLE_CMSISDAP "enable cmsis DAP interface (requires hidapi)" ON)
|
2020-07-25 06:06:25 +02:00
|
|
|
option(USE_PKGCONFIG "Use pkgconfig to find libraries" ON)
|
|
|
|
|
option(LINK_CMAKE_THREADS "Use CMake find_package to link the threading library" OFF)
|
2021-10-06 08:46:00 +02:00
|
|
|
set(ISE_PATH "/opt/Xilinx/14.7" CACHE STRING "ise root directory (default: /opt/Xilinx/14.7)")
|
2020-03-14 18:49:13 +01:00
|
|
|
|
2020-01-27 09:47:42 +01:00
|
|
|
## specify the C++ standard
|
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
2020-07-25 06:06:25 +02:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra ${CMAKE_CXX_FLAGS_DEBUG}")
|
2020-01-27 09:47:42 +01:00
|
|
|
|
2020-03-14 18:49:13 +01:00
|
|
|
if (BUILD_STATIC)
|
2020-07-25 06:06:25 +02:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static ${CMAKE_EXE_LINKER_FLAGS}")
|
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
2020-03-14 18:49:13 +01:00
|
|
|
endif()
|
|
|
|
|
|
2020-02-16 13:33:38 +01:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
# By default: DATA_DIR="/usr/local/share"
|
|
|
|
|
add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\")
|
|
|
|
|
|
2021-10-06 08:46:00 +02:00
|
|
|
add_definitions(-DISE_DIR=\"${ISE_PATH}\")
|
|
|
|
|
|
2022-03-22 21:36:36 +01:00
|
|
|
if (USE_PKGCONFIG)
|
2020-07-25 06:06:25 +02:00
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
|
pkg_check_modules(LIBFTDI REQUIRED libftdi1)
|
|
|
|
|
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
|
2021-10-14 06:46:59 +02:00
|
|
|
pkg_check_modules(HIDAPI hidapi-hidraw)
|
|
|
|
|
# if hidraw not found try with libusb
|
2022-03-22 21:36:36 +01:00
|
|
|
if (NOT HIDAPI_FOUND)
|
2021-10-14 06:46:59 +02:00
|
|
|
pkg_check_modules(HIDAPI hidapi-libusb)
|
|
|
|
|
endif()
|
2021-12-02 07:20:58 +01:00
|
|
|
# zlib support (gzip)
|
|
|
|
|
pkg_check_modules(ZLIB zlib)
|
|
|
|
|
if (NOT ZLIB_FOUND)
|
|
|
|
|
# try zlib-ng
|
|
|
|
|
pkg_check_modules(ZLIB zlib-ng)
|
|
|
|
|
if (ZLIB_FOUND)
|
|
|
|
|
add_definitions(-DHAS_ZLIBNG)
|
|
|
|
|
else()
|
|
|
|
|
message(FATAL_ERROR "Could find ZLIB")
|
|
|
|
|
endif()
|
|
|
|
|
endif(NOT ZLIB_FOUND)
|
2020-07-25 06:06:25 +02:00
|
|
|
|
2022-03-22 21:36:36 +01:00
|
|
|
if (ENABLE_UDEV)
|
2020-07-25 06:06:25 +02:00
|
|
|
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()
|
2020-03-14 19:42:07 +01:00
|
|
|
endif()
|
|
|
|
|
endif()
|
2020-01-27 09:47:42 +01:00
|
|
|
|
|
|
|
|
set(OPENFPGALOADER_SOURCE
|
2020-08-20 16:58:20 +02:00
|
|
|
src/anlogic.cpp
|
2020-08-21 14:01:07 +02:00
|
|
|
src/anlogicBitParser.cpp
|
2020-08-20 16:56:29 +02:00
|
|
|
src/anlogicCable.cpp
|
2021-11-06 10:33:25 +01:00
|
|
|
src/ch552_jtag.cpp
|
2021-06-20 10:25:49 +02:00
|
|
|
src/dfu.cpp
|
2021-02-15 07:33:58 +01:00
|
|
|
src/dfuFileParser.cpp
|
2020-06-14 15:41:00 +02:00
|
|
|
src/dirtyJtag.cpp
|
2020-10-31 08:46:53 +01:00
|
|
|
src/efinix.cpp
|
|
|
|
|
src/efinixHexParser.cpp
|
2021-05-13 16:04:34 +02:00
|
|
|
src/fx2_ll.cpp
|
2020-10-31 15:02:54 +01:00
|
|
|
src/ice40.cpp
|
2021-05-13 12:14:52 +02:00
|
|
|
src/ihexParser.cpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/spiFlash.cpp
|
2021-12-22 19:01:58 +01:00
|
|
|
src/spiInterface.cpp
|
2020-09-05 07:49:57 +02:00
|
|
|
src/rawParser.cpp
|
2020-08-19 15:15:13 +02:00
|
|
|
src/usbBlaster.cpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/epcq.cpp
|
|
|
|
|
src/svf_jtag.cpp
|
|
|
|
|
src/jedParser.cpp
|
2021-11-09 09:54:09 +01:00
|
|
|
src/feaparser.cpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/display.cpp
|
2020-03-06 09:22:34 +01:00
|
|
|
src/jtag.cpp
|
2020-03-07 11:43:18 +01:00
|
|
|
src/ftdiJtagBitbang.cpp
|
2020-03-06 09:22:34 +01:00
|
|
|
src/ftdiJtagMPSSE.cpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/configBitstreamParser.cpp
|
|
|
|
|
src/ftdipp_mpsse.cpp
|
|
|
|
|
src/main.cpp
|
|
|
|
|
src/latticeBitParser.cpp
|
|
|
|
|
src/gowin.cpp
|
|
|
|
|
src/device.cpp
|
2022-03-12 18:46:23 +01:00
|
|
|
src/jlink.cpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/lattice.cpp
|
|
|
|
|
src/progressBar.cpp
|
|
|
|
|
src/fsparser.cpp
|
|
|
|
|
src/mcsParser.cpp
|
|
|
|
|
src/ftdispi.cpp
|
|
|
|
|
src/altera.cpp
|
|
|
|
|
src/bitparser.cpp
|
2021-10-03 16:25:41 +02:00
|
|
|
src/xilinx.cpp
|
|
|
|
|
src/xilinxMapParser.cpp
|
2021-12-10 12:12:32 +01:00
|
|
|
src/colognechip.cpp
|
|
|
|
|
src/colognechipCfgParser.cpp
|
2022-07-06 20:58:19 +02:00
|
|
|
src/xvc_server.cpp
|
2020-01-27 09:47:42 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(OPENFPGALOADER_HEADERS
|
|
|
|
|
src/altera.hpp
|
2020-08-20 16:58:20 +02:00
|
|
|
src/anlogic.hpp
|
2020-08-21 14:01:07 +02:00
|
|
|
src/anlogicBitParser.hpp
|
2020-08-20 16:56:29 +02:00
|
|
|
src/anlogicCable.hpp
|
2021-11-06 10:33:25 +01:00
|
|
|
src/ch552_jtag.hpp
|
2020-07-23 18:32:18 +02:00
|
|
|
src/cxxopts.hpp
|
2021-06-20 10:25:49 +02:00
|
|
|
src/dfu.hpp
|
2021-02-15 07:33:58 +01:00
|
|
|
src/dfuFileParser.hpp
|
2020-06-14 15:41:00 +02:00
|
|
|
src/dirtyJtag.hpp
|
2020-10-31 08:46:53 +01:00
|
|
|
src/efinix.hpp
|
|
|
|
|
src/efinixHexParser.hpp
|
2021-05-13 16:04:34 +02:00
|
|
|
src/fx2_ll.hpp
|
2021-05-13 12:14:52 +02:00
|
|
|
src/ice40.hpp
|
|
|
|
|
src/ihexParser.hpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/progressBar.hpp
|
2020-09-05 07:49:57 +02:00
|
|
|
src/rawParser.hpp
|
2020-08-19 15:15:13 +02:00
|
|
|
src/usbBlaster.hpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/bitparser.hpp
|
2020-03-07 11:43:18 +01:00
|
|
|
src/ftdiJtagBitbang.hpp
|
2020-03-06 09:22:34 +01:00
|
|
|
src/ftdiJtagMPSSE.hpp
|
2022-03-12 18:46:23 +01:00
|
|
|
src/jlink.hpp
|
2020-03-06 09:22:34 +01:00
|
|
|
src/jtag.hpp
|
|
|
|
|
src/jtagInterface.hpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/fsparser.hpp
|
|
|
|
|
src/part.hpp
|
|
|
|
|
src/board.hpp
|
|
|
|
|
src/jedParser.hpp
|
2021-11-09 09:54:09 +01:00
|
|
|
src/feaparser.hpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/display.hpp
|
|
|
|
|
src/mcsParser.hpp
|
|
|
|
|
src/ftdipp_mpsse.hpp
|
|
|
|
|
src/spiFlash.hpp
|
2021-10-10 18:25:09 +02:00
|
|
|
src/spiFlashdb.hpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/epcq.hpp
|
2020-04-22 15:17:55 +02:00
|
|
|
src/spiInterface.hpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/svf_jtag.hpp
|
|
|
|
|
src/configBitstreamParser.hpp
|
|
|
|
|
src/device.hpp
|
|
|
|
|
src/gowin.hpp
|
|
|
|
|
src/cable.hpp
|
|
|
|
|
src/ftdispi.hpp
|
|
|
|
|
src/lattice.hpp
|
|
|
|
|
src/latticeBitParser.hpp
|
2021-10-03 16:25:41 +02:00
|
|
|
src/xilinx.hpp
|
|
|
|
|
src/xilinxMapParser.hpp
|
2021-12-10 12:12:32 +01:00
|
|
|
src/colognechip.hpp
|
|
|
|
|
src/colognechipCfgParser.hpp
|
2022-07-06 20:58:19 +02:00
|
|
|
src/xvc_server.hpp
|
2020-01-27 09:47:42 +01:00
|
|
|
)
|
|
|
|
|
|
2022-03-22 21:36:36 +01:00
|
|
|
link_directories(
|
|
|
|
|
${LIBUSB_LIBRARY_DIRS}
|
|
|
|
|
${LIBFTDI_LIBRARY_DIRS}
|
|
|
|
|
)
|
|
|
|
|
|
2020-01-27 09:47:42 +01:00
|
|
|
add_executable(openFPGALoader
|
|
|
|
|
${OPENFPGALOADER_SOURCE}
|
|
|
|
|
${OPENFPGALOADER_HEADERS}
|
|
|
|
|
)
|
|
|
|
|
|
2020-03-14 19:42:07 +01:00
|
|
|
include_directories(
|
2020-01-27 09:47:42 +01:00
|
|
|
${LIBUSB_INCLUDE_DIRS}
|
|
|
|
|
${LIBFTDI_INCLUDE_DIRS}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_link_libraries(openFPGALoader
|
|
|
|
|
${LIBUSB_LIBRARIES}
|
|
|
|
|
${LIBFTDI_LIBRARIES}
|
|
|
|
|
)
|
2020-03-17 07:25:26 +01:00
|
|
|
|
2020-07-25 08:21:27 +02:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
|
|
|
|
# winsock provides ntohs
|
|
|
|
|
target_link_libraries(openFPGALoader ws2_32)
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-03-17 07:25:26 +01:00
|
|
|
# libusb_attach_kernel_driver is only available on Linux.
|
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
|
add_definitions(-DATTACH_KERNEL)
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-03-22 21:36:36 +01:00
|
|
|
if (ENABLE_UDEV)
|
|
|
|
|
include_directories(${LIBUDEV_INCLUDE_DIRS})
|
|
|
|
|
target_link_libraries(openFPGALoader ${LIBUDEV_LIBRARIES})
|
2020-03-14 19:42:07 +01:00
|
|
|
endif()
|
|
|
|
|
|
2020-03-14 18:49:13 +01:00
|
|
|
if (BUILD_STATIC)
|
|
|
|
|
set_target_properties(openFPGALoader PROPERTIES LINK_SEARCH_END_STATIC 1)
|
|
|
|
|
endif()
|
2021-06-19 17:28:48 +02:00
|
|
|
|
|
|
|
|
if (ENABLE_CMSISDAP)
|
2022-03-22 21:36:36 +01:00
|
|
|
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()
|
2021-06-19 17:28:48 +02:00
|
|
|
endif(ENABLE_CMSISDAP)
|
|
|
|
|
|
2022-04-10 16:02:39 +02:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
|
add_definitions(-DENABLE_XVC_CLIENT=1)
|
|
|
|
|
target_sources(openFPGALoader PRIVATE src/xvc_client.cpp)
|
|
|
|
|
list (APPEND OPENFPGALOADER_HEADERS src/xvc_client.hpp)
|
|
|
|
|
message("Xilinx Virtual Server (client side) support enabled")
|
|
|
|
|
else()
|
|
|
|
|
message("Xilinx Virtual Server (client side) support disabled")
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-11-25 08:11:50 +01:00
|
|
|
if (ZLIB_FOUND)
|
|
|
|
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
|
|
|
|
target_link_libraries(openFPGALoader ${ZLIB_LIBRARIES})
|
|
|
|
|
add_definitions(-DHAS_ZLIB=1)
|
|
|
|
|
else()
|
|
|
|
|
message("zlib library not found: can't flash intel/altera devices")
|
|
|
|
|
endif()
|
2020-03-15 08:22:29 +01:00
|
|
|
|
2020-07-25 06:06:25 +02:00
|
|
|
if (LINK_CMAKE_THREADS)
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
target_link_libraries(openFPGALoader Threads::Threads)
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-01-27 09:47:42 +01:00
|
|
|
# libftdi < 1.4 as no usb_addr
|
2021-02-25 13:36:28 +01:00
|
|
|
# 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})
|
2020-01-27 09:47:42 +01:00
|
|
|
|
|
|
|
|
install(TARGETS openFPGALoader DESTINATION bin)
|
2021-07-03 11:01:56 +02:00
|
|
|
file(GLOB BITS_FILES spiOverJtag/spiOverJtag_*.bit)
|
2021-07-08 20:59:28 +02:00
|
|
|
file(GLOB RBF_FILES spiOverJtag/spiOverJtag_*.rbf)
|
2021-12-19 17:34:51 +01:00
|
|
|
file(GLOB GZ_FILES spiOverJtag/spiOverJtag_*.*.gz)
|
2020-01-27 09:47:42 +01:00
|
|
|
install(FILES
|
|
|
|
|
test_sfl.svf
|
2021-07-03 11:01:56 +02:00
|
|
|
${BITS_FILES}
|
2021-07-08 20:59:28 +02:00
|
|
|
${RBF_FILES}
|
2021-11-25 08:11:50 +01:00
|
|
|
${GZ_FILES}
|
2020-02-16 13:33:38 +01:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openFPGALoader
|
2020-01-27 09:47:42 +01:00
|
|
|
)
|