mirror of
https://github.com/pine64/blisp.git
synced 2025-03-30 14:57:16 +00:00
Optional syslibs support
Add optional support for building against system libraries of libserialport and Argtable3
This commit is contained in:
parent
2e931f80db
commit
8914260b60
@ -4,6 +4,7 @@ project(blisp C)
|
||||
set(CMAKE_C_STANDARD 23)
|
||||
|
||||
option(BLISP_BUILD_CLI "Build CLI Tool" OFF)
|
||||
option(BLISP_USE_SYSTEM_LIBRARIES "Use system-installed libraries" "${CMAKE_USE_SYSTEM_LIBRARIES}")
|
||||
|
||||
add_library(libblisp_obj OBJECT
|
||||
lib/blisp.c
|
||||
@ -38,6 +39,13 @@ set_target_properties(libblisp_static PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "static"
|
||||
OUTPUT_NAME "blisp")
|
||||
|
||||
if(BLISP_USE_SYSTEM_LIBRARIES)
|
||||
find_package(PkgConfig)
|
||||
pkg_search_module(LIBSERIALPORT REQUIRED libserialport)
|
||||
target_link_libraries(libblisp PUBLIC ${LIBSERIALPORT_LIBRARIES})
|
||||
target_link_libraries(libblisp_static PUBLIC ${LIBSERIALPORT_LIBRARIES})
|
||||
target_include_directories(libblisp_obj PUBLIC ${LIBSERIALPORT_INCLUDE_DIRS})
|
||||
else()
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
target_sources(libblisp_obj PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/vendor/libserialport/serialport.c
|
||||
@ -79,6 +87,7 @@ elseif(APPLE)
|
||||
target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport)
|
||||
write_file(${CMAKE_SOURCE_DIR}/vendor/libserialport/config.h "// bypass errors.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(TARGETS libblisp libblisp_static DESTINATION lib)
|
||||
|
||||
|
10
README.md
10
README.md
@ -54,6 +54,16 @@ mkdir build && cd build
|
||||
cmake -DBLISP_BUILD_CLI=ON ..
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
For building against preinstalled system libraries of the used vendor
|
||||
libraries (e.g. for use by system maintainers), additionally define
|
||||
`BLISP_USE_SYSTEM_LIBRARIES`, e.g. using following commands:
|
||||
```bash
|
||||
mkdir build && cd build
|
||||
cmake -DBLISP_USE_SYSTEM_LIBRARIES=ON -DBLISP_BUILD_CLI=ON ..
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
#### Need more build details? [See here](https://github.com/pine64/blisp/wiki/Update-Pinecil-V2#build-blisp-flasher-from-code).
|
||||
|
||||
## Usage
|
||||
|
@ -1,13 +1,20 @@
|
||||
set(ARGTABLE3_ENABLE_TESTS OFF CACHE BOOL "Enable unit tests")
|
||||
set(ARGTABLE3_ENABLE_EXAMPLES OFF CACHE BOOL "Enable examples")
|
||||
#set(ARGTABLE3_REPLACE_GETOPT OFF CACHE BOOL "Replace getopt in the system C library")
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/vendor/argtable3 ${CMAKE_CURRENT_BINARY_DIR}/argtable3)
|
||||
|
||||
add_executable(blisp src/main.c src/cmd/write.c src/util.c src/common.c src/cmd/iot.c)
|
||||
|
||||
if(BLISP_USE_SYSTEM_LIBRARIES)
|
||||
find_package(Argtable3 REQUIRED)
|
||||
else()
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/vendor/argtable3 ${CMAKE_CURRENT_BINARY_DIR}/argtable3)
|
||||
|
||||
target_include_directories(blisp PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}/include"
|
||||
"${CMAKE_SOURCE_DIR}/vendor/argtable3/src")
|
||||
endif()
|
||||
|
||||
target_include_directories(blisp PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}/include")
|
||||
|
||||
target_link_libraries(blisp PRIVATE
|
||||
argtable3
|
||||
|
Loading…
Reference in New Issue
Block a user