Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmake/DetermineTargetArch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function(determine_target_arch OUTPUT_VARIABLE)
else()
message(FATAL_ERROR "Unrecognized architecture ${MSVC_C_ARCHITECTURE_ID} from ${CMAKE_C_COMPILER}")
endif()
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMD_ARGS "-target" "${CMAKE_C_COMPILER_TARGET}" "-dumpmachine")
else()
Expand All @@ -36,6 +36,8 @@ function(determine_target_arch OUTPUT_VARIABLE)

if("${ARCH}" STREQUAL "x86_64")
# Do nothing
elseif("${ARCH}" STREQUAL "arm64")
# Do nothing
elseif("${ARCH}" STREQUAL "aarch64")
set(ARCH "arm64")
elseif("${ARCH}" STREQUAL "i686")
Expand Down
2 changes: 1 addition & 1 deletion cmake/k4aCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (NOT ("${CMAKE_C_COMPILER_ID}" STREQUAL "${CMAKE_CXX_COMPILER_ID}"))
message(FATAL_ERROR "C compiler (${CMAKE_C_COMPILER_ID}) does not match C++ compiler (${CMAKE_CXX_COMPILER_ID})")
endif()

if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
set(CLANG_ALL_WARNINGS "-Weverything")
list(APPEND CLANG_ALL_WARNINGS "-Wno-missing-field-initializers") # Allow c structs without all fields initialized
list(APPEND CLANG_ALL_WARNINGS "-Wno-reserved-id-macro") # Needed for azure-c-shared-utility which defines new macros that start with "_"
Expand Down
2 changes: 1 addition & 1 deletion extern/libsoundio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
endif()

add_library(libsoundio::libsoundio ALIAS libsoundio_static)
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
find_library(LIBSOUNDIO_LIB soundio)
add_library(libsoundio::libsoundio SHARED IMPORTED GLOBAL)
set_property(TARGET libsoundio::libsoundio PROPERTY IMPORTED_LOCATION ${LIBSOUNDIO_LIB})
Expand Down
62 changes: 38 additions & 24 deletions extern/libusb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,61 @@
add_library(LibUSB
STATIC
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
add_library(LibUSB INTERFACE IMPORTED GLOBAL)
target_include_directories(LibUSB INTERFACE "/opt/homebrew/include/libusb-1.0")
target_link_libraries(LibUSB INTERFACE "/opt/homebrew/lib/libusb-1.0.dylib")
add_library(LibUSB::LibUSB ALIAS LibUSB)

else()
add_library(
LibUSB STATIC
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/core.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/descriptor.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/hotplug.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/io.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/strerror.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/sync.c")

target_include_directories(LibUSB PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/libusb)
target_include_directories(LibUSB PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os)
target_include_directories(LibUSB
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/libusb)
target_include_directories(LibUSB
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os)

add_library(LibUSB::LibUSB ALIAS LibUSB)
add_library(LibUSB::LibUSB ALIAS LibUSB)

if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(LibUSB PUBLIC "-Wno-zero-length-array")
endif()
endif()

if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
target_sources(
LibUSB
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/poll_windows.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/threads_windows.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/windows_nt_common.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/windows_usbdk.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/windows_winusb.c")

if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
target_sources(LibUSB PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/poll_windows.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/threads_windows.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/windows_nt_common.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/windows_usbdk.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/windows_winusb.c")
target_include_directories(LibUSB
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/msvc)

target_include_directories(LibUSB PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/msvc)

target_compile_definitions(LibUSB PRIVATE "_LIB" "_CRT_SECURE_NO_WARNINGS" "WINVER=0x0501" "_WIN32_WINNT=0x0501")
target_compile_definitions(
LibUSB PRIVATE "_LIB" "_CRT_SECURE_NO_WARNINGS" "WINVER=0x0501"
"_WIN32_WINNT=0x0501")

target_compile_options(LibUSB PRIVATE "/source-charset:utf-8")

elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
target_sources(LibUSB PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/poll_posix.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/threads_posix.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/linux_usbfs.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/linux_udev.c")
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
target_sources(
LibUSB
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/poll_posix.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/threads_posix.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/linux_usbfs.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libusb/os/linux_udev.c")

target_include_directories(LibUSB PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/)

target_link_libraries(LibUSB PUBLIC "udev")

else()
else()
message(FATAL_ERROR "Unknown CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
endif()
endif()
2 changes: 1 addition & 1 deletion src/dynlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(DYNLIB_SRCS dynlib_windows.c)
set(DYNLIB_DEPENDENCIES
pathcch.lib)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(DYNLIB_SRCS dynlib_linux.c)
else()
message(FATAL_ERROR "Unknown system: ${CMAKE_SYSTEM_NAME}")
Expand Down
2 changes: 1 addition & 1 deletion src/rwlock/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
add_library(k4a_rwlock STATIC
rwlock_linux.c
)
Expand Down