Update macos
- Add TODO for missing options - Fix formatting - Set GODOT_ARCH in case of arch being 'universal' - Simplify the test project when SYSTEM_NAME is Darwin
parent
c485dafbbd
commit
a22f19fb0d
|
@ -7,22 +7,23 @@ MacOS platform
|
|||
|
||||
]=======================================================================]
|
||||
|
||||
# Find Requirements
|
||||
IF(APPLE)
|
||||
# APPLE is set to True when the target system is an Apple platform
|
||||
# (macOS, iOS, tvOS, visionOS or watchOS).
|
||||
if( APPLE )
|
||||
set( CMAKE_OSX_SYSROOT $ENV{SDKROOT} )
|
||||
find_library( COCOA_LIBRARY REQUIRED
|
||||
NAMES Cocoa
|
||||
PATHS ${CMAKE_OSX_SYSROOT}/System/Library
|
||||
PATH_SUFFIXES Frameworks
|
||||
NO_DEFAULT_PATH)
|
||||
ENDIF (APPLE)
|
||||
|
||||
NO_DEFAULT_PATH )
|
||||
endif( APPLE )
|
||||
|
||||
function( macos_options )
|
||||
# macos options here
|
||||
# TODO "macos_deployment_target" "macOS deployment target" "default"
|
||||
# TODO "macos_sdk_path" "macOS SDK path" ""
|
||||
# TODO if has_osxcross(): "osxcross_sdk" "OSXCross SDK version" "darwin16"
|
||||
endfunction()
|
||||
|
||||
|
||||
function( macos_generate )
|
||||
|
||||
# OSX_ARCHITECTURES does not support generator expressions.
|
||||
|
@ -36,7 +37,9 @@ function( macos_generate )
|
|||
set_target_properties( ${TARGET_NAME}
|
||||
PROPERTIES
|
||||
|
||||
# Specify multiple architectures for universal builds
|
||||
OSX_ARCHITECTURES "${OSX_ARCH}"
|
||||
GODOT_ARCH ${SYSTEM_ARCH}
|
||||
)
|
||||
|
||||
target_compile_definitions(${TARGET_NAME}
|
||||
|
|
|
@ -20,6 +20,22 @@ foreach( TARGET_ALIAS template_debug template_release editor )
|
|||
set( TARGET_NAME "godot-cpp.test.${TARGET_ALIAS}" )
|
||||
set( LINK_TARGET "godot-cpp::${TARGET_ALIAS}" )
|
||||
|
||||
### Get useful properties of the library
|
||||
get_target_property( GODOT_PLATFORM ${LINK_TARGET} GODOT_PLATFORM )
|
||||
get_target_property( GODOT_TARGET ${LINK_TARGET} GODOT_TARGET )
|
||||
get_target_property( GODOT_ARCH ${LINK_TARGET} GODOT_ARCH )
|
||||
get_target_property( OSX_ARCH ${LINK_TARGET} OSX_ARCHITECTURES )
|
||||
|
||||
set( DEV_TAG "$<$<BOOL:${GODOT_DEV_BUILD}>:.dev>" )
|
||||
|
||||
if( CMAKE_SYSTEM_NAME STREQUAL Darwin )
|
||||
set( OUTPUT_DIR "${OUTPUT_DIR}/libgdexample.macos.${TEST_TARGET}.framework")
|
||||
set( OUTPUT_NAME "gdexample.macos.${TEST_TARGET}${DEV_TAG}" )
|
||||
else()
|
||||
set( OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/project/bin/" )
|
||||
set( OUTPUT_NAME "gdexample.${GODOT_PLATFORM}.${GODOT_TARGET}${DEV_TAG}.${GODOT_ARCH}" )
|
||||
endif()
|
||||
|
||||
add_library( ${TARGET_NAME} SHARED EXCLUDE_FROM_ALL )
|
||||
|
||||
target_sources( ${TARGET_NAME}
|
||||
|
@ -38,14 +54,6 @@ foreach( TARGET_ALIAS template_debug template_release editor )
|
|||
|
||||
target_link_libraries( ${TARGET_NAME} PRIVATE ${LINK_TARGET} )
|
||||
|
||||
### Get useful properties of the library
|
||||
get_target_property( GODOT_PLATFORM ${LINK_TARGET} GODOT_PLATFORM )
|
||||
get_target_property( GODOT_TARGET ${LINK_TARGET} GODOT_TARGET )
|
||||
get_target_property( GODOT_ARCH ${LINK_TARGET} GODOT_ARCH )
|
||||
|
||||
set( OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/project/bin/" )
|
||||
set( DEV_TAG "$<$<BOOL:${GODOT_DEV_BUILD}>:.dev>" )
|
||||
|
||||
set_target_properties( ${TARGET_NAME}
|
||||
PROPERTIES
|
||||
CXX_STANDARD 17
|
||||
|
@ -68,27 +76,20 @@ foreach( TARGET_ALIAS template_debug template_release editor )
|
|||
PREFIX "lib"
|
||||
OUTPUT_NAME "gdexample.${GODOT_PLATFORM}.${GODOT_TARGET}${DEV_TAG}.${GODOT_ARCH}"
|
||||
|
||||
#macos options, ignored on other platforms
|
||||
OSX_ARCHITECTURES "${OSX_ARCH}"
|
||||
|
||||
# enable RPATH on MACOS, with the BUILD_RPATH_USE_ORIGIN
|
||||
# this should allow loading libraries from relative paths on macos.
|
||||
MACOSX_RPATH ON
|
||||
|
||||
# Some IDE's respect this property to logically group targets
|
||||
FOLDER "godot-cpp"
|
||||
)
|
||||
|
||||
# CMAKE_SYSTEM_NAME refers to the target system
|
||||
# Only blank the suffix on osx to match SCons
|
||||
if( CMAKE_SYSTEM_NAME STREQUAL Darwin )
|
||||
get_target_property( OSX_ARCH ${LINK_TARGET} OSX_ARCHITECTURES )
|
||||
|
||||
set( OUTPUT_DIR "${OUTPUT_DIR}/libgdexample.macos.${TEST_TARGET}.framework")
|
||||
|
||||
set_target_properties( ${TARGET_NAME}
|
||||
PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "$<1:${OUTPUT_DIR}>"
|
||||
RUNTIME_OUTPUT_DIRECTORY "$<1:${OUTPUT_DIR}>"
|
||||
|
||||
OUTPUT_NAME "gdexample.macos.${TARGET_ALIAS}${DEV_TAG}"
|
||||
SUFFIX ""
|
||||
|
||||
#macos options
|
||||
OSX_ARCHITECTURES "${OSX_ARCH}"
|
||||
)
|
||||
set_target_properties( ${TARGET_NAME} PROPERTIES SUFFIX "" )
|
||||
endif ()
|
||||
|
||||
endforeach()
|
||||
|
|
Loading…
Reference in New Issue