Merge pull request #17 from Martoni/cmake
Cmake compile system proposal
This commit is contained in:
commit
9dc0372304
|
|
@ -0,0 +1,96 @@
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
|
# set the project name
|
||||||
|
project(openFPGALoader VERSION 0.1 LANGUAGES CXX)
|
||||||
|
|
||||||
|
## specify the C++ standard
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra")
|
||||||
|
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(LIBFTDI REQUIRED libftdi1)
|
||||||
|
pkg_check_modules(LIBFTDIPP REQUIRED libftdipp1)
|
||||||
|
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
|
||||||
|
pkg_check_modules(LIBUDEV REQUIRED libudev)
|
||||||
|
|
||||||
|
set(OPENFPGALOADER_SOURCE
|
||||||
|
src/spiFlash.cpp
|
||||||
|
src/epcq.cpp
|
||||||
|
src/svf_jtag.cpp
|
||||||
|
src/jedParser.cpp
|
||||||
|
src/display.cpp
|
||||||
|
src/ftdijtag.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/progressBar.hpp
|
||||||
|
src/bitparser.hpp
|
||||||
|
src/ftdijtag.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/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(${LIBUDEV_INCLUDE_DIRS}
|
||||||
|
${LIBUSB_INCLUDE_DIRS}
|
||||||
|
${LIBFTDI_INCLUDE_DIRS}
|
||||||
|
${LIBFTDIPP_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(openFPGALoader
|
||||||
|
${LIBUDEV_LIBRARIES}
|
||||||
|
${LIBUSB_LIBRARIES}
|
||||||
|
${LIBFTDI_LIBRARIES}
|
||||||
|
${LIBFTDIPP_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
# libftdi < 1.4 as no usb_addr
|
||||||
|
if (${LIBFTDI_VERSION} VERSION_LESS 1.4)
|
||||||
|
set(CMAKE_CXX_FLAGS "-DOLD_FTDI_VERSION=1")
|
||||||
|
else()
|
||||||
|
set(CMAKE_CXX_FLAGS "-DOLD_FTDI_VERSION=0")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(TARGETS openFPGALoader DESTINATION bin)
|
||||||
|
install(FILES
|
||||||
|
test_sfl.svf
|
||||||
|
spiOverJtag/spiOverJtag_xc7a35.bit
|
||||||
|
DESTINATION share/openFPGALoader
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Install instructions
|
||||||
|
|
||||||
|
## Compile from source
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir build
|
||||||
|
$ cd build
|
||||||
|
$ cmake ../src/
|
||||||
|
$ cmake --build .
|
||||||
|
```
|
||||||
32
Makefile
32
Makefile
|
|
@ -1,32 +0,0 @@
|
||||||
EXEC_NAME=openFPGALoader
|
|
||||||
SRC= $(wildcard *.cpp)
|
|
||||||
OBJS= $(SRC:.cpp=.o)
|
|
||||||
LDFLAGS=-lm -g -Wall -std=c++11 $(shell pkg-config --libs libftdipp1 libudev)
|
|
||||||
CXXFLAGS=-g -Wall -std=c++11 $(shell pkg-config --cflags libftdipp1 libudev)
|
|
||||||
|
|
||||||
# libftdi < 1.4 as no usb_addr
|
|
||||||
ifeq ($(shell pkg-config --atleast-version=1.4 libftdipp1 && echo 1),)
|
|
||||||
CXXFLAGS+=-DOLD_FTDI_VERSION=1
|
|
||||||
else
|
|
||||||
CXXFLAGS+=-DOLD_FTDI_VERSION=0
|
|
||||||
endif
|
|
||||||
|
|
||||||
all:$(EXEC_NAME)
|
|
||||||
|
|
||||||
$(EXEC_NAME):$(OBJS)
|
|
||||||
$(CXX) -o $@ $^ $(LDFLAGS)
|
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
install:
|
|
||||||
cp -f openFPGALoader /usr/local/bin
|
|
||||||
mkdir -p /usr/local/share/openFPGALoader
|
|
||||||
cp -f test_sfl.svf /usr/local/share/openFPGALoader
|
|
||||||
cp -f spiOverJtag/*.bit /usr/local/share/openFPGALoader
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf *.o
|
|
||||||
rm -f $(EXEC_NAME)
|
|
||||||
rm -f *.c~ *.h~ Makefile~
|
|
||||||
rm -f out*.dat
|
|
||||||
|
|
@ -28,7 +28,7 @@ __Supported cables:__
|
||||||
This application uses **libftdi1**, so this library must be installed (and,
|
This application uses **libftdi1**, so this library must be installed (and,
|
||||||
depending of the distribution, headers too)
|
depending of the distribution, headers too)
|
||||||
```bash
|
```bash
|
||||||
apt-get install libftdi1-2 libftdi1-dev libftdipp1-3 libftdipp1-dev libudev-dev
|
apt-get install libftdi1-2 libftdi1-dev libftdipp1-3 libftdipp1-dev libudev-dev cmake
|
||||||
```
|
```
|
||||||
and if not already done, install **pkg-config**, **make** and **g++**.
|
and if not already done, install **pkg-config**, **make** and **g++**.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
// the configured options and settings for openFPGALoader
|
||||||
|
#define openFPGALoader_VERSION_MAJOR @openFPGALoader_VERSION_MAJOR@
|
||||||
|
#define openFPGALoader_VERSION_MINOR @openFPGALoader_VERSION_MINOR@
|
||||||
Loading…
Reference in New Issue