Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build failures on macOS + Apple Silicon #944

Merged
merged 2 commits into from
Mar 13, 2023
Merged
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
8 changes: 6 additions & 2 deletions rviz_ogre_vendor/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 @@ -191,7 +195,7 @@ macro(build_ogre)
${extra_cmake_args}
-Wno-dev
PATCH_COMMAND
${Patch_EXECUTABLE} -p1 -N < ${CMAKE_CURRENT_SOURCE_DIR}/pragma-patch.diff &&
${Patch_EXECUTABLE} -p1 -N -l < ${CMAKE_CURRENT_SOURCE_DIR}/pragma-patch.diff &&
${Patch_EXECUTABLE} -p1 -N < ${CMAKE_CURRENT_SOURCE_DIR}/relocatable.patch &&
${Patch_EXECUTABLE} -p1 -N < ${CMAKE_CURRENT_SOURCE_DIR}/C4267.patch
COMMAND
Expand Down
22 changes: 19 additions & 3 deletions rviz_ogre_vendor/pragma-patch.diff
Original file line number Diff line number Diff line change
Expand Up @@ -1814,14 +1814,14 @@ diff --git a/PlugIns/OctreeZone/CMakeLists.txt b/PlugIns/OctreeZone/CMakeLists.t
@@ -23,6 +23,11 @@ generate_export_header(Plugin_OctreeZone
EXPORT_MACRO_NAME _OgreOctreeZonePluginExport
EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/OgreOctreeZonePrerequisites.h)

+if (UNIX)
+ set_property(TARGET Plugin_OctreeZone APPEND PROPERTY
+ INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${OGRE_LIB_DIRECTORY}/OGRE)
+endif ()
+
ogre_config_framework(Plugin_OctreeZone)

ogre_config_plugin(Plugin_OctreeZone)
diff --git a/OgreMain/include/OgreTimer.h b/OgreMain/include/OgreTimer.h
--- a/OgreMain/include/OgreTimer.h 2019-06-24 16:04:20.000000000 -0700
Expand All @@ -1845,4 +1845,20 @@ diff --git a/OgreMain/include/OgreTimer.h b/OgreMain/include/OgreTimer.h
+#pragma warning(pop)
+#endif
#endif

diff --git a/CMake/Utils/PrecompiledHeader.cmake b/CMake/Utils/PrecompiledHeader.cmake
index bfb0059..62b4f6d 100644
--- a/CMake/Utils/PrecompiledHeader.cmake
+++ b/CMake/Utils/PrecompiledHeader.cmake
@@ -340,7 +340,11 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _input)
if(NOT OGRE_ENABLE_PRECOMPILED_HEADERS)
# do nothing
elseif(CMAKE_VERSION GREATER_EQUAL "3.16")
- target_precompile_headers(${_targetName} PRIVATE ${_input})
+ if(APPLE)
+ add_compile_options((-Xclang -include -Xclang ${_input}))
+ else()
+ target_precompile_headers(${_targetName} PRIVATE ${_input})
+ endif()
elseif(CMAKE_GENERATOR MATCHES "^Visual.*$")

# Auto include the precompile (useful for moc processing, since the use of