← All tasks
cppgoogle/googletest #3616Not a task: already works

CMake: Build targets contain semicolon in generator-expression in INTERFACE_INCLUDE_DIRECTORIES property

envgap__google__googletest-3616

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
16f637fbf4ffc3f7a01fa4eceb7906634565242f
Manifest
googlemock/CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

google/googletest #3616 · read the original issue
### Describe the bug



The CMake targets `gtest`, `gtest_main`, `gmock` and `gmock_main` will get their `INTERFACE_INCLUDE_DIRECTORIES` property populated with the paths to the include directories containing the headers of GoogleTest/GoogleMock. In order to separate between search-paths for built and installed targets, the generator-expressions `$<BUILD_INTERFACE:...>` and `$<INSTALL_INTERFACE:...>` are used (as recommend by the CMake documentation).  

However, the values that are put into these generator-expressions are lists which contain literal semicolons (`;`). This is problematic, because when iterating over the values of these targets' `INTERFACE_INCLUDE_DIRECTORIES` property the generator-expressions will be broken into multiple parts at these semicolons. As a result, iterating over the individual search path  directories is not possible without additional reconstruction of the individual strings.





### Steps to reproduce the bug



```cmake

# CMakeLists.txt



cmake_minimum_required(VERSION 3.12...3.21)



project( GoogleTest_test



# Get GoogleTest source-code from Github and load its CMakeLists.txt file.

include(FetchContent)

FetchContent_Declare(

    GoogleTest

    GIT_REPOSITORY https://github.com/google/googletest.git

    GIT_TAG master

)

FetchContent_MakeAvailable( GoogleTest )



# Access INTERFACE_INCLUDE_DIRECTORIES property of `gtest` target.

get_target_property( prop gtest INTERFACE_INCLUDE_DIRECTORIES )

# Try to loop through the individual include search paths stored in the property.

foreach( dir IN LISTS prop )

    message( STATUS "include search dir: ${dir}" )

endforeach()

```

Configure it with `mkdir build && cmake -S . -B build`. This then outputs something like this:

```

...

-- include search dir: $<BUILD_INTERFACE:/home/user/build/_deps/googletest-src/googletest/include

-- include search dir: /home/user/build/_deps/googletest-src/googletest>

-- include search dir: $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>

...

```



### Possible solution.



Replace occurrences of `;` in the generator-expressions by `$<SEMICOLON>` instead.



### Does the bug persist in the most recent commit?



Yes



### What operating system and version are you using?



Independent of OS. (I was using Ubuntu 20.04 and Windows 10.)



### What compiler and version are you using?



Does not matter. This is a problem at CMake-configure time.



### What build system are you using?



CMake... obviously.



### Additional context



None
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]