blisp/CMakeLists.txt

80 lines
3.1 KiB
CMake
Raw Normal View History

2022-08-24 10:06:39 +00:00
cmake_minimum_required(VERSION 3.22)
project(blisp C)
set(CMAKE_C_STANDARD 23)
2022-09-24 09:58:47 +00:00
option(BLISP_BUILD_CLI "Build CLI Tool" OFF)
2022-09-25 08:58:59 +00:00
add_library(libblisp_obj OBJECT
lib/blisp.c
2022-11-08 21:06:14 +00:00
lib/chip/blisp_chip_bl60x.c
lib/chip/blisp_chip_bl70x.c lib/blisp_easy.c)
2022-09-25 08:58:59 +00:00
target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/include/)
set_property(TARGET libblisp_obj PROPERTY POSITION_INDEPENDENT_CODE 1)
2022-09-24 09:58:47 +00:00
2022-09-25 08:58:59 +00:00
add_library(libblisp SHARED $<TARGET_OBJECTS:libblisp_obj>)
add_library(libblisp_static STATIC $<TARGET_OBJECTS:libblisp_obj>)
2022-09-24 09:58:47 +00:00
set_target_properties(libblisp PROPERTIES
2022-09-25 08:58:59 +00:00
PUBLIC_HEADER "include/blisp.h"
2023-01-21 13:50:35 +00:00
VERSION 0.0.3
2022-09-24 09:58:47 +00:00
SOVERSION 1
2022-09-25 08:58:59 +00:00
LIBRARY_OUTPUT_DIRECTORY "shared"
OUTPUT_NAME "blisp")
set_target_properties(libblisp_static PROPERTIES
PUBLIC_HEADER "include/blisp.h"
2023-01-21 13:50:35 +00:00
VERSION 0.0.3
2023-01-12 10:47:01 +00:00
SOVERSION 1
2022-09-25 08:58:59 +00:00
ARCHIVE_OUTPUT_DIRECTORY "static"
OUTPUT_NAME "blisp")
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
2022-09-25 08:58:59 +00:00
target_sources(libblisp_obj PRIVATE
${CMAKE_SOURCE_DIR}/vendor/libserialport/serialport.c
${CMAKE_SOURCE_DIR}/vendor/libserialport/timing.c)
2022-11-07 14:22:06 +00:00
target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport)
endif()
2022-11-07 14:22:06 +00:00
2022-09-25 08:58:59 +00:00
if(WIN32)
2023-01-21 14:14:50 +00:00
target_link_libraries(libblisp PRIVATE Setupapi.lib)
target_link_libraries(libblisp_static PRIVATE Setupapi.lib)
2022-09-25 08:58:59 +00:00
target_compile_definitions(libblisp_obj PRIVATE LIBSERIALPORT_MSBUILD)
target_sources(libblisp_obj PRIVATE
${CMAKE_SOURCE_DIR}/vendor/libserialport/windows.c)
elseif(UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
2022-09-25 08:58:59 +00:00
target_sources(libblisp_obj PRIVATE
${CMAKE_SOURCE_DIR}/vendor/libserialport/linux.c
${CMAKE_SOURCE_DIR}/vendor/libserialport/linux_termios.c)
target_compile_definitions(libblisp_obj PRIVATE
LIBSERIALPORT_ATBUILD
HAVE_TERMIOS2_SPEED
HAVE_STRUCT_TERMIOS2
HAVE_DECL_BOTHER
2022-09-25 08:58:59 +00:00
"SP_API=__attribute__((visibility(\"default\")))"
"SP_PRIV=__attribute__((visibility(\"hidden\")))")
write_file(${CMAKE_SOURCE_DIR}/vendor/libserialport/config.h "// bypass errors.")
elseif(UNIX AND ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
target_include_directories(libblisp_obj PRIVATE /usr/local/include/)
target_link_libraries(libblisp PRIVATE -L/usr/local/lib usb serialport)
target_link_libraries(libblisp_static PRIVATE -L/usr/local/lib usb serialport)
2022-10-05 09:53:32 +00:00
elseif(APPLE)
target_sources(libblisp_obj PRIVATE
${CMAKE_SOURCE_DIR}/vendor/libserialport/macosx.c)
2022-12-06 16:15:53 +00:00
target_link_libraries(libblisp PRIVATE "-framework IOKit" "-framework CoreFoundation")
target_compile_definitions(libblisp_obj PRIVATE
LIBSERIALPORT_ATBUILD
"SP_PRIV=__attribute__((visibility(\"hidden\")))"
"SP_API=__attribute__((visibility(\"default\")))")
2022-10-05 09:53:32 +00:00
target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport)
write_file(${CMAKE_SOURCE_DIR}/vendor/libserialport/config.h "// bypass errors.")
2022-09-25 08:58:59 +00:00
endif()
2022-09-24 09:58:47 +00:00
if(BLISP_BUILD_CLI)
add_subdirectory(tools/blisp)
endif()