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

String comparisons in CMake failing #791

Closed
simonkampe opened this issue Sep 25, 2020 · 0 comments
Closed

String comparisons in CMake failing #791

simonkampe opened this issue Sep 25, 2020 · 0 comments
Assignees
Labels

Comments

@simonkampe
Copy link

simonkampe commented Sep 25, 2020

When building abseil-cpp with CMake > 3.1 the string comparisons will fail if there exists a variable with the same name as the actual string.

Discovered when compiling abseil as part of a larger project, we had an option called shared in another subrepos CMake-files, and this collided with the check in AbseilHelpers.cpp causing it to hit this else() clause:

message(FATAL_ERROR "Invalid build type: ${_build_type}")

Some debugging suggests this can be solved by changing the comparisons from e.g.

elseif(${_build_type} STREQUAL "static" OR ${_build_type} STREQUAL "shared")

to

elseif(_build_type STREQUAL "static" OR _build_type STREQUAL "shared")

or by using

cmake_policy(SET CMP0054 OLD)

for CMake > 3.1

Somewhere in our CMake-files we set the CMake policy to:

cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})

which should result in it using the NEW behaviour that causes the STREQUALs to fail since it now dereferences everything.

@simonkampe simonkampe added the bug label Sep 25, 2020
@simonkampe simonkampe changed the title String comparisons in CMake (CMP0054) failing String comparisons in CMake failing Sep 25, 2020
@derekmauro derekmauro self-assigned this Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants