mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[cmake] update CMake configurations for Apple platforms (#12729)
This commit updates various CMake configuration files to simplify the check for Apple platforms. It replaces the `CMAKE_CXX_COMPILER_ID` check for `AppleClang` with the built-in `APPLE` variable across multiple targets (such as `ftd`, `mtd`, `cli`, and others). This ensures that Apple-specific linker and compiler flags (like `-Wl,-map` and `-Wimplicit-int-conversion`) are correctly applied when building on macOS, regardless of the specific compiler used. Additionally, this commit updates `CMakeLists.txt` to explicitly set the `CMAKE_AR` and `CMAKE_RANLIB` paths to the default system locations (`/usr/bin/ar` and `/usr/bin/ranlib`) when the `APPLE` variable is set.
This commit is contained in:
committed by
GitHub
parent
da7a103401
commit
fb216d335c
@@ -49,6 +49,11 @@ set(CMAKE_CXX_STANDARD 11)
|
|||||||
set(CMAKE_C_EXTENSIONS OFF)
|
set(CMAKE_C_EXTENSIONS OFF)
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
set(CMAKE_AR "/usr/bin/ar")
|
||||||
|
set(CMAKE_RANLIB "/usr/bin/ranlib")
|
||||||
|
endif()
|
||||||
|
|
||||||
message(STATUS "OpenThread Source Directory: ${PROJECT_SOURCE_DIR}")
|
message(STATUS "OpenThread Source Directory: ${PROJECT_SOURCE_DIR}")
|
||||||
|
|
||||||
target_include_directories(ot-config INTERFACE
|
target_include_directories(ot-config INTERFACE
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ target_link_libraries(ot-cli-ftd PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
if(OT_LINKER_MAP)
|
if(OT_LINKER_MAP)
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_link_libraries(ot-cli-ftd PRIVATE -Wl,-map,ot-cli-ftd.map)
|
target_link_libraries(ot-cli-ftd PRIVATE -Wl,-map,ot-cli-ftd.map)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(ot-cli-ftd PRIVATE -Wl,-Map=ot-cli-ftd.map)
|
target_link_libraries(ot-cli-ftd PRIVATE -Wl,-Map=ot-cli-ftd.map)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ target_link_libraries(ot-cli-mtd PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
if(OT_LINKER_MAP)
|
if(OT_LINKER_MAP)
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_link_libraries(ot-cli-mtd PRIVATE -Wl,-map,ot-cli-mtd.map)
|
target_link_libraries(ot-cli-mtd PRIVATE -Wl,-map,ot-cli-mtd.map)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(ot-cli-mtd PRIVATE -Wl,-Map=ot-cli-mtd.map)
|
target_link_libraries(ot-cli-mtd PRIVATE -Wl,-Map=ot-cli-mtd.map)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ target_link_libraries(ot-cli-radio PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
if(OT_LINKER_MAP)
|
if(OT_LINKER_MAP)
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_link_libraries(ot-cli-radio PRIVATE -Wl,-map,ot-cli-radio.map)
|
target_link_libraries(ot-cli-radio PRIVATE -Wl,-map,ot-cli-radio.map)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(ot-cli-radio PRIVATE -Wl,-Map=ot-cli-radio.map)
|
target_link_libraries(ot-cli-radio PRIVATE -Wl,-Map=ot-cli-radio.map)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ target_link_libraries(ot-ncp-ftd PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
if(OT_LINKER_MAP)
|
if(OT_LINKER_MAP)
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_link_libraries(ot-ncp-ftd PRIVATE -Wl,-map,ot-ncp-ftd.map)
|
target_link_libraries(ot-ncp-ftd PRIVATE -Wl,-map,ot-ncp-ftd.map)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(ot-ncp-ftd PRIVATE -Wl,-Map=ot-ncp-ftd.map)
|
target_link_libraries(ot-ncp-ftd PRIVATE -Wl,-Map=ot-ncp-ftd.map)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ target_link_libraries(ot-ncp-mtd PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
if(OT_LINKER_MAP)
|
if(OT_LINKER_MAP)
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_link_libraries(ot-ncp-mtd PRIVATE -Wl,-map,ot-ncp-mtd.map)
|
target_link_libraries(ot-ncp-mtd PRIVATE -Wl,-map,ot-ncp-mtd.map)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(ot-ncp-mtd PRIVATE -Wl,-Map=ot-ncp-mtd.map)
|
target_link_libraries(ot-ncp-mtd PRIVATE -Wl,-Map=ot-ncp-mtd.map)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ target_link_libraries(ot-rcp PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
if(OT_LINKER_MAP)
|
if(OT_LINKER_MAP)
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_link_libraries(ot-rcp PRIVATE -Wl,-map,ot-rcp.map)
|
target_link_libraries(ot-rcp PRIVATE -Wl,-map,ot-rcp.map)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(ot-rcp PRIVATE -Wl,-Map=ot-rcp.map)
|
target_link_libraries(ot-rcp PRIVATE -Wl,-Map=ot-rcp.map)
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ target_compile_options(openthread-ftd PRIVATE
|
|||||||
-Wundef
|
-Wundef
|
||||||
)
|
)
|
||||||
|
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_compile_options(openthread-ftd PRIVATE -Wimplicit-int-conversion)
|
target_compile_options(openthread-ftd PRIVATE -Wimplicit-int-conversion)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ target_compile_options(openthread-mtd PRIVATE
|
|||||||
-Wundef
|
-Wundef
|
||||||
)
|
)
|
||||||
|
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_compile_options(openthread-mtd PRIVATE -Wimplicit-int-conversion)
|
target_compile_options(openthread-mtd PRIVATE -Wimplicit-int-conversion)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ target_compile_options(openthread-radio PRIVATE
|
|||||||
-Wundef
|
-Wundef
|
||||||
)
|
)
|
||||||
|
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_compile_options(openthread-radio PRIVATE -Wimplicit-int-conversion)
|
target_compile_options(openthread-radio PRIVATE -Wimplicit-int-conversion)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ target_link_libraries(ot-cli PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
if(OT_LINKER_MAP)
|
if(OT_LINKER_MAP)
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_link_libraries(ot-cli PRIVATE -Wl,-map,ot-cli.map)
|
target_link_libraries(ot-cli PRIVATE -Wl,-map,ot-cli.map)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(ot-cli PRIVATE -Wl,-Map=ot-cli.map)
|
target_link_libraries(ot-cli PRIVATE -Wl,-Map=ot-cli.map)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ target_link_libraries(ot-daemon PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
if(OT_LINKER_MAP)
|
if(OT_LINKER_MAP)
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_link_libraries(ot-daemon PRIVATE -Wl,-map,ot-daemon.map)
|
target_link_libraries(ot-daemon PRIVATE -Wl,-map,ot-daemon.map)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(ot-daemon PRIVATE -Wl,-Map=ot-daemon.map)
|
target_link_libraries(ot-daemon PRIVATE -Wl,-Map=ot-daemon.map)
|
||||||
@@ -78,7 +78,7 @@ target_link_libraries(ot-ctl PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
if(OT_LINKER_MAP)
|
if(OT_LINKER_MAP)
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
|
if(APPLE)
|
||||||
target_link_libraries(ot-ctl PRIVATE -Wl,-map,ot-ctl.map)
|
target_link_libraries(ot-ctl PRIVATE -Wl,-map,ot-ctl.map)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(ot-ctl PRIVATE -Wl,-Map=ot-ctl.map)
|
target_link_libraries(ot-ctl PRIVATE -Wl,-Map=ot-ctl.map)
|
||||||
|
|||||||
Reference in New Issue
Block a user