Mentions légales du service

Skip to content
Snippets Groups Projects
Commit ebd7e004 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Add a new environment file inspired from StarPU to fix python issues

parent af7ca8d6
No related branches found
No related tags found
1 merge request!70Add a new environment file inspired from StarPU to fix python issues
......@@ -51,7 +51,7 @@
# The generated files are then installed in the subdirectory
# lib/pkgconfig of the prefix directory.
#
# generate_env_files(
# generate_env_file(
# [PROJECTNAME name]
# )
# Where:
......@@ -61,6 +61,22 @@
# The generated file is installed in the subdirectory bin of the
# prefix directory.
#
# generate_newenv_file(
# [PACKAGE name]
# [PACKAGE_TEST test]
# )
# Where:
# - PACKAGE defines the project name of the library if different
# from CMAKE_PROJECT_NAME.
# - PACKAGE_TEST defines a test string to check if the installation
# - is correct within the generated file.
#
# While the first version generates a file named $PACKAGE_env.sh, the
# new one generates a $PACKAGE_env file to avoid conflict
#
# The generated file is installed in the subdirectory bin of the
# prefix directory.
#
###
###
......@@ -215,7 +231,7 @@ endmacro(generate_pkgconfig_files)
###
#
# generate_env_file: generate pkf-config files
# generate_env_file: generate file to setup environment variables
#
###
macro(generate_env_file)
......@@ -256,6 +272,62 @@ macro(generate_env_file)
endmacro(generate_env_file)
###
#
# generate_env_file2: generate file to setup environment variables (StarPU-like)
#
###
macro(generate_newenv_file)
set(_options )
set(_oneValueArgs PACKAGE PACKAGE_TEST)
set(_multiValueArgs )
set(MN "generate_env_file2")
cmake_parse_arguments(generate_env_file2
"${_options}" "${_oneValueArgs}"
"${_multiValueArgs}" ${ARGN} )
set(MN "generate_pkgconfig_files")
cmake_parse_arguments(${MN}
"${_options}" "${_oneValueArgs}"
"${_multiValueArgs}" ${ARGN} )
if ( NOT DEFINED ${MN}_PACKAGE )
set( PACKAGE ${CMAKE_PROJECT_NAME} )
else()
set( PACKAGE ${${MN}_PACKAGE} )
endif()
if ( NOT DEFINED ${MN}_PACKAGE_TEST )
set( PACKAGE_TEST "0 = 0" )
else()
set( PACKAGE_TEST ${${MN}_PACKAGE_TEST} )
endif()
string(TOLOWER ${PACKAGE} PACKAGE_LC)
string(TOUPPER ${PACKAGE} PACKAGE_UC)
# Create .sh file
# ---------------
configure_file(
"${MORSE_CMAKE_MODULE_PATH}/env.in"
"${CMAKE_CURRENT_BINARY_DIR}/bin/${PACKAGE_LC}_env" @ONLY)
# installation
# ------------
# 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 ${PACKAGE_LC}_env - already in the default environment" )
else ()
message( STATUS "Install ${PACKAGE_LC}_env in ${CMAKE_INSTALL_PREFIX}/bin" )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/bin/${PACKAGE_LC}_env"
DESTINATION bin)
endif()
endmacro(generate_newenv_file)
##
## @end file GenPkgConfig.cmake
##
#
# @file @LONAME@_env.sh
#
# @copyright 2016-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
# Univ. Bordeaux. All rights reserved.
#
# @version 0.9.0
# @author Mathieu Faverge
# @date 2024-09-26
#
# @brief Script to setup environment file inspired from StarPU
#
#!/bin/sh
PROGNAME=@PACKAGE_LC@_env
usage()
{
echo "Tool to set @PACKAGE@ environment variables"
echo ""
echo "Usage: source $PROGNAME"
echo ""
echo ""
echo "Options:"
echo " -h, --help display this help and exit"
echo " -v, --version output version information and exit"
echo ""
echo "Report bugs to <@PACKAGE_BUGREPORT@>"
}
if [ "$1" = "-v" ] || [ "$1" = "--version" ]
then
echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]
then
usage
else
prefix=$(realpath @CMAKE_INSTALL_PREFIX@)
@PACKAGE_LC@_bindir=$(realpath @CMAKE_INSTALL_PREFIX@/bin)
@PACKAGE_LC@_libdir=$(realpath @CMAKE_INSTALL_PREFIX@/lib)
@PACKAGE_LC@_datarootdir=$(realpath @CMAKE_INSTALL_PREFIX@/share)
if [ -n "@PACKAGE_TEST@" ]
then
if test @PACKAGE_TEST@
then
echo "Setting @PACKAGE@ environment for $prefix"
export @PACKAGE_UC@_ROOT=$prefix
export PKG_CONFIG_PATH=$@PACKAGE_LC@_libdir/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=$@PACKAGE_LC@_libdir:$LD_LIBRARY_PATH
export PATH=$@PACKAGE_LC@_bindir:$PATH
export MANPATH=$@PACKAGE_LC@_datarootdir/man:$MANPATH
for d in $@PACKAGE_LC@_libdir/python3*/site-packages ; do export PYTHONPATH=$d:$PYTHONPATH ; done
else
echo "[Error] $prefix is not a valid @PACKAGE@ installation directory"
fi
fi
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment