Skip to content

Commit

Permalink
arm64 support for lopsided98/nix-ros-overlay
Browse files Browse the repository at this point in the history
this patch is based on release/humble/rviz_ogre_vendor/11.2.12-1 to
support rviz2 on darwin-aarch64 for ros2-humble, see details at
lopsided98/nix-ros-overlay#445

allow building arm64

```
@@ -125,7 +125,11 @@ macro(build_ogre)
     set(OGRE_CXX_FLAGS "${OGRE_CXX_FLAGS} /w /EHsc")
   elseif(APPLE)
     set(OGRE_CXX_FLAGS "${OGRE_CXX_FLAGS} -std=c++14 -stdlib=libc++ -w")
-    list(APPEND extra_cmake_args "-DCMAKE_OSX_ARCHITECTURES='x86_64'")
+    if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
+      list(APPEND extra_cmake_args "-DCMAKE_OSX_ARCHITECTURES='arm64'")
+    else()
+      list(APPEND extra_cmake_args "-DCMAKE_OSX_ARCHITECTURES='x86_64'")
+    endif()
   else()  # Linux
     set(OGRE_C_FLAGS "${OGRE_C_FLAGS} -w")
     # include Clang -Wno-everything to disable warnings in that build. GCC doesn't mind it
```

solve `error: Objective-C was disabled in PCH file but is currently enabled`
for Apple Silicon.

`fix-arm64` is merged by upstream since v1.12.9, version bump is in
nix-ros-overlay `override.nix`.

```
@@ -185,10 +188,10 @@ macro(build_ogre)
       -DOGRE_BUILD_COMPONENT_JAVA:BOOL=FALSE
       -DOGRE_BUILD_COMPONENT_CSHARP:BOOL=FALSE
       -DOGRE_BUILD_COMPONENT_BITES:BOOL=FALSE
+      -DOGRE_ENABLE_PRECOMPILED_HEADERS=0
       ${extra_cmake_args}
       -Wno-dev
     PATCH_COMMAND
       ${Patch_EXECUTABLE} -p1 -N < ${CMAKE_CURRENT_SOURCE_DIR}/pragma-patch.diff &&
-      ${Patch_EXECUTABLE} -p1 -N < ${CMAKE_CURRENT_SOURCE_DIR}/fix-arm64.diff &&
       ${Patch_EXECUTABLE} -p1 -N < ${CMAKE_CURRENT_SOURCE_DIR}/relocatable.patch
     COMMAND
```
  • Loading branch information
stevalkr committed Aug 4, 2024
1 parent c6b9246 commit 777d3f4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ macro(build_ogre)
set(OGRE_CXX_FLAGS "${OGRE_CXX_FLAGS} /w /EHsc")
elseif(APPLE)
set(OGRE_CXX_FLAGS "${OGRE_CXX_FLAGS} -std=c++14 -stdlib=libc++ -w")
list(APPEND extra_cmake_args "-DCMAKE_OSX_ARCHITECTURES='x86_64'")
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
list(APPEND extra_cmake_args "-DCMAKE_OSX_ARCHITECTURES='arm64'")
else()
list(APPEND extra_cmake_args "-DCMAKE_OSX_ARCHITECTURES='x86_64'")
endif()
else() # Linux
set(OGRE_C_FLAGS "${OGRE_C_FLAGS} -w")
# include Clang -Wno-everything to disable warnings in that build. GCC doesn't mind it
Expand Down Expand Up @@ -185,11 +189,11 @@ macro(build_ogre)
-DOGRE_BUILD_COMPONENT_JAVA:BOOL=FALSE
-DOGRE_BUILD_COMPONENT_CSHARP:BOOL=FALSE
-DOGRE_BUILD_COMPONENT_BITES:BOOL=FALSE
-DOGRE_ENABLE_PRECOMPILED_HEADERS=0
${extra_cmake_args}
-Wno-dev
PATCH_COMMAND
${Patch_EXECUTABLE} -p1 -N < ${CMAKE_CURRENT_SOURCE_DIR}/pragma-patch.diff &&
${Patch_EXECUTABLE} -p1 -N < ${CMAKE_CURRENT_SOURCE_DIR}/fix-arm64.diff &&
${Patch_EXECUTABLE} -p1 -N < ${CMAKE_CURRENT_SOURCE_DIR}/relocatable.patch
COMMAND
${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/FindFreetype.cmake ${CMAKE_CURRENT_BINARY_DIR}/ogre-v1.12.1-prefix/src/ogre-v1.12.1/CMake/Packages/FindFreetype.cmake
Expand Down

0 comments on commit 777d3f4

Please sign in to comment.