Skip to content

Commit

Permalink
[macOS] Backport fixes to fix build errors
Browse files Browse the repository at this point in the history
Fix MorphAnimation sample on macOS
  • Loading branch information
darksylinc committed Dec 13, 2021
1 parent 6c231c1 commit 0c476f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 72 deletions.
27 changes: 8 additions & 19 deletions OgreMain/src/OgrePlatformInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,18 @@ THE SOFTWARE.
#elif (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && OGRE_PLATFORM != OGRE_PLATFORM_NACL
#include <signal.h>
#include <setjmp.h>
#if OGRE_PLATFORM != OGRE_PLATFORM_WIN32
#if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
#include <linux/sysctl.h>
#endif
#endif

#if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
#include <cpu-features.h>
#elif OGRE_CPU == OGRE_CPU_ARM
#if __MACH__
#include <mach/machine.h>
#ifndef CPU_SUBTYPE_ARM64_V8
#define CPU_SUBTYPE_ARM64_V8 ((cpu_subtype_t) 1)
#endif
#ifndef CPU_SUBTYPE_ARM_V8
#define CPU_SUBTYPE_ARM_V8 ((cpu_subtype_t) 13)
#endif
#endif
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
#include <linux/sysctl.h>
#include <cpu-features.h>
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
#include <sys/sysctl.h>
#include <mach/machine.h>
#endif

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT
#include "windows.h"
#include <windows.h>
#endif

// Yes, I know, this file looks very ugly, but there aren't other ways to do it better.
Expand Down
58 changes: 5 additions & 53 deletions Samples/2.0/ApiUsage/MorphAnimations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,60 +18,12 @@ ogre_add_component_include_dir(Hlms/Pbs)

add_recursive( ./ SOURCE_FILES )

set(SAMPLE_NAME Sample_MorphAnimations)
ogre_add_executable(${SAMPLE_NAME} WIN32 MACOSX_BUNDLE ${SOURCE_FILES} ${SAMPLE_COMMON_RESOURCES})
ogre_add_executable(Sample_MorphAnimations WIN32 MACOSX_BUNDLE ${SOURCE_FILES} ${SAMPLE_COMMON_RESOURCES})

target_link_libraries(${SAMPLE_NAME} ${OGRE_LIBRARIES} ${OGRE_SAMPLES_LIBRARIES})
ogre_config_sample_lib(${SAMPLE_NAME})
target_link_libraries(Sample_MorphAnimations ${OGRE_LIBRARIES} ${OGRE_SAMPLES_LIBRARIES})
ogre_config_sample_lib(Sample_MorphAnimations)

if( APPLE )
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.ogre3d.${SAMPLE_NAME}")
set(MACOSX_BUNDLE_BUNDLE_NAME "${SAMPLE_NAME}")
set(MACOSX_BUNDLE_EXECUTABLE "${SAMPLE_NAME}")
set_target_properties(${SAMPLE_NAME} PROPERTIES RESOURCE "${TUTORIAL_RESOURCES}")
set_target_properties(${SAMPLE_NAME} PROPERTIES RESOURCE "${SAMPLE_COMMON_RESOURCES}" )
set_target_properties(${SAMPLE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${SAMPLES_PLIST})


if( CMAKE_GENERATOR STREQUAL "Xcode" )
#if (IOS)
# set(APP_CONTENTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin/$(CONFIGURATION)/${SAMPLE_NAME}.app)
#else ()
set(APP_CONTENTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../../../bin/$(CONFIGURATION)/${SAMPLE_NAME}.app/Contents)
#endif ()
else ()
#if (IOS)
# set(APP_CONTENTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin/${SAMPLE_NAME}.app)
#else ()
set(APP_CONTENTS_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../../../bin/${SAMPLE_NAME}.app/Contents)
#endif ()
endif ()

if( NOT OGRE_BUILD_PLATFORM_APPLE_IOS )
set(FRAMEWORKS
Ogre
RenderSystem_GL3PLUS
RenderSystem_Metal
OgreHlmsPbs
OgreHlmsUnlit
OgreOverlay
Plugin_ParticleFX
)

foreach(FWK ${FRAMEWORKS})
add_custom_command(TARGET ${SAMPLE_NAME} POST_BUILD
COMMAND ditto ${CMAKE_CURRENT_BINARY_DIR}/../../../../lib/macosx/${FWK}.framework ${APP_CONTENTS_PATH}/Frameworks/${FWK}.framework
)
endforeach(FWK)

add_custom_command(TARGET ${SAMPLE_NAME} POST_BUILD
COMMAND mkdir -p ${APP_CONTENTS_PATH}/Resources
)

foreach(RSC ${SAMPLE_COMMON_RESOURCES})
add_custom_command(TARGET ${SAMPLE_NAME} POST_BUILD
COMMAND cp -r ${RSC} ${APP_CONTENTS_PATH}/Resources/
)
endforeach()
endif()
set_target_properties( Sample_MorphAnimations PROPERTIES RESOURCE "${SAMPLE_COMMON_RESOURCES}" )
set_target_properties( Sample_MorphAnimations PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${SAMPLES_PLIST} )
endif()

0 comments on commit 0c476f3

Please sign in to comment.