Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error evaluating generator expression #5283

Open
1 task done
burak-yildizoz opened this issue Oct 1, 2024 · 0 comments
Open
1 task done

Error evaluating generator expression #5283

burak-yildizoz opened this issue Oct 1, 2024 · 0 comments
Labels
triage Issue pending classification

Comments

@burak-yildizoz
Copy link

Is there an already existing issue for this?

  • I have searched the existing issues

Expected behavior

CMake generate step should not fail.

Current behavior

CMake fails with the following error message.

CMake Error at CMakeLists.txt (target_link_libraries):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:fastrtps,TYPE>

  Target "fastrtps" not found.


CMake Error at CMakeLists.txt (target_link_libraries):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:fastcdr,TYPE>

  Target "fastcdr" not found.

Steps to reproduce

subdirectory/CMakeLists.txt:

find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)

add_library(my_lib STATIC "source.cpp")
target_link_libraries(my_lib PUBLIC fastcdr fastrtps)

CMakeLists.txt:

add_subdirectory(subdirectory)

add_executable(my_exe "main.cpp")
target_link_libraries(my_exe my_lib)

The issue is resolved if the following lines are added to CMakeLists.txt.

find_package(fastcdr QUIET)
find_package(fastrtps QUIET)

Fast DDS version/commit

2.14.2

Platform/Architecture

Windows 10 Visual Studio 2019

Transport layer

Default configuration, UDPv4 & SHM

Additional context

The problem is most likely caused by the following line at src/cpp/CMakeLists.txt files.

target_compile_definitions(${PROJECT_NAME}
    PRIVATE
    ${PROJECT_NAME_UPPER}_SOURCE
    INTERFACE
    $<$<BOOL:${WIN32}>:${PROJECT_NAME_UPPER}_NO_LIB>
    PUBLIC
    $<$<STREQUAL:$<TARGET_PROPERTY:${PROJECT_NAME},TYPE>,SHARED_LIBRARY>:${PROJECT_NAME_UPPER}_DYN_LINK>
    )

The generated line in fastcdr-static-targets.cmake is as follows.

set_target_properties(fastcdr PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "\$<\$<BOOL:1>FASTCDR_NO_LIB>;\$<\$<STREQUAL:\$<TARGET_PROPERTY:fastcdr,TYPE>,SHARED_LIBRARY>:FASTCDR_DYN_LINK>"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
)

Consequently, the problem described in CMake: set_target_properties fails with target defined by generator expression occurs.

XML configuration file

No response

Relevant log output

No response

Network traffic capture

No response

@burak-yildizoz burak-yildizoz added the triage Issue pending classification label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Issue pending classification
Projects
None yet
Development

No branches or pull requests

1 participant