better handling of CMAKE_MODULE_PATH when passed to another project

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
monroegm-disable-blank-issue-2
Esteban Papp 4 years ago
parent 9585096829
commit 4e699138b8

@ -21,6 +21,21 @@ if(json_error)
message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}") message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}")
endif() endif()
if(CMAKE_MODULE_PATH)
foreach(module_path ${CMAKE_MODULE_PATH})
if(EXISTS ${module_path}/Findo3de.cmake)
file(READ ${module_path}/../engine.json engine_json)
string(JSON engine_name ERROR_VARIABLE json_error GET ${engine_json} engine_name)
if(json_error)
message(FATAL_ERROR "Unable to read key 'engine_name' from 'engine.json', error: ${json_error}")
endif()
if(LY_ENGINE_NAME_TO_USE STREQUAL engine_name)
return() # Engine being forced through CMAKE_MODULE_PATH
endif()
endif()
endforeach()
endif()
if(DEFINED ENV{USERPROFILE} AND EXISTS $ENV{USERPROFILE}) if(DEFINED ENV{USERPROFILE} AND EXISTS $ENV{USERPROFILE})
set(manifest_path $ENV{USERPROFILE}/.o3de/o3de_manifest.json) # Windows set(manifest_path $ENV{USERPROFILE}/.o3de/o3de_manifest.json) # Windows
else() else()

@ -21,6 +21,21 @@ if(json_error)
message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}") message(FATAL_ERROR "Unable to read key 'engine' from 'project.json', error: ${json_error}")
endif() endif()
if(CMAKE_MODULE_PATH)
foreach(module_path ${CMAKE_MODULE_PATH})
if(EXISTS ${module_path}/Findo3de.cmake)
file(READ ${module_path}/../engine.json engine_json)
string(JSON engine_name ERROR_VARIABLE json_error GET ${engine_json} engine_name)
if(json_error)
message(FATAL_ERROR "Unable to read key 'engine_name' from 'engine.json', error: ${json_error}")
endif()
if(LY_ENGINE_NAME_TO_USE STREQUAL engine_name)
return() # Engine being forced through CMAKE_MODULE_PATH
endif()
endif()
endforeach()
endif()
if(DEFINED ENV{USERPROFILE} AND EXISTS $ENV{USERPROFILE}) if(DEFINED ENV{USERPROFILE} AND EXISTS $ENV{USERPROFILE})
set(manifest_path $ENV{USERPROFILE}/.o3de/o3de_manifest.json) # Windows set(manifest_path $ENV{USERPROFILE}/.o3de/o3de_manifest.json) # Windows
else() else()

Loading…
Cancel
Save