From 13f4c8561b5036a27302a545885c8582da31ce18 Mon Sep 17 00:00:00 2001 From: Mathieu Faverge <mathieu.faverge@inria.fr> Date: Tue, 21 Nov 2023 11:49:45 +0100 Subject: [PATCH] env.sh: Install the env.sh file only if we use a non default directory to install the package --- modules/GenPkgConfig.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/GenPkgConfig.cmake b/modules/GenPkgConfig.cmake index c683f31..d729630 100644 --- a/modules/GenPkgConfig.cmake +++ b/modules/GenPkgConfig.cmake @@ -230,8 +230,16 @@ macro(generate_env_file) # installation # ------------ - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/bin/${LONAME}_env.sh" - DESTINATION bin) + # Check if the PREFIX is in the PATH or not + # If yes, no need to install this file + string(REPLACE ":" ";" pathlist "$ENV{PATH}") + if ( "${CMAKE_INSTALL_PREFIX}/bin" IN_LIST pathlist ) + message( STATUS "No installation of ${LONAME}_env.sh - already in the default environment" ) + else () + message( STATUS "Install ${LONAME}_env.sh in ${CMAKE_INSTALL_PREFIX}/bin" ) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/bin/${LONAME}_env.sh" + DESTINATION bin) + endif() endmacro(generate_env_file) -- GitLab