2020-01-27 09:47:42 +01:00
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
|
|
|
|
|
|
# set the project name
|
|
|
|
|
project(openFPGALoader VERSION 0.1 LANGUAGES CXX)
|
|
|
|
|
|
2020-03-14 18:49:13 +01:00
|
|
|
option(BUILD_STATIC "Whether or not to build with static libraries" OFF)
|
2020-03-14 19:42:07 +01:00
|
|
|
option(ENABLE_UDEV "use udev to search JTAG adapter from /dev/xx" 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)
|
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}\")
|
|
|
|
|
|
2020-07-25 06:06:25 +02:00
|
|
|
if(USE_PKGCONFIG)
|
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
|
pkg_check_modules(LIBFTDI REQUIRED libftdi1)
|
|
|
|
|
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
|
|
|
|
|
|
|
|
|
|
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()
|
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-20 16:56:29 +02:00
|
|
|
src/anlogicCable.cpp
|
2020-06-14 15:41:00 +02:00
|
|
|
src/dirtyJtag.cpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/spiFlash.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
|
|
|
|
|
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/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
|
2020-08-20 16:58:20 +02:00
|
|
|
src/anlogic.hpp
|
2020-08-20 16:56:29 +02:00
|
|
|
src/anlogicCable.hpp
|
2020-07-23 18:32:18 +02:00
|
|
|
src/cxxopts.hpp
|
2020-06-14 15:41:00 +02:00
|
|
|
src/dirtyJtag.hpp
|
2020-01-27 09:47:42 +01:00
|
|
|
src/progressBar.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
|
|
|
|
|
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
|
|
|
|
|
src/display.hpp
|
|
|
|
|
src/mcsParser.hpp
|
|
|
|
|
src/ftdipp_mpsse.hpp
|
|
|
|
|
src/spiFlash.hpp
|
|
|
|
|
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/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}
|
|
|
|
|
)
|
|
|
|
|
|
2020-03-14 19:42:07 +01:00
|
|
|
include_directories(
|
2020-01-27 09:47:42 +01:00
|
|
|
${LIBUSB_INCLUDE_DIRS}
|
|
|
|
|
${LIBFTDI_INCLUDE_DIRS}
|
|
|
|
|
)
|
|
|
|
|
|
2020-03-15 08:22:29 +01:00
|
|
|
|
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
|
find_library(LIBFTDI1STATIC libftdi1.a REQUIRED)
|
|
|
|
|
find_library(LIBUSB1STATIC libusb-1.0.a REQUIRED)
|
2020-07-23 18:32:18 +02:00
|
|
|
target_link_libraries(openFPGALoader ${LIBFTDI1STATIC} ${LIBUSB1STATIC})
|
2020-03-15 08:22:29 +01:00
|
|
|
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()
|
2020-01-27 09:47:42 +01:00
|
|
|
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()
|
|
|
|
|
|
2020-03-14 19:42:07 +01:00
|
|
|
if(ENABLE_UDEV)
|
|
|
|
|
include_directories(${LIBUDEV_INCLUDE_DIRS})
|
|
|
|
|
target_link_libraries(openFPGALoader ${LIBUDEV_LIBRARIES})
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-03-14 18:49:13 +01:00
|
|
|
if (BUILD_STATIC)
|
|
|
|
|
set_target_properties(openFPGALoader PROPERTIES LINK_SEARCH_END_STATIC 1)
|
|
|
|
|
endif()
|
2020-03-15 08:22:29 +01:00
|
|
|
endif()
|
|
|
|
|
|
2020-07-25 06:06:25 +02:00
|
|
|
if (LINK_CMAKE_THREADS)
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
target_link_libraries(openFPGALoader Threads::Threads)
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-03-14 18:49:13 +01:00
|
|
|
|
2020-01-27 09:47:42 +01:00
|
|
|
# libftdi < 1.4 as no usb_addr
|
|
|
|
|
if (${LIBFTDI_VERSION} VERSION_LESS 1.4)
|
2020-07-25 06:06:25 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "-DOLD_FTDI_VERSION=1 ${CMAKE_CXX_FLAGS}")
|
2020-01-27 09:47:42 +01:00
|
|
|
else()
|
2020-07-25 06:06:25 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "-DOLD_FTDI_VERSION=0 ${CMAKE_CXX_FLAGS}")
|
2020-01-27 09:47:42 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
install(TARGETS openFPGALoader DESTINATION bin)
|
|
|
|
|
install(FILES
|
|
|
|
|
test_sfl.svf
|
|
|
|
|
spiOverJtag/spiOverJtag_xc7a35.bit
|
2020-08-08 11:42:38 +02:00
|
|
|
spiOverJtag/spiOverJtag_xc7s50.bit
|
2020-02-16 13:33:38 +01:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openFPGALoader
|
2020-01-27 09:47:42 +01:00
|
|
|
)
|