135 lines
4.7 KiB
Diff
135 lines
4.7 KiB
Diff
|
From 8146d440a24b262c2fabde0da1df9035404a4c11 Mon Sep 17 00:00:00 2001
|
||
|
From: Neil Hanlon <neil@rockylinux.org>
|
||
|
Date: Fri, 30 Dec 2022 23:49:37 -0500
|
||
|
Subject: [PATCH] Fix cmake
|
||
|
|
||
|
---
|
||
|
CMakeLists.txt | 80 ++++++++++++++++++++++----------------
|
||
|
tools/blisp/CMakeLists.txt | 14 ++++---
|
||
|
2 files changed, 55 insertions(+), 44 deletions(-)
|
||
|
|
||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||
|
index 2288949..fa22831 100644
|
||
|
--- a/CMakeLists.txt
|
||
|
+++ b/CMakeLists.txt
|
||
|
@@ -32,41 +32,55 @@ set_target_properties(libblisp_static PROPERTIES
|
||
|
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.")
|
||
|
-elseif(APPLE)
|
||
|
- target_sources(libblisp_obj PRIVATE
|
||
|
- ${CMAKE_SOURCE_DIR}/vendor/libserialport/macosx.c)
|
||
|
- 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\")))")
|
||
|
- target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport)
|
||
|
- 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})
|
||
|
+
|
||
|
+
|
||
|
+set(BLISP_PACKAGE_NAME Blisp)
|
||
|
+set(BLISP_VERSION 1.0.0)
|
||
|
+
|
||
|
+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")
|
||
|
+
|
||
|
+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 --git a/tools/blisp/CMakeLists.txt b/tools/blisp/CMakeLists.txt
|
||
|
index 6cb53f4..c345fd5 100644
|
||
|
--- a/tools/blisp/CMakeLists.txt
|
||
|
+++ b/tools/blisp/CMakeLists.txt
|
||
|
@@ -1,17 +1,19 @@
|
||
|
-add_subdirectory(${CMAKE_SOURCE_DIR}/vendor/argtable3 ${CMAKE_CURRENT_BINARY_DIR}/argtable3)
|
||
|
+# add_subdirectory(${CMAKE_SOURCE_DIR}/vendor/argtable3 ${CMAKE_CURRENT_BINARY_DIR}/argtable3)
|
||
|
|
||
|
add_executable(blisp src/main.c src/cmd/write.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()
|
||
|
+
|