Skip to content

Allow packages to use project() #582

Description

@masterleinad

trilinos/Trilinos#11779 explores using Kokkos as a native CMake project within Trilinos' TriBITS build system. In the process, I noticed that tribits_package_postprocess doesn't work properly if the package uses project(), see https://github.com/trilinos/Trilinos/pull/11779/files#r1196855222, since

if (${PACKAGE_NAME}_SOURCE_DIR STREQUAL ${PROJECT_NAME}_SOURCE_DIR)

would report that the code is executed at the top level instead of at the package level and then set ${PACKAGE_NAME}_TRIBITS_PACKAGE_POSTPROCESS in the same scope instead of in the parent scope.
Using $(CMAKE_PROJECT_NAME}_SOURCE_DIR) instead of $(PROJECT_NAME}_SOURCE_DIR) fixes this for me.
Note that there might be more cases where it would be more appropriate to check for CMAKE_PROJECT_NAME instead of PROJECT_NAME but this appears sufficient for my case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    In Review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions