Skip to content

Commit

Permalink
Fixed CMake configuration issue for Gems (o3de#18628)
Browse files Browse the repository at this point in the history
that use CMake to compile external 3rdparty libraries
when those libraries, like FlatBuffers, define custom target
that rely on CMake generator rules.

For example I have a Gem that relies on a proprietary
library called `myproj`. In turn, `myproj` requires FlatBuffers
and uses the CMake function from FlatBuffers called:
```
build_flatbuffers
```
Which define custom targets to automatically compile the IDL files whenever there
are change and generate new C++ files.

I was getting this error when running CMake configure:
```
-- Configuring done (56.5s)
CMake Error at C:/GIT/o3de/cmake/LYWrappers.cmake:398 (add_custom_command):
  Error evaluating generator expression:

    $<TARGET_FILE:myproj_schema>

  Target "myproj_schema" is not an executable or library.
Call Stack (most recent call first):
  C:/GIT/o3de/Code/LauncherUnified/launcher_generator.cmake:164 (ly_add_target)
  C:/GIT/o3de/Code/LauncherUnified/CMakeLists.txt:105 (include)
```
I reached out to @nick-l-o3de, and he found out that `cmake/Platform/Common/RuntimeDependencies_common.cmake`
was the culprit and extra logic was needed at lines:
```
313:         if(NOT target_type IN_LIST LY_TARGET_TYPES_WITH_RUNTIME_OUTPUTS OR target_type STREQUAL UTILITY)
373:         if(NOT target_type IN_LIST LY_TARGET_TYPES_WITH_RUNTIME_OUTPUTS OR target_type STREQUAL UTILITY)
```

Signed-off-by: galibzon <[email protected]>
  • Loading branch information
galibzon authored Jan 18, 2025
1 parent 6df681c commit 6b4b249
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cmake/Platform/Common/RuntimeDependencies_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ function(o3de_get_command_for_dependency)
if(TARGET ${dependency})

get_target_property(target_type ${dependency} TYPE)
if(NOT target_type IN_LIST LY_TARGET_TYPES_WITH_RUNTIME_OUTPUTS)
if(NOT target_type IN_LIST LY_TARGET_TYPES_WITH_RUNTIME_OUTPUTS OR target_type STREQUAL UTILITY)
return()
endif()

Expand Down Expand Up @@ -370,10 +370,9 @@ function(o3de_get_file_from_dependency)
unset(source_file)
if(TARGET ${dependency})
get_property(target_type TARGET ${dependency} PROPERTY TYPE)
if(NOT target_type IN_LIST LY_TARGET_TYPES_WITH_RUNTIME_OUTPUTS)
if(NOT target_type IN_LIST LY_TARGET_TYPES_WITH_RUNTIME_OUTPUTS OR target_type STREQUAL UTILITY)
return()
endif()

set(source_file $<TARGET_FILE:${dependency}>)
else()
string(REGEX MATCH "^([^\n]*)[\n]?(.*)$" file_regex "${dependency}")
Expand Down

0 comments on commit 6b4b249

Please sign in to comment.