AimRT/cmake/GetLibUnifex.cmake

45 lines
1.0 KiB
CMake
Raw Normal View History

2024-09-23 16:01:31 +08:00
# Copyright (c) 2023, AgiBot Inc.
# All rights reserved.
include(FetchContent)
message(STATUS "get libunifex ...")
set(libunifex_DOWNLOAD_URL
"https://github.com/facebookexperimental/libunifex/archive/591ec09e7d51858ad05be979d4034574215f5971.tar.gz"
CACHE STRING "")
if(libunifex_LOCAL_SOURCE)
FetchContent_Declare(
libunifex
SOURCE_DIR ${libunifex_LOCAL_SOURCE}
OVERRIDE_FIND_PACKAGE)
else()
FetchContent_Declare(
libunifex
URL ${libunifex_DOWNLOAD_URL}
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
OVERRIDE_FIND_PACKAGE)
endif()
# Wrap it in a function to restrict the scope of the variables
function(get_libunifex)
FetchContent_GetProperties(libunifex)
if(NOT libunifex_POPULATED)
set(UNIFEX_BUILD_EXAMPLES OFF)
2024-09-23 16:01:31 +08:00
FetchContent_MakeAvailable(libunifex)
2024-09-23 16:01:31 +08:00
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(unifex PRIVATE -Wno-unused-but-set-variable)
endif()
add_library(unifex::unifex ALIAS unifex)
2024-09-23 16:01:31 +08:00
endif()
endfunction()
2024-09-23 16:01:31 +08:00
get_libunifex()
2024-09-23 16:01:31 +08:00
# import targets:
# unifex::unifex