AimRT/cmake/GetIceoryx.cmake
zhangyi1357 0a63cb9fe1
build: refactor CMake scripts to use functions for variable scope (#87)
* build: refactor CMake scripts to use functions for variable scope

Wrap multiple CMake scripts in functions to restrict variable scope and prevent unintended resets. This ensures better modularity and maintainability in the build process while adhering to modern CMake best practices.

* refactor: simplify opentelemetry fetch logic

Streamline the handling of OpenTelemetry dependencies by removing unnecessary function wrappers and directly implementing the fetching logic. This improves readability and maintainability while ensuring that relevant variables are correctly set within the proper scope.

* refactor: encapsulate OpenTelemetry configuration in a function

Wrap the OpenTelemetry setup in a function to limit variable scope, improving code organization and maintainability.
2024-11-07 21:17:34 +08:00

42 lines
913 B
CMake
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Copyright (c) 2023, AgiBot Inc.
# All rights reserved.
include(FetchContent)
message(STATUS "get iceoryx...")
# fetch iceoryx
set(iceoryx_DOWNLOAD_URL
"https://github.com/eclipse-iceoryx/iceoryx/archive/refs/tags/v2.0.6.tar.gz"
CACHE STRING "")
set(DOWNLOAD_TOML_LIB OFF)
if(iceoryx_LOCAL_SOURCE)
FetchContent_Declare(
iceoryx
SOURCE_DIR ${iceoryx_LOCAL_SOURCE}
OVERRIDE_FIND_PACKAGE)
else()
FetchContent_Declare(
iceoryx
URL ${iceoryx_DOWNLOAD_URL}
DOWNLOAD_EXTRACT_TIMESTAMP ON
OVERRIDE_FIND_PACKAGE)
endif()
# Wrap it in a function to restrict the scope of the variables
function(get_iceoryx)
FetchContent_GetProperties(iceoryx)
if(NOT iceoryx_POPULATED)
FetchContent_Populate(iceoryx)
# iceoryxs cmake file in ./iceoryx_meta
add_subdirectory(${iceoryx_SOURCE_DIR}/iceoryx_meta ${iceoryx_BINARY_DIR})
endif()
endfunction()
get_iceoryx()