Open mcuee opened 8 months ago
vcpkg does not have the port yet. There was a new port request but nobody has done the port yet.
FYI, I have a very basic CMakeLists.txt
in PR #3.
@ndim
Nice. You are almost there already.
Need to add something similar to avrdude, for MinGW.
if(WIN32 OR MINGW)
list(APPEND EXTRA_WINDOWS_RESOURCES "${PROJECT_BINARY_DIR}/src/windows.rc")
list(APPEND EXTRA_WINDOWS_LIBRARIES setupapi hid ws2_32)
endif()
Build log
MINGW64 /c/work/avr/avrdude_test/avrdude_libserialport_pr3
$ cmake -B build_cmake_mingw64
-- Building for: Ninja
-- The C compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (5.7s)
-- Generating done (0.0s)
-- Build files have been written to: C:/work/avr/avrdude_test/avrdude_libserialport_pr3/build_cmake_mingw64
$ cmake --build build_cmake_mingw64
[2/2] Linking C shared library libserialport.dll
FAILED: libserialport.dll liblibserialport.dll.a
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\msys64\mingw64\bin\cc.exe -shared -o libserialport.dll -Wl,--out-implib,liblibserialport.dll.a -Wl,--major-image-version,0,--minor-image-version,1 CMakeFiles/libserialport.dir/windows.c.obj -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x9f2): undefined reference to `__imp_CM_Get_Parent'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xa17): undefined reference to `__imp_CM_Get_Device_IDA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xc52): undefined reference to `__imp_SetupDiGetClassDevsA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xca1): undefined reference to `__imp_SetupDiEnumDeviceInterfaces'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xcdb): undefined reference to `__imp_SetupDiGetDeviceInterfaceDetailA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xd45): undefined reference to `__imp_SetupDiGetDeviceInterfaceDetailA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xd74): undefined reference to `__imp_CM_Get_Parent'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xe4e): undefined reference to `__imp_SetupDiEnumDeviceInfo'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xe66): undefined reference to `__imp_SetupDiDestroyDeviceInfoList'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xec2): undefined reference to `__imp_SetupDiGetClassDevsA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xeda): undefined reference to `sp_last_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xf23): undefined reference to `sp_free_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xf70): undefined reference to `__imp_SetupDiOpenDevRegKey'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x1073): undefined reference to `__imp_CM_Get_Parent'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x10b1): undefined reference to `__imp_CM_Get_DevNode_Registry_PropertyA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x1142): undefined reference to `__imp_CM_Get_DevNode_Registry_PropertyA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x1170): undefined reference to `__imp_CM_Get_Parent'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x11f9): undefined reference to `__imp_CM_Get_Device_IDA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x1273): undefined reference to `__imp_CM_Get_DevNode_Registry_PropertyA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x133a): undefined reference to `__imp_CM_Get_DevNode_Registry_PropertyA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x13ba): undefined reference to `__imp_CM_Get_Parent'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x150f): undefined reference to `__imp_SetupDiEnumDeviceInfo'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x152d): undefined reference to `__imp_SetupDiDestroyDeviceInfoList'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x15ff): undefined reference to `sp_last_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x163f): undefined reference to `sp_free_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x16f7): undefined reference to `sp_last_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x1737): undefined reference to `sp_free_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x18de): undefined reference to `list_append'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.rdata$.refptr.sp_debug_handler[.refptr.sp_debug_handler]+0x0): undefined reference to `sp_debug_handler'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Similar for VS2019.
PS C:\work\avr\avrdude_test\avrdude_libserialport_pr3> cmake -B .\build_cmake_vs2019
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.29.30153.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/work/avr/avrdude_test/avrdude_libserialport_pr3/build_cmake_vs2019
PS C:\work\avr\avrdude_test\avrdude_libserialport_pr3> cmake --build .\build_cmake_vs2019
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Checking Build System
Building Custom Rule C:/work/avr/avrdude_test/avrdude_libserialport_pr3/CMakeLists.txt
windows.c
C:\work\avr\avrdude_test\avrdude_libserialport_pr3\libserialport.h(292,1): warning C4005: 'SP_API': macro redefinition
[C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\config.h(17): message : see previous definition o
f 'SP_API' [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_sp_last_error_message referenced in function get_port_det
ails [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_sp_free_error_message referenced in function get_port_det
ails [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiEnumDeviceInfo referenced in function get_port_det
ails [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiDestroyDeviceInfoList referenced in function get_p
ort_details [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiEnumDeviceInterfaces referenced in function get_us
b_details [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiGetDeviceInterfaceDetailA referenced in function g
et_usb_details [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiGetClassDevsA referenced in function get_port_deta
ils [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiOpenDevRegKey referenced in function get_port_deta
ils [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_CM_Get_Device_IDA referenced in function get_port_details
[C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_CM_Get_DevNode_Registry_PropertyA referenced in function
get_port_details [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_CM_Get_Parent referenced in function get_port_details [C:
\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol list_append referenced in function list_ports [C:\work\avr\avrd
ude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2001: unresolved external symbol sp_debug_handler [C:\work\avr\avrdude_test\avrdude_libserialpor
t_pr3\build_cmake_vs2019\libserialport.vcxproj]
C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\Debug\libserialport.dll : fatal error LNK1120: 13
unresolved externals [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
As of https://github.com/ndim/libserialport/commit/0574156aad7ee8e5332d132f25fb0383e773f0fe, the CI builds are succeeding: https://github.com/ndim/libserialport/actions/runs/8069048688
This includes cmake ("cm") and autotools ("at") builds:
The commit series and the resulting tree need massive cleanups, but at least we now have a known good state, at least in the sense of "it succeeds building something".
CMake build under macOS ARM64 (macOS 14.3.1, Mac Mini M1).
mcuee@mcuees-Mac-mini libserialport_ndim % cmake -B build_cmake
-- The C compiler identification is AppleClang 15.0.0.15000100
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/mcuee/build/avr/libserialport_ndim/build_cmake
mcuee@mcuees-Mac-mini libserialport_ndim % cmake --build build_cmake
[ 25%] Building C object CMakeFiles/libserialport.dir/serialport.c.o
[ 50%] Building C object CMakeFiles/libserialport.dir/timing.c.o
[ 75%] Building C object CMakeFiles/libserialport.dir/macosx.c.o
[100%] Linking C shared library libserialport.dylib
[100%] Built target libserialport
CMake under Linux.
mcuee@UbuntuSwift3 ~/build/avr/libserialport_ndim (add-version-suffix)$ cmake -B build_cmake
-- The C compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/mcuee/build/avr/libserialport_ndim/build_cmake
mcuee@UbuntuSwift3 ~/build/avr/libserialport_ndim (add-version-suffix)$ cmake --build build_cmake/
[ 20%] Building C object CMakeFiles/libserialport.dir/serialport.c.o
[ 40%] Building C object CMakeFiles/libserialport.dir/timing.c.o
[ 60%] Building C object CMakeFiles/libserialport.dir/linux.c.o
[ 80%] Building C object CMakeFiles/libserialport.dir/linux_termios.c.o
[100%] Linking C shared library libserialport.so
[100%] Built target libserialport
mcuee@UbuntuSwift3 ~/build/avr/libserialport_ndim (add-version-suffix)$ sudo cmake --build build_cmake --target install
[100%] Built target libserialport
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/pkgconfig/libserialport.pc
-- Installing: /usr/local/lib/libserialport.so.0.1.0
-- Installing: /usr/local/lib/libserialport.so.0
-- Installing: /usr/local/lib/libserialport.so
-- Installing: /usr/local/include/libserialport.h
Not so sure how to carry out cross-compiler under macOS though. https://github.com/arduino/avrdude-packing/issues/31#issuecomment-2016702499
Reference
To do:
This issue will address No 2 and No 3, which may require quite some efforts.