poac-dev / poac

A package manager and build system for C++
https://poac.dev
Apache License 2.0
1.13k stars 73 forks source link

Incorrect CXX value in internally generated Makefile #924

Closed watiko closed 2 days ago

watiko commented 4 months ago

In the Makefile generated by poac when the CXX environment variable is not specified, CXX is specified as follows.

CXX ?= clang++
# https://github.com/poac-dev/poac/blob/0.9.3/src/BuildConfig.cc#L569

In this case, CXX is Implicit Variables in Gnu Make, so the default value of g++ is retained. This means that unintentional use of g++ will occur via make when CXX environment variables are not specified. https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

I'm not familiar with make, but the following might work as intended.

ifeq "$(origin CXX)" "default"
    CXX := clang++
endif

.PHONY: all
all:
    @echo "$(info $(CXX))"
ken-matsui commented 4 months ago

@watiko Thank you for reporting this! Would you want to submit a PR for this? I'm happy to review it.