From fbcad749a488940a5a27ca43f363b294c6c4fade Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 27 Feb 2025 10:36:31 +0100 Subject: [PATCH] port: use target_ command version in all CMake projects --- port/freebsd-netgraph/CMakeLists.txt | 10 +++++----- port/libusb-intel/CMakeLists.txt | 16 ++++++++-------- port/libusb/CMakeLists.txt | 14 +++++++------- port/linux/CMakeLists.txt | 13 +++++-------- port/posix-h4-airoc/CMakeLists.txt | 8 ++++---- port/posix-h4-nxp/CMakeLists.txt | 8 ++++---- port/posix-h4-zephyr/CMakeLists.txt | 8 ++++---- port/posix-h4/CMakeLists.txt | 8 ++++---- port/windows-h4-da14585/CMakeLists.txt | 6 +++--- port/windows-h4-zephyr/CMakeLists.txt | 6 +++--- port/windows-h4/CMakeLists.txt | 6 +++--- port/windows-winusb-intel/CMakeLists.txt | 6 +++--- port/windows-winusb/CMakeLists.txt | 6 +++--- 13 files changed, 56 insertions(+), 59 deletions(-) diff --git a/port/freebsd-netgraph/CMakeLists.txt b/port/freebsd-netgraph/CMakeLists.txt index 67b3fd058..02a200d82 100644 --- a/port/freebsd-netgraph/CMakeLists.txt +++ b/port/freebsd-netgraph/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.18) -project(BTstack-posix-h4) +project(BTstack-FreeBSD-Netgraph) SET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..) @@ -159,16 +159,16 @@ 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() endif() # pthread find_package(Threads) -link_libraries(${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(btstack ${CMAKE_THREAD_LIBS_INIT}) # Add CC256x Support and specify init script # set (CC256X_INIT_SCRIPT bluetooth_init_cc2564C_1.5.c) diff --git a/port/libusb-intel/CMakeLists.txt b/port/libusb-intel/CMakeLists.txt index 5eef08dc5..54aac8e16 100644 --- a/port/libusb-intel/CMakeLists.txt +++ b/port/libusb-intel/CMakeLists.txt @@ -34,7 +34,7 @@ include_directories(../../3rd-party/lc3-google/include) include_directories(../../3rd-party/md5) include_directories(../../3rd-party/hxcmod-player) include_directories(../../3rd-party/hxcmod-player/mod) -include_directories(../../3rdarty/lwip/core/src/include) +include_directories(../../3rd-party/lwip/core/src/include) include_directories(../../3rd-party/lwip/dhcp-server) include_directories(../../3rd-party/rijndael) include_directories(../../3rd-party/yxml) @@ -140,23 +140,23 @@ find_package(PkgConfig REQUIRED) # libusb pkg_check_modules(LIBUSB REQUIRED libusb-1.0) -include_directories(${LIBUSB_INCLUDE_DIRS}) -link_directories(${LIBUSB_LIBRARY_DIRS}) -link_libraries(${LIBUSB_LIBRARIES}) +target_include_directories(btstack PUBLIC ${LIBUSB_INCLUDE_DIRS}) +target_link_directories(btstack PUBLIC ${LIBUSB_LIBRARY_DIRS}) +target_link_libraries(btstack ${LIBUSB_LIBRARIES}) # portaudio 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() # pthread find_package(Threads) -link_libraries(${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(btstack ${CMAKE_THREAD_LIBS_INIT}) # create targets for all examples file(GLOB EXAMPLES_C "../../example/*.c") diff --git a/port/libusb/CMakeLists.txt b/port/libusb/CMakeLists.txt index 623685701..9169dac9e 100644 --- a/port/libusb/CMakeLists.txt +++ b/port/libusb/CMakeLists.txt @@ -143,23 +143,23 @@ find_package(PkgConfig REQUIRED) # libusb pkg_check_modules(LIBUSB REQUIRED libusb-1.0) -include_directories(${LIBUSB_INCLUDE_DIRS}) -link_directories(${LIBUSB_LIBRARY_DIRS}) -link_libraries(${LIBUSB_LIBRARIES}) +target_include_directories(btstack PUBLIC ${LIBUSB_INCLUDE_DIRS}) +target_link_directories(btstack PUBLIC ${LIBUSB_LIBRARY_DIRS}) +target_link_libraries(btstack ${LIBUSB_LIBRARIES}) # portaudio 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() # pthread find_package(Threads) -link_libraries(${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(btstack ${CMAKE_THREAD_LIBS_INIT}) # create targets for all examples file(GLOB EXAMPLES_C "../../example/*.c") diff --git a/port/linux/CMakeLists.txt b/port/linux/CMakeLists.txt index bce7af035..a7f4500df 100644 --- a/port/linux/CMakeLists.txt +++ b/port/linux/CMakeLists.txt @@ -140,9 +140,6 @@ list(SORT SOURCES) # create static lib add_library(btstack STATIC ${SOURCES}) -# Collect libraries for executables -set (BTSTACK_LIBRARIES btstack) - # pkgconfig find_package(PkgConfig) @@ -151,16 +148,16 @@ if (PkgConfig_FOUND) pkg_check_modules(PORTAUDIO portaudio-2.0) if(PORTAUDIO_FOUND) message("HAVE_PORTAUDIO") - include_directories(${PORTAUDIO_INCLUDE_DIRS}) - set(BTSTACK_LIBRARIES ${BTSTACK_LIBRARIES} ${PORTAUDIO_LIBRARIES}) - link_directories(${PORTAUDIO_LIBRARY_DIRS}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() endif() # pthread find_package(Threads) -set(BTSTACK_LIBRARIES ${BTSTACK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} pthread m bluetooth) +target_link_libraries(btstack ${CMAKE_THREAD_LIBS_INIT}) # get list of examples, skipping mesh_node_demo include(../../example/CMakeLists.txt) @@ -187,5 +184,5 @@ foreach(EXAMPLE ${EXAMPLES}) message("example ${EXAMPLE}") endif() add_executable(${EXAMPLE} ${SOURCES_EXAMPLE}) - target_link_libraries(${EXAMPLE} ${BTSTACK_LIBRARIES}) + target_link_libraries(${EXAMPLE} btstack) endforeach(EXAMPLE) diff --git a/port/posix-h4-airoc/CMakeLists.txt b/port/posix-h4-airoc/CMakeLists.txt index dbf6d4e94..dc37a67d9 100644 --- a/port/posix-h4-airoc/CMakeLists.txt +++ b/port/posix-h4-airoc/CMakeLists.txt @@ -137,16 +137,16 @@ 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() endif() # pthread find_package(Threads) -link_libraries(${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(btstack ${CMAKE_THREAD_LIBS_INIT}) # Add BCM Support diff --git a/port/posix-h4-nxp/CMakeLists.txt b/port/posix-h4-nxp/CMakeLists.txt index 8d7fc249e..4b19dd9e9 100644 --- a/port/posix-h4-nxp/CMakeLists.txt +++ b/port/posix-h4-nxp/CMakeLists.txt @@ -137,16 +137,16 @@ 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() endif() # pthread find_package(Threads) -link_libraries(${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(btstack ${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 15fb8c260..721d8375b 100644 --- a/port/posix-h4-zephyr/CMakeLists.txt +++ b/port/posix-h4-zephyr/CMakeLists.txt @@ -83,16 +83,16 @@ 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() endif() # pthread find_package(Threads) -link_libraries(${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(btstack ${CMAKE_THREAD_LIBS_INIT}) # get list of examples include(../../example/CMakeLists.txt) diff --git a/port/posix-h4/CMakeLists.txt b/port/posix-h4/CMakeLists.txt index 938d51115..0a26068c8 100644 --- a/port/posix-h4/CMakeLists.txt +++ b/port/posix-h4/CMakeLists.txt @@ -167,16 +167,16 @@ 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() endif() # pthread find_package(Threads) -link_libraries(${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(btstack ${CMAKE_THREAD_LIBS_INIT}) # Add CC256x Support and specify init script set (CC256X_INIT_SCRIPT bluetooth_init_cc2564C_1.5.c) diff --git a/port/windows-h4-da14585/CMakeLists.txt b/port/windows-h4-da14585/CMakeLists.txt index b99fb4de1..67ab969e5 100644 --- a/port/windows-h4-da14585/CMakeLists.txt +++ b/port/windows-h4-da14585/CMakeLists.txt @@ -77,9 +77,9 @@ 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() endif() diff --git a/port/windows-h4-zephyr/CMakeLists.txt b/port/windows-h4-zephyr/CMakeLists.txt index cf14a8a27..d5979d276 100644 --- a/port/windows-h4-zephyr/CMakeLists.txt +++ b/port/windows-h4-zephyr/CMakeLists.txt @@ -77,9 +77,9 @@ 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() endif() diff --git a/port/windows-h4/CMakeLists.txt b/port/windows-h4/CMakeLists.txt index a8b627318..42ed72cf5 100644 --- a/port/windows-h4/CMakeLists.txt +++ b/port/windows-h4/CMakeLists.txt @@ -160,9 +160,9 @@ 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() endif() diff --git a/port/windows-winusb-intel/CMakeLists.txt b/port/windows-winusb-intel/CMakeLists.txt index be262c37d..b747c69aa 100644 --- a/port/windows-winusb-intel/CMakeLists.txt +++ b/port/windows-winusb-intel/CMakeLists.txt @@ -94,9 +94,9 @@ 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() endif() diff --git a/port/windows-winusb/CMakeLists.txt b/port/windows-winusb/CMakeLists.txt index 3565f3c31..86deea041 100644 --- a/port/windows-winusb/CMakeLists.txt +++ b/port/windows-winusb/CMakeLists.txt @@ -86,9 +86,9 @@ 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}) + target_include_directories(btstack PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) + target_link_directories(btstack PUBLIC ${PORTAUDIO_LIBRARY_DIRS}) + target_link_libraries(btstack ${PORTAUDIO_LIBRARIES}) add_compile_definitions(HAVE_PORTAUDIO) endif() endif()