Skip to content

Commit bfe472e

Browse files
authored
Merge pull request #65 from JetbladeDevsStuff/fix-build-macos
Fix lots of build problems on macOS
2 parents 1fb33da + 2268e53 commit bfe472e

File tree

3 files changed

+86
-7
lines changed

3 files changed

+86
-7
lines changed

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cmake_minimum_required(VERSION 3.16)
2-
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
2+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
3+
# set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
34
project(blisp C)
45
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
56
set(CMAKE_C_STANDARD 11)
@@ -42,11 +43,10 @@ set_target_properties(libblisp_static PROPERTIES
4243
OUTPUT_NAME "blisp")
4344

4445
if(BLISP_USE_SYSTEM_LIBRARIES)
45-
find_package(PkgConfig)
46-
pkg_search_module(LIBSERIALPORT REQUIRED libserialport)
47-
target_link_libraries(libblisp PUBLIC ${LIBSERIALPORT_LIBRARIES})
48-
target_link_libraries(libblisp_static PUBLIC ${LIBSERIALPORT_LIBRARIES})
49-
target_include_directories(libblisp_obj PUBLIC ${LIBSERIALPORT_INCLUDE_DIRS})
46+
find_package(Libserialport REQUIRED)
47+
target_link_libraries(libblisp PUBLIC Libserialport::Libserialport)
48+
target_link_libraries(libblisp_static PUBLIC Libserialport::Libserialport)
49+
target_include_directories(libblisp_obj PUBLIC ${Libserialport_INCLUDE_DIRS})
5050
else()
5151
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
5252
target_sources(libblisp_obj PRIVATE

cmake/FindLibserialport.cmake

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# SPDX-License-Identifier: MIT
2+
3+
#[=======================================================================[.rst:
4+
FindLibserialport
5+
-------
6+
7+
Finds the sigrok serial port library (``libserialport``)
8+
9+
Imported Targets
10+
^^^^^^^^^^^^^^^^
11+
12+
This module defines the following imported targets, if found:
13+
14+
``Libserialport::Libserialport``
15+
The serialport library
16+
17+
Result Variables
18+
^^^^^^^^^^^^^^^^
19+
20+
This module will define the following variables:
21+
22+
``Libserialport_FOUND``
23+
True if the system has the serialport library.
24+
``Libserialport_VERSION``
25+
The version of the serialport library which was found.
26+
``Libserialport_INCLUDE_DIRS``
27+
Include directories needed to use ``libserialport``.
28+
``Libserialport_LIBRARIES``
29+
Libraries needed to link to ``libserialport``.
30+
31+
Cache Variables
32+
^^^^^^^^^^^^^^^
33+
34+
The following cache variables may also be set:
35+
36+
``Libserialport_INCLUDE_DIR``
37+
The directory containing ``libserialport.h``.
38+
``Libserialport_LIBRARY``
39+
The path to the ``libserialport`` library.
40+
41+
#]=======================================================================]
42+
43+
find_package(PkgConfig)
44+
pkg_check_modules(PC_Libserialport QUIET libserialport)
45+
46+
find_path(Libserialport_INCLUDE_DIR
47+
NAMES libserialport.h
48+
PATHS "${PC_Libserialport_INCLUDE_DIRS}"
49+
)
50+
find_library(Libserialport_LIBRARY
51+
NAMES serialport
52+
HINTS "${PC_Libserialport_LIBRARY_DIRS}"
53+
)
54+
55+
set(Foo_VERSION ${PC_Foo_VERSION})
56+
57+
include(FindPackageHandleStandardArgs)
58+
find_package_handle_standard_args(Libserialport
59+
FOUND_VAR Libserialport_FOUND
60+
REQUIRED_VARS
61+
Libserialport_LIBRARY
62+
Libserialport_INCLUDE_DIR
63+
VERSION_VAR Libserialport_VERSION
64+
)
65+
66+
if(Libserialport_FOUND)
67+
set(Libserialport_LIBRARIES ${Libserialport_LIBRARY})
68+
set(Libserialport_INCLUDE_DIRS ${Libserialport_INCLUDE_DIR})
69+
set(Libserialport_DEFINITIONS ${PC_Liberialport_CFLAGS_OTHER})
70+
endif()
71+
72+
if(Libserialport_FOUND AND NOT TARGET Libserialport::Libserialport)
73+
add_library(Libserialport::Libserialport UNKNOWN IMPORTED)
74+
set_target_properties(Libserialport::Libserialport PROPERTIES
75+
IMPORTED_LOCATION "${Libserialport_LIBRARY}"
76+
INTERFACE_COMPILE_OPTIONS "${PC_Libserialport_CFLAGS_OTHER}"
77+
INTERFACE_INCLUDE_DIRECTORIES "${Libserialport_INCLUDE_DIR}"
78+
)
79+
endif()

tools/blisp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ target_include_directories(blisp PRIVATE
2020
"${CMAKE_SOURCE_DIR}/include")
2121

2222
target_link_libraries(blisp PRIVATE
23-
argtable3
23+
argtable3::argtable3
2424
libblisp_static file_parsers)
2525

2626
if (WIN32)

0 commit comments

Comments
 (0)