Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FindANTLR.cmake: should also look in $CLASSPATH #3551

Open
hzeller opened this issue Mar 28, 2023 · 3 comments
Open

FindANTLR.cmake: should also look in $CLASSPATH #3551

hzeller opened this issue Mar 28, 2023 · 3 comments
Assignees

Comments

@hzeller
Copy link
Collaborator

hzeller commented Mar 28, 2023

The cmake/modules/FindANTLR.cmake looks in a few hard-coded well-known locations for a potential antlr*complete.jar.

if(NOT ANTLR_JAR_LOCATION)
find_file(ANTLR_JAR_LOCATION
NAMES antlr-4.12.0-complete.jar antlr.jar antlr4.jar antlr-4.jar
HINTS /usr /usr/local /usr/local/lib/ /usr/share /usr/share/java /usr/local/Homebrew ~/homebrew /usr/local/homebrew/Cellar /opt/homebrew/Cellar
PATH_SUFFIXES antlr 4.12.0 antlr/4.12.0
NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH)
message("ANTLR Jar: ${ANTLR_JAR_LOCATION}")
endif()

However, that is not necessarily where the file is.
It would be good if it was also consulting the CLASSPATH (arguably, it even should look there first before going into guess-mode rummaging through directories).

While at it, looking for exactly version 4.12.0 is very specific, can we change that to 4.12.* to be future compatible in case there are new patchlevels coming out ?

@timkpaine
Copy link
Collaborator

I took a look at where debian and homebrew put the asset, I didn't see anything about setting classpath or configuring the users's profile to have that var. Is it the standard for folks to maintain a classpath var like they might a PATH? Maybe antlr already has something to find where the jar is? But yeah easy to implement, just unfamiliar with Java ecosystem.

@hzeller
Copy link
Collaborator Author

hzeller commented Mar 29, 2023

In NixOS, the jar file ends up in the CLASSPATH (and to show that it is not predictable: in my case, the setting is CLASSPATH=/nix/store/6cnfr2cy5ninj4xnhnqk8x4vkrz8bydn-antlr-4.12.0/share/java/antlr-4.12.0-complete.jar)

In the Java-world, CLASSPATH common - it is what PATH is for binaries.

@timkpaine
Copy link
Collaborator

Ok makes sense, will add

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants