From caeaa206eb51459f9342b4042b1af2ec395bf0ac Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 1 Nov 2023 14:53:02 +0100 Subject: [PATCH] port: update to CMake 3.12, mark PortAudio as optional, add pthread lib for posix --- port/libusb/CMakeLists.txt | 10 ++++------ port/posix-h4-bcm/CMakeLists.txt | 13 ++++++++----- port/posix-h4-nxp/CMakeLists.txt | 10 ++++++---- port/posix-h4-zephyr/CMakeLists.txt | 10 ++++------ port/posix-h4/CMakeLists.txt | 12 +++++++----- port/windows-h4-da14585/CMakeLists.txt | 8 +++----- port/windows-h4-zephyr/CMakeLists.txt | 10 ++++------ port/windows-h4/CMakeLists.txt | 8 +++----- port/windows-winusb-intel/CMakeLists.txt | 8 +++----- port/windows-winusb/CMakeLists.txt | 8 +++----- 10 files changed, 45 insertions(+), 52 deletions(-) diff --git a/port/libusb/CMakeLists.txt b/port/libusb/CMakeLists.txt index 448ae8373..b31f74230 100644 --- a/port/libusb/CMakeLists.txt +++ b/port/libusb/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.12) SET(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk) SET(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -138,7 +138,7 @@ list(SORT SOURCES) # create static lib add_library(btstack STATIC ${SOURCES}) -# pkgconfig +# pkgconfig required to link libusb find_package(PkgConfig REQUIRED) # libusb @@ -148,21 +148,19 @@ link_directories(${LIBUSB_LIBRARY_DIRS}) link_libraries(${LIBUSB_LIBRARIES}) # portaudio -pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) +pkg_check_modules(PORTAUDIO portaudio-2.0) if(PORTAUDIO_FOUND) message("HAVE_PORTAUDIO") include_directories(${PORTAUDIO_INCLUDE_DIRS}) link_directories(${PORTAUDIO_LIBRARY_DIRS}) link_libraries(${PORTAUDIO_LIBRARIES}) - # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) - SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") + add_compile_definitions(HAVE_PORTAUDIO) endif() # pthread find_package(Threads) link_libraries(${CMAKE_THREAD_LIBS_INIT}) - # create targets for all examples file(GLOB EXAMPLES_C "../../example/*.c") list(SORT EXAMPLES_C) diff --git a/port/posix-h4-bcm/CMakeLists.txt b/port/posix-h4-bcm/CMakeLists.txt index abc10c5fe..eaf8be52e 100644 --- a/port/posix-h4-bcm/CMakeLists.txt +++ b/port/posix-h4-bcm/CMakeLists.txt @@ -130,21 +130,24 @@ list(SORT SOURCES) add_library(btstack STATIC ${SOURCES}) # pkgconfig -find_package(PkgConfig QUIET) +find_package(PkgConfig) # portaudio -if (PgConfig_FOUND) - pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) +if (PkgConfig_FOUND) + pkg_check_modules(PORTAUDIO portaudio-2.0) if(PORTAUDIO_FOUND) message("HAVE_PORTAUDIO") include_directories(${PORTAUDIO_INCLUDE_DIRS}) link_directories(${PORTAUDIO_LIBRARY_DIRS}) link_libraries(${PORTAUDIO_LIBRARIES}) - # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) - SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") + add_compile_definitions(HAVE_PORTAUDIO) endif() endif() +# pthread +find_package(Threads) +link_libraries(${CMAKE_THREAD_LIBS_INIT}) + # Add BCM Support include(${BTSTACK_ROOT}/chipset/bcm/bcm.cmake) diff --git a/port/posix-h4-nxp/CMakeLists.txt b/port/posix-h4-nxp/CMakeLists.txt index 2806628bc..d34fe5e98 100644 --- a/port/posix-h4-nxp/CMakeLists.txt +++ b/port/posix-h4-nxp/CMakeLists.txt @@ -130,21 +130,23 @@ list(SORT SOURCES) add_library(btstack STATIC ${SOURCES}) # pkgconfig -find_package(PkgConfig QUIET) +find_package(PkgConfig) # portaudio if (PkgConfig_FOUND) - pkg_check_modules(PORTAUDIO QUIET portaudio-2.0) + pkg_check_modules(PORTAUDIO portaudio-2.0) if(PORTAUDIO_FOUND) message("HAVE_PORTAUDIO") include_directories(${PORTAUDIO_INCLUDE_DIRS}) link_directories(${PORTAUDIO_LIBRARY_DIRS}) link_libraries(${PORTAUDIO_LIBRARIES}) - # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) - SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") + add_compile_definitions(HAVE_PORTAUDIO) endif() endif() +# pthread +find_package(Threads) +link_libraries(${CMAKE_THREAD_LIBS_INIT}) # Add NXP Support include(${BTSTACK_ROOT}/chipset/nxp/nxp.cmake) diff --git a/port/posix-h4-zephyr/CMakeLists.txt b/port/posix-h4-zephyr/CMakeLists.txt index 33071d023..15fb8c260 100644 --- a/port/posix-h4-zephyr/CMakeLists.txt +++ b/port/posix-h4-zephyr/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.12) SET(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk) SET(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -76,18 +76,17 @@ list(SORT SOURCES) add_library(btstack STATIC ${SOURCES}) # pkgconfig -find_package(PkgConfig QUIET) +find_package(PkgConfig) # portaudio if (PkgConfig_FOUND) - pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) + pkg_check_modules(PORTAUDIO portaudio-2.0) if(PORTAUDIO_FOUND) message("HAVE_PORTAUDIO") include_directories(${PORTAUDIO_INCLUDE_DIRS}) link_directories(${PORTAUDIO_LIBRARY_DIRS}) link_libraries(${PORTAUDIO_LIBRARIES}) - # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) - SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") + add_compile_definitions(HAVE_PORTAUDIO) endif() endif() @@ -95,7 +94,6 @@ endif() find_package(Threads) link_libraries(${CMAKE_THREAD_LIBS_INIT}) - # get list of examples include(../../example/CMakeLists.txt) set (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL}) diff --git a/port/posix-h4/CMakeLists.txt b/port/posix-h4/CMakeLists.txt index 73157d2d3..71c8f4a73 100644 --- a/port/posix-h4/CMakeLists.txt +++ b/port/posix-h4/CMakeLists.txt @@ -152,21 +152,23 @@ list(SORT SOURCES) add_library(btstack STATIC ${SOURCES}) # pkgconfig -find_package(PkgConfig QUIET) +find_package(PkgConfig) # portaudio if (PkgConfig_FOUND) - pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) + pkg_check_modules(PORTAUDIO portaudio-2.0) if(PORTAUDIO_FOUND) message("HAVE_PORTAUDIO") include_directories(${PORTAUDIO_INCLUDE_DIRS}) link_directories(${PORTAUDIO_LIBRARY_DIRS}) link_libraries(${PORTAUDIO_LIBRARIES}) - # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) - SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") + add_compile_definitions(HAVE_PORTAUDIO) endif() endif() +# pthread +find_package(Threads) +link_libraries(${CMAKE_THREAD_LIBS_INIT}) # Add CC256x Support and specify init script set (CC256X_INIT_SCRIPT bluetooth_init_cc2564C_1.5.c) @@ -200,5 +202,5 @@ foreach(EXAMPLE ${EXAMPLES}) message("example ${EXAMPLE}") endif() add_executable(${EXAMPLE} ${SOURCES_EXAMPLE}) - target_link_libraries(${EXAMPLE} btstack) + target_link_libraries(${EXAMPLE} btstack pthread) endforeach(EXAMPLE) diff --git a/port/windows-h4-da14585/CMakeLists.txt b/port/windows-h4-da14585/CMakeLists.txt index c5e74a0b3..b99fb4de1 100644 --- a/port/windows-h4-da14585/CMakeLists.txt +++ b/port/windows-h4-da14585/CMakeLists.txt @@ -70,22 +70,20 @@ list(SORT SOURCES) add_library(btstack STATIC ${SOURCES}) # pkgconfig -find_package(PkgConfig QUIET) +find_package(PkgConfig) # portaudio if (PkgConfig_FOUND) - pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) + pkg_check_modules(PORTAUDIO portaudio-2.0) if(PORTAUDIO_FOUND) message("HAVE_PORTAUDIO") include_directories(${PORTAUDIO_INCLUDE_DIRS}) link_directories(${PORTAUDIO_LIBRARY_DIRS}) link_libraries(${PORTAUDIO_LIBRARIES}) - # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) - SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") + add_compile_definitions(HAVE_PORTAUDIO) endif() endif() - # get list of examples, skipping mesh_node_demo include(../../example/CMakeLists.txt) set (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL}) diff --git a/port/windows-h4-zephyr/CMakeLists.txt b/port/windows-h4-zephyr/CMakeLists.txt index b39620722..cf14a8a27 100644 --- a/port/windows-h4-zephyr/CMakeLists.txt +++ b/port/windows-h4-zephyr/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.12) project(BTstack-windows-h4-zephyr) @@ -70,22 +70,20 @@ list(SORT SOURCES) add_library(btstack STATIC ${SOURCES}) # pkgconfig -find_package(PkgConfig QUIET) +find_package(PkgConfig) # portaudio if (PkgConfig_FOUND) - pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) + pkg_check_modules(PORTAUDIO portaudio-2.0) if(PORTAUDIO_FOUND) message("HAVE_PORTAUDIO") include_directories(${PORTAUDIO_INCLUDE_DIRS}) link_directories(${PORTAUDIO_LIBRARY_DIRS}) link_libraries(${PORTAUDIO_LIBRARIES}) - # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) - SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") + add_compile_definitions(HAVE_PORTAUDIO) endif() endif() - # get list of examples, skipping mesh_node_demo include(../../example/CMakeLists.txt) set (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL}) diff --git a/port/windows-h4/CMakeLists.txt b/port/windows-h4/CMakeLists.txt index 516bb3723..a8b627318 100644 --- a/port/windows-h4/CMakeLists.txt +++ b/port/windows-h4/CMakeLists.txt @@ -153,22 +153,20 @@ list(SORT SOURCES) add_library(btstack STATIC ${SOURCES}) # pkgconfig -find_package(PkgConfig QUIET) +find_package(PkgConfig) # portaudio if (PkgConfig_FOUND) - pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) + pkg_check_modules(PORTAUDIO portaudio-2.0) if(PORTAUDIO_FOUND) message("HAVE_PORTAUDIO") include_directories(${PORTAUDIO_INCLUDE_DIRS}) link_directories(${PORTAUDIO_LIBRARY_DIRS}) link_libraries(${PORTAUDIO_LIBRARIES}) - # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) - SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") + add_compile_definitions(HAVE_PORTAUDIO) endif() endif() - # Add CC256x Support and specify init script set (CC256X_INIT_SCRIPT bluetooth_init_cc2564C_1.5.c) include(${BTSTACK_ROOT}/chipset/cc256x/cc256x.cmake) diff --git a/port/windows-winusb-intel/CMakeLists.txt b/port/windows-winusb-intel/CMakeLists.txt index 1ae1600e3..be262c37d 100644 --- a/port/windows-winusb-intel/CMakeLists.txt +++ b/port/windows-winusb-intel/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.12) project(BTstack-windows-winusb-intel) @@ -91,18 +91,16 @@ find_package(PkgConfig QUIET) # portaudio if (PkgConfig_FOUND) - pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) + pkg_check_modules(PORTAUDIO portaudio-2.0) if(PORTAUDIO_FOUND) message("HAVE_PORTAUDIO") include_directories(${PORTAUDIO_INCLUDE_DIRS}) link_directories(${PORTAUDIO_LIBRARY_DIRS}) link_libraries(${PORTAUDIO_LIBRARIES}) - # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) - SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") + add_compile_definitions(HAVE_PORTAUDIO) endif() endif() - # get list of examples, skipping mesh_node_demo include(../../example/CMakeLists.txt) set (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY} ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE}) diff --git a/port/windows-winusb/CMakeLists.txt b/port/windows-winusb/CMakeLists.txt index bd129ecdc..3565f3c31 100644 --- a/port/windows-winusb/CMakeLists.txt +++ b/port/windows-winusb/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.12) project(BTstack-windows-winusb) @@ -83,18 +83,16 @@ find_package(PkgConfig QUIET) # portaudio if (PkgConfig_FOUND) - pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) + pkg_check_modules(PORTAUDIO portaudio-2.0) if(PORTAUDIO_FOUND) message("HAVE_PORTAUDIO") include_directories(${PORTAUDIO_INCLUDE_DIRS}) link_directories(${PORTAUDIO_LIBRARY_DIRS}) link_libraries(${PORTAUDIO_LIBRARIES}) - # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) - SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") + add_compile_definitions(HAVE_PORTAUDIO) endif() endif() - # get list of examples, skipping mesh_node_demo include(../../example/CMakeLists.txt) set (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY} ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE})