Bug 267971 - devel/cmake-core: cmake doesn't respect PATH when it resolves CMAKE_CXX_COMPILER for g++11
Summary: devel/cmake-core: cmake doesn't respect PATH when it resolves CMAKE_CXX_COMPI...
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-kde (Team)
URL: https://gitlab.kitware.com/cmake/cmak...
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-24 18:24 UTC by Yuri Victorovich
Modified: 2022-11-24 20:20 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (kde)


Attachments
cmake-PATH.shar (1.27 KB, text/plain)
2022-11-24 18:24 UTC, Yuri Victorovich
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer 2022-11-24 18:24:40 UTC
Created attachment 238311 [details]
cmake-PATH.shar

Please consider that both c++ and g++11 are not in /usr/local/bin, but instead they are in /usr/local/libexec/ccache, which is placed first in PATH.

When cmake is called with -DCMAKE_CXX_COMPILER=g++11 and the CMAKE_PREFIX_PATH="/usr/local" environment variable is set - CMAKE_CXX_COMPILER ends up being /usr/local/bin/g++11 regardless of PATH.

But if in the above invocation g++11 is replaced with c++ - CMAKE_CXX_COMPILER is resolved through PATH as it should be.

The attached program demonstrates this problem.

Execute run.sh from the attached shar archive. It has 2 sections, GOOD and BAD. BAD section has CMAKE_PREFIX_PATH="/usr/local" and it shows that CMAKE_CXX_COMPILER=/usr/local/bin/g++11

If you would replaces g++11 with c++ - this problem would go away.

This problem prevents CCACHE from working for projects that use GCC.