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

[22340] Error evaluating generator expression #5283

Closed
1 task done
burak-yildizoz opened this issue Oct 1, 2024 · 1 comment · Fixed by #5435 or eProsima/Fast-CDR#251
Closed
1 task done

[22340] Error evaluating generator expression #5283

burak-yildizoz opened this issue Oct 1, 2024 · 1 comment · Fixed by #5435 or eProsima/Fast-CDR#251
Labels
bug Issue to report a bug in progress Issue or PR which is being reviewed

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
@Mario-DL
Copy link
Member

Hi @burak-yildizoz,

Thanks for the report ! I could reproduce the issue, we will work on that and come back when we address it.

@Mario-DL Mario-DL added bug Issue to report a bug in progress Issue or PR which is being reviewed and removed triage Issue pending classification labels Nov 27, 2024
@Mario-DL Mario-DL changed the title Error evaluating generator expression [22340] Error evaluating generator expression Nov 27, 2024
@Mario-DL Mario-DL linked a pull request Nov 28, 2024 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue to report a bug in progress Issue or PR which is being reviewed
Projects
None yet
2 participants