diff -ru blisp-0.0.2/CMakeLists.txt blisp-0.0.2-b/CMakeLists.txt --- blisp-0.0.2/CMakeLists.txt 2023-01-12 05:49:04.000000000 -0500 +++ blisp-0.0.2-b/CMakeLists.txt 2023-01-12 14:31:14.092073606 -0500 @@ -32,29 +32,18 @@ ARCHIVE_OUTPUT_DIRECTORY "static" OUTPUT_NAME "blisp") -target_sources(libblisp_obj PRIVATE - ${CMAKE_SOURCE_DIR}/vendor/libserialport/serialport.c - ${CMAKE_SOURCE_DIR}/vendor/libserialport/timing.c) - -target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport) - if(WIN32) target_link_libraries(libblisp_obj PRIVATE Setupapi.lib) 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) - 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 - "SP_API=__attribute__((visibility(\"default\")))" - "SP_PRIV=__attribute__((visibility(\"hidden\")))") - write_file(${CMAKE_SOURCE_DIR}/vendor/libserialport/config.h "// bypass errors.") + find_package(PkgConfig) + pkg_check_modules(LIBSP REQUIRED libserialport>=0.1.1) + + target_link_libraries(libblisp_obj PRIVATE ${LIBSP_LIBRARIES}) + target_include_directories(libblisp_obj PRIVATE ${LIBSP_INCLUDE_DIRS}) + target_compile_options(libblisp_obj PUBLIC ${LIBSP_CFLAGS_OTHER}) elseif(APPLE) target_sources(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport/macosx.c) @@ -67,6 +56,49 @@ write_file(${CMAKE_SOURCE_DIR}/vendor/libserialport/config.h "// bypass errors.") endif() +set(BLISP_PACKAGE_NAME Blisp) +set(BLISP_VERSION 0.0.2) +include(GNUInstallDirs) +if(UNIX OR MSYS OR MINGW) + set(BLISP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/blisp) +elseif(WIN32) + set(BLISP_INSTALL_CMAKEDIR "cmake") +endif() + if(BLISP_BUILD_CLI) add_subdirectory(tools/blisp) + install(TARGETS blisp + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) endif() + +install(TARGETS libblisp + EXPORT ${BLISP_PACKAGE_NAME}Config + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +file(GLOB HEADER_FILES + "${PROJECT_SOURCE_DIR}/include/*.h" + "${PROJECT_SOURCE_DIR}/data/*.h" +) + +install(FILES ${HEADER_FILES} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +install(EXPORT ${BLISP_PACKAGE_NAME}Config + NAMESPACE ${BLISP_PROJECT_NAME}:: + DESTINATION ${BLISP_INSTALL_CMAKEDIR} +) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file("${PROJECT_BINARY_DIR}/${BLISP_PACKAGE_NAME}ConfigVersion.cmake" + VERSION ${BLISP_VERSION} + COMPATIBILITY SameMajorVersion +) + +install(FILES "${PROJECT_BINARY_DIR}/${BLISP_PACKAGE_NAME}ConfigVersion.cmake" + DESTINATION ${BLISP_INSTALL_CMAKEDIR} +) diff -ru blisp-0.0.2/tools/blisp/CMakeLists.txt blisp-0.0.2-b/tools/blisp/CMakeLists.txt --- blisp-0.0.2/tools/blisp/CMakeLists.txt 2023-01-12 05:49:04.000000000 -0500 +++ blisp-0.0.2-b/tools/blisp/CMakeLists.txt 2023-01-12 14:20:35.839890965 -0500 @@ -1,20 +1,21 @@ 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) -target_include_directories(blisp PRIVATE - "${CMAKE_SOURCE_DIR}/include" - "${CMAKE_SOURCE_DIR}/vendor/argtable3/src") +find_package(Argtable3 REQUIRED) +target_include_directories(blisp PRIVATE + "${CMAKE_SOURCE_DIR}/include") target_link_libraries(blisp PRIVATE - argtable3 + argtable3::argtable3 + ${LIBSP_LIBRARIES} libblisp_static) if (WIN32) target_link_libraries(blisp PRIVATE Setupapi.lib) elseif (APPLE) target_link_libraries(blisp PRIVATE "-framework IOKit" "-framework CoreFoundation") -endif () \ No newline at end of file +endif () +