Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 2,686
    • Issues 2,686
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 23
    • Merge Requests 23
  • Packages
    • Packages
    • Container Registry
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Commits
  • Issue Boards
  • CMake
  • CMakeCMake
  • Issues
  • #18556

Closed
Open
Opened Nov 05, 2018 by Kyle Edwards@kyle.edwards
  • Report abuse
  • New issue
Report abuse New issue

$<IN_LIST:...> doesn't handle empty strings the same way as if(IN_LIST)

These two don't work the same:

# Test if(IN_LIST)
set(_item "")
set(_mylist ";a")
if(_item IN_LIST _mylist)
  message(STATUS "In the list")
else()
  message(STATUS "Not in the list")
endif()

# Test $<IN_LIST:...>
add_custom_target(tgt COMMAND ${CMAKE_COMMAND} -E echo $<IN_LIST:,$<SEMICOLON>a>)

The if(IN_LIST) case says "yes", but the generator expression says "no". This is surprising and unexpected behavior.

Unfortunately, it seems to be enforced by Tests/GeneratorExpression/CMakeLists.txt line 64:

    -Dtest_inlist_empty_3=$<IN_LIST:,>

and Tests/GeneratorExpression/check-part1.cmake line 56:

check(test_inlist_empty_3 "0")

The fix would be to change line 291 in Source/cmGeneratorExpressionNode.cxx:

    cmSystemTools::ExpandListArgument(parameters[1], values); // Add a true parameter to the end to handle empty items

However, this would break backwards compatibility. We could add a policy that tries it both ways and warns the user if they differ.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
1
Labels
triage:needpolicy
Assign labels
  • View project labels
Reference: cmake/cmake#18556