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

[Cpp] CMake: use variables for specifying install paths consistently #4109

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions runtime/Cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,11 @@ if(WITH_DEMO)
add_subdirectory(demo)
endif(WITH_DEMO)

include(GNUInstallDirs)

# Generate CMake Package Files only if install is active
if (ANTLR4_INSTALL)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

if(NOT ANTLR4_CMAKE_DIR)
Expand Down Expand Up @@ -202,14 +203,14 @@ endif(ANTLR4_INSTALL)

if(EXISTS LICENSE.txt)
install(FILES LICENSE.txt
DESTINATION "share/doc/libantlr4")
DESTINATION ${CMAKE_INSTALL_DOCDIR})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this use an ANTLR-specific sub-directory? 🤔

Copy link
Author

@jmairboeck jmairboeck Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMAKE_INSTALL_DOCDIR contains a project specific sub-directory by default, see https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html#result-variables. It defaults to DATAROOTDIR/doc/PROJECT_NAME.

Edit: Maybe the project name should be changed to lower-case so that this matches the old value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, interesting. Didn't know that.

I wonder whether changing the casing of the project name has other side effects though 🤔

elseif(EXISTS ../../LICENSE.txt)
install(FILES ../../LICENSE.txt
DESTINATION "share/doc/libantlr4")
DESTINATION ${CMAKE_INSTALL_DOCDIR})
endif()

install(FILES README.md VERSION
DESTINATION "share/doc/libantlr4")
DESTINATION ${CMAKE_INSTALL_DOCDIR})

set(CPACK_PACKAGE_CONTACT "antlr-discussion@googlegroups.com")
set(CPACK_PACKAGE_VERSION ${ANTLR_VERSION})
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (NOT ANTLR_BUILD_SHARED AND NOT ANTLR_BUILD_STATIC)
message(FATAL_ERROR "Options ANTLR_BUILD_SHARED and ANTLR_BUILD_STATIC can't both be OFF")
endif()

set(libantlrcpp_INCLUDE_INSTALL_DIR "include/antlr4-runtime")
set(libantlrcpp_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/antlr4-runtime")

set(libantlrcpp_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/runtime/src
Expand Down
Loading