瀏覽代碼

Added CMake to project so it can be cross-compiled

pull/254/head
Goran Filinić 6 月之前
父節點
當前提交
1fc6be2892
共有 7 個文件被更改,包括 212 次插入10 次删除
  1. +9
    -0
      CMakeLists.txt
  2. +7
    -10
      build
  3. +36
    -0
      devLib/CMakeLists.txt
  4. +29
    -0
      gpio/CMakeLists.txt
  5. +28
    -0
      pins/CMakeLists.txt
  6. +66
    -0
      wiringPi/CMakeLists.txt
  7. +37
    -0
      wiringPiD/CMakeLists.txt

+ 9
- 0
CMakeLists.txt 查看文件

@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.10)
project(WiringPiLib)

# Include subdirectories
add_subdirectory(devLib)
add_subdirectory(gpio)
add_subdirectory(pins)
add_subdirectory(wiringPi)
add_subdirectory(wiringPiD)

+ 7
- 10
build 查看文件

@@ -100,7 +100,7 @@ if [ x$1 = "xdebian" ]; then
cd $here/gpio
make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib DEB_DESTDIR=${deb_destdir}
cd $here/debian-template
fakeroot dpkg-deb --build wiringPi
dpkg-deb --build wiringPi
dpkg-name -o wiringPi.deb
exit
fi
@@ -119,30 +119,28 @@ fi
echo
echo "WiringPi Library"
cd wiringPi
$sudo make uninstall
if [ x$1 = "xstatic" ]; then
make -j5 static
check_make_ok
$sudo make install-static
oe_runmake-static
else
make -j5
check_make_ok
$sudo make install
oe_runmake
fi
check_make_ok

echo
echo "WiringPi Devices Library"
cd ../devLib
$sudo make uninstall
if [ x$1 = "xstatic" ]; then
make -j5 static
check_make_ok
$sudo make install-static
oe_runmake-static
else
make -j5
check_make_ok
$sudo make install
oe_runmake
fi
check_make_ok

@@ -151,15 +149,14 @@ fi
cd ../gpio
make -j5
check_make_ok
$sudo make install
check_make_ok
oe_runmake

# echo
# echo "wiringPi Daemon"
# cd ../wiringPiD
# make -j5
# check_make_ok
# $sudo make install
# oe_runmake
# check_make_ok

# echo


+ 36
- 0
devLib/CMakeLists.txt 查看文件

@@ -0,0 +1,36 @@
# CMakeLists.txt for devLib

cmake_minimum_required(VERSION 3.10)
project(devLib)

# Source files
set(SRC
ds1302.c maxdetect.c piNes.c
gertboard.c piFace.c
lcd128x64.c lcd.c
scrollPhat.c
piGlow.c
)

# Headers
set(HEADERS
ds1302.h maxdetect.h piNes.h
gertboard.h piFace.h
lcd128x64.h lcd.h
scrollPhatFont.h scrollPhat.h
piGlow.h
)

# Compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat=2 -Winline -pipe -fPIC")

# Add the library target
add_library(wiringPiDev SHARED ${SRC})

# Set the library version
set_target_properties(wiringPiDev PROPERTIES VERSION ${VERSION} SOVERSION ${WIRINGPI_SONAME_SUFFIX})

# Install headers
install(FILES ${HEADERS} DESTINATION include)
# Install the library
install(TARGETS wiringPiDev LIBRARY DESTINATION lib)

+ 29
- 0
gpio/CMakeLists.txt 查看文件

@@ -0,0 +1,29 @@
# CMakeLists.txt for gpio

cmake_minimum_required(VERSION 3.10)
project(gpio)

# Source files
set(SRC
gpio.c
readall.c
)

# Compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")

# Add the executable target
add_executable(gpio ${SRC})

# Find the required libraries
find_library(WIRINGPI_LIB wiringPi)
find_library(WIRINGPI_DEV_LIB wiringPiDev)

# Link the required libraries
target_link_libraries(gpio ${WIRINGPI_LIB} ${WIRINGPI_DEV_LIB} pthread rt m crypt)

# Install the executable
install(TARGETS gpio DESTINATION bin)

# Install man page
install(FILES gpio.1 DESTINATION share/man/man1)

+ 28
- 0
pins/CMakeLists.txt 查看文件

@@ -0,0 +1,28 @@
# CMakeLists.txt for pins

cmake_minimum_required(VERSION 3.10)
project(pins LANGUAGES NONE)

# Source file
set(SRC pins.tex)

# Add custom target to generate PDF
add_custom_target(pins_pdf
COMMAND latex ${SRC}
COMMAND dvipdf ${SRC:.tex=.dvi}
COMMENT "Generating PDF"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

# Add clean target
add_custom_target(clean_pins
COMMAND rm -f *.dvi *.aux *.log *.ps *.toc *.bak *~
COMMENT "Cleaning pins"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

# Add dependencies
add_dependencies(pins_pdf clean_pins)

# Install PDF
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pins.pdf DESTINATION share/pins)

+ 66
- 0
wiringPi/CMakeLists.txt 查看文件

@@ -0,0 +1,66 @@
# CMakeLists.txt for wiringPi

cmake_minimum_required(VERSION 3.10)
project(WiringPi)

# Source files
set(SRC
wiringPi.c
wiringSerial.c wiringShift.c
piHiPri.c piThread.c
wiringPiSPI.c wiringPiI2C.c
softPwm.c softTone.c
mcp23008.c mcp23016.c mcp23017.c
mcp23s08.c mcp23s17.c
sr595.c
pcf8574.c pcf8591.c
mcp3002.c mcp3004.c mcp4802.c mcp3422.c
max31855.c max5322.c ads1115.c
sn3218.c
bmp180.c htu21d.c ds18b20.c rht03.c
drcSerial.c drcNet.c
pseudoPins.c
wpiExtensions.c
wiringPiLegacy.c
)

# Headers
set(HEADERS
wiringPi.h
wiringSerial.h wiringShift.h
wiringPiSPI.h wiringPiI2C.h
softPwm.h softTone.h
mcp23008.h mcp23016.h mcp23017.h
mcp23s08.h mcp23s17.h
sr595.h
pcf8574.h pcf8591.h
mcp3002.h mcp3004.h mcp4802.h mcp3422.h
max31855.h max5322.h ads1115.h
sn3218.h
bmp180.h htu21d.h ds18b20.h rht03.h
drcSerial.h drcNet.h
pseudoPins.h
wpiExtensions.h
)
# Compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Winline -pipe -fPIC -Wformat-security")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-soname,libwiringPi.so${WIRINGPI_SONAME_SUFFIX}")

# Read version from version.h
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/../version.h" VERSION)
string(REGEX REPLACE ".*VERSION \"([0-9]+.[0-9]+)\".*" "\\1" VERSION "${VERSION}")

# Add the library target
add_library(wiringPi SHARED ${SRC})

# Set the library version
set(WIRINGPI_SONAME_SUFFIX "1")
set_target_properties(wiringPi PROPERTIES VERSION ${VERSION} SOVERSION ${WIRINGPI_SONAME_SUFFIX})
target_include_directories(wiringPi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

# Add -lm to link with the math library
target_link_libraries(wiringPi PUBLIC m crypt)
# Install headers
install(FILES ${HEADERS} DESTINATION include)
# Install the library
install(TARGETS wiringPi LIBRARY DESTINATION lib)

+ 37
- 0
wiringPiD/CMakeLists.txt 查看文件

@@ -0,0 +1,37 @@
# CMakeLists.txt for wiringPiD

cmake_minimum_required(VERSION 3.10)
project(wiringPiD)

# Source files
set(SRC wiringpid.c network.c runRemote.c daemonise.c)

# Add the executable
add_executable(wiringpid ${SRC})

# Set C compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -Wextra")

# Include directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

# Link libraries
find_library(WIRINGPI_LIB wiringPi)
find_library(WIRINGPIDEV_LIB wiringPiDev)
find_library(PTHREAD_LIB pthread)
find_library(RT_LIB rt)
find_library(M_LIB m)
find_library(CRYPT_LIB crypt)
target_link_libraries(wiringpid
${WIRINGPI_LIB}
${WIRINGPIDEV_LIB}
${PTHREAD_LIB}
${RT_LIB}
${M_LIB}
${CRYPT_LIB}
)

# Install the executable
install(TARGETS wiringpid
RUNTIME DESTINATION bin
)

Loading…
取消
儲存