@ -18,7 +18,7 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_L
string ( JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${ project_json } engine )
string ( JSON LY_ENGINE_NAME_TO_USE ERROR_VARIABLE json_error GET ${ project_json } engine )
if ( json_error )
if ( json_error )
message ( FATAL_ERROR "Unable to read key 'engine' from 'project.json' , e rror: ${json_error}")
message ( FATAL_ERROR "Unable to read key 'engine' from 'project.json' \nE rror: ${json_error}")
endif ( )
endif ( )
if ( CMAKE_MODULE_PATH )
if ( CMAKE_MODULE_PATH )
@ -27,7 +27,7 @@ if(CMAKE_MODULE_PATH)
file ( READ ${ module_path } /../engine.json engine_json )
file ( READ ${ module_path } /../engine.json engine_json )
string ( JSON engine_name ERROR_VARIABLE json_error GET ${ engine_json } engine_name )
string ( JSON engine_name ERROR_VARIABLE json_error GET ${ engine_json } engine_name )
if ( json_error )
if ( json_error )
message ( FATAL_ERROR "Unable to read key 'engine_name' from 'engine.json' , e rror: ${json_error}")
message ( FATAL_ERROR "Unable to read key 'engine_name' from 'engine.json' \nE rror: ${json_error}")
endif ( )
endif ( )
if ( LY_ENGINE_NAME_TO_USE STREQUAL engine_name )
if ( LY_ENGINE_NAME_TO_USE STREQUAL engine_name )
return ( ) # E n g i n e b e i n g f o r c e d t h r o u g h C M A K E _ M O D U L E _ P A T H
return ( ) # E n g i n e b e i n g f o r c e d t h r o u g h C M A K E _ M O D U L E _ P A T H
@ -42,6 +42,11 @@ else()
set ( manifest_path $ENV{ HOME } /.o3de/o3de_manifest.json ) # U n i x
set ( manifest_path $ENV{ HOME } /.o3de/o3de_manifest.json ) # U n i x
endif ( )
endif ( )
set ( registration_error [=[
E n g i n e r e g i s t r a t i o n i s r e q u i r e d b e f o r e c o n f i g u r i n g a p r o j e c t .
R u n ' s c r i p t s / o 3 d e r e g i s t e r - - t h i s - e n g i n e ' f r o m t h e e n g i n e r o o t .
] = ] )
# R e a d t h e ~ / . o 3 d e / o 3 d e _ m a n i f e s t . j s o n f i l e a n d l o o k t h r o u g h t h e ' e n g i n e s _ p a t h ' o b j e c t .
# R e a d t h e ~ / . o 3 d e / o 3 d e _ m a n i f e s t . j s o n f i l e a n d l o o k t h r o u g h t h e ' e n g i n e s _ p a t h ' o b j e c t .
# F i n d a k e y t h a t m a t c h e s L Y _ E N G I N E _ N A M E _ T O _ U S E a n d u s e t h a t a s t h e e n g i n e p a t h .
# F i n d a k e y t h a t m a t c h e s L Y _ E N G I N E _ N A M E _ T O _ U S E a n d u s e t h a t a s t h e e n g i n e p a t h .
if ( EXISTS ${ manifest_path } )
if ( EXISTS ${ manifest_path } )
@ -50,36 +55,38 @@ if(EXISTS ${manifest_path})
string ( JSON engines_path_count ERROR_VARIABLE json_error LENGTH ${ manifest_json } engines_path )
string ( JSON engines_path_count ERROR_VARIABLE json_error LENGTH ${ manifest_json } engines_path )
if ( json_error )
if ( json_error )
message ( FATAL_ERROR "Unable to read key 'engines_path' from '${manifest_path}' , error: ${js on_error}")
message ( FATAL_ERROR "Unable to read key 'engines_path' from '${manifest_path}' \nError: ${json_error}\n${registrati on_error}")
endif ( )
endif ( )
string ( JSON engines_path_type ERROR_VARIABLE json_error TYPE ${ manifest_json } engines_path )
string ( JSON engines_path_type ERROR_VARIABLE json_error TYPE ${ manifest_json } engines_path )
if ( json_error OR NOT ${ engines_path_type } STREQUAL "OBJECT" )
if ( json_error OR NOT ${ engines_path_type } STREQUAL "OBJECT" )
message ( FATAL_ERROR "Type of 'engines_path' in '${manifest_path}' is not a JSON Object , e rror: ${json_error}")
message ( FATAL_ERROR "Type of 'engines_path' in '${manifest_path}' is not a JSON Object \nE rror: ${json_error}")
endif ( )
endif ( )
math ( EXPR engines_path_count "${engines_path_count}-1" )
math ( EXPR engines_path_count "${engines_path_count}-1" )
foreach ( engine_path_index RANGE ${ engines_path_count } )
foreach ( engine_path_index RANGE ${ engines_path_count } )
string ( JSON engine_name ERROR_VARIABLE json_error MEMBER ${ manifest_json } engines_path ${ engine_path_index } )
string ( JSON engine_name ERROR_VARIABLE json_error MEMBER ${ manifest_json } engines_path ${ engine_path_index } )
if ( json_error )
if ( json_error )
message ( FATAL_ERROR "Unable to read 'engines_path/${engine_path_index}' from '${manifest_path}' , e rror: ${json_error}")
message ( FATAL_ERROR "Unable to read 'engines_path/${engine_path_index}' from '${manifest_path}' \nE rror: ${json_error}")
endif ( )
endif ( )
if ( LY_ENGINE_NAME_TO_USE STREQUAL engine_name )
if ( LY_ENGINE_NAME_TO_USE STREQUAL engine_name )
string ( JSON engine_path ERROR_VARIABLE json_error GET ${ manifest_json } engines_path ${ engine_name } )
string ( JSON engine_path ERROR_VARIABLE json_error GET ${ manifest_json } engines_path ${ engine_name } )
if ( json_error )
if ( json_error )
message ( FATAL_ERROR "Unable to read value from 'engines_path/${engine_name}' , e rror: ${json_error}")
message ( FATAL_ERROR "Unable to read value from 'engines_path/${engine_name}' \nE rror: ${json_error}")
endif ( )
endif ( )
if ( engine_path )
if ( engine_path )
list ( APPEND CMAKE_MODULE_PATH "${engine_path}/cmake" )
list ( APPEND CMAKE_MODULE_PATH "${engine_path}/cmake" )
break ( )
return ( )
endif ( )
endif ( )
endif ( )
endif ( )
endforeach ( )
endforeach ( )
message ( FATAL_ERROR "The project.json uses engine name '${LY_ENGINE_NAME_TO_USE}' but no engine with that name has been registered.\n${registration_error}" )
else ( )
else ( )
# I f t h e u s e r i s p a s s i n g C M A K E _ M O D U L E _ P A T H w e a s s u m e t h a t s w h e r e w e w i l l f i n d t h e e n g i n e
# I f t h e u s e r i s p a s s i n g C M A K E _ M O D U L E _ P A T H w e a s s u m e t h a t s w h e r e w e w i l l f i n d t h e e n g i n e
if ( NOT CMAKE_MODULE_PATH )
if ( NOT CMAKE_MODULE_PATH )
message ( FATAL_ERROR " Engine registration is required before configuring a project. Please register an engine by running 'scripts/o3de register --this-engine' ")
message ( FATAL_ERROR " O3DE Manifest file not found.\n${registration_error} ")
endif ( )
endif ( )
endif ( )
endif ( )