Always use centralized configuration detection mechanisms (like CMake finder modules) instead of hardcoding paths or environment variables. This approach ensures compatibility across different installation methods and environments.
Always use centralized configuration detection mechanisms (like CMake finder modules) instead of hardcoding paths or environment variables. This approach ensures compatibility across different installation methods and environments.
When integrating with external libraries or tools:
findXXX.cmake
) that can detect installations in multiple locationsFor example, instead of hardcoding:
export NVSHMEM_HOME=/usr/local
Create a CMake finder module that can handle multiple installation scenarios:
# findNVSHMEM.cmake example
find_path(NVSHMEM_INCLUDE_DIR nvshmem.h
PATHS
${NVSHMEM_HOME}/include
/usr/local/include
$ENV{CONDA_PREFIX}/include
)
if(NVSHMEM_INCLUDE_DIR)
get_filename_component(NVSHMEM_HOME ${NVSHMEM_INCLUDE_DIR} DIRECTORY)
endif()
This approach ensures your build system can adapt to different installation methods (pip, system packages, custom paths) without requiring manual configuration changes.
Enter the URL of a public GitHub repository