From b41683af2042e04b7cd8849c02859a5a91b9a5a9 Mon Sep 17 00:00:00 2001 From: Alex Domingo Date: Wed, 14 Feb 2024 17:37:14 +0100 Subject: [PATCH 1/5] set CMake installation LIBDIR to lib by default in CMakeMake easyblock --- easybuild/easyblocks/generic/cmakemake.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/easybuild/easyblocks/generic/cmakemake.py b/easybuild/easyblocks/generic/cmakemake.py index 4c6eca89e0..f31a5da55c 100644 --- a/easybuild/easyblocks/generic/cmakemake.py +++ b/easybuild/easyblocks/generic/cmakemake.py @@ -106,6 +106,7 @@ def extra_options(extra_vars=None): 'configure_cmd': [DEFAULT_CONFIGURE_CMD, "Configure command to use", CUSTOM], 'generator': [None, "Build file generator to use. None to use CMakes default", CUSTOM], 'install_target_subdir': [None, "Subdirectory to use as installation target", CUSTOM], + 'install_libdir': ['lib', "Subdirectory to use for library installation files", CUSTOM], 'runtest': [None, "Make target to test build or True to use CTest", BUILD], 'srcdir': [None, "Source directory location to provide to cmake command", CUSTOM], 'separate_build_dir': [True, "Perform build in a separate directory", CUSTOM], @@ -201,10 +202,17 @@ def configure_step(self, srcdir=None, builddir=None): if '-DCMAKE_BUILD_TYPE=' in self.cfg['configopts']: if self.cfg.get('build_type') is not None: - self.log.warning('CMAKE_BUILD_TYPE is set in configopts. Ignoring build_type') + self.log.warning("CMAKE_BUILD_TYPE is set in configopts. Ignoring 'build_type' easyconfig parameter.") else: options['CMAKE_BUILD_TYPE'] = self.build_type + if '-DCMAKE_INSTALL_LIBDIR=' in self.cfg['configopts']: + self.log.warning( + "CMAKE_INSTALL_LIBDIR is set in configopts. Ignoring 'install_libdir' easyconfig parameter." + ) + else: + options['CMAKE_INSTALL_LIBDIR'] = self.cfg['install_libdir'] + # Add -fPIC flag if necessary if self.toolchain.options['pic']: options['CMAKE_POSITION_INDEPENDENT_CODE'] = 'ON' From 805eae2e9457546b357828d8069056ebde4a805a Mon Sep 17 00:00:00 2001 From: Alex Domingo Date: Wed, 6 Mar 2024 18:32:35 +0100 Subject: [PATCH 2/5] downgrade logs to info level about CMAKE_BUILD_TYPE and CMAKE_INSTALL_LIBDIR settings in configopts replacing easyconfig parameters --- easybuild/easyblocks/generic/cmakemake.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easybuild/easyblocks/generic/cmakemake.py b/easybuild/easyblocks/generic/cmakemake.py index f31a5da55c..0aeaf77307 100644 --- a/easybuild/easyblocks/generic/cmakemake.py +++ b/easybuild/easyblocks/generic/cmakemake.py @@ -202,12 +202,12 @@ def configure_step(self, srcdir=None, builddir=None): if '-DCMAKE_BUILD_TYPE=' in self.cfg['configopts']: if self.cfg.get('build_type') is not None: - self.log.warning("CMAKE_BUILD_TYPE is set in configopts. Ignoring 'build_type' easyconfig parameter.") + self.log.info("CMAKE_BUILD_TYPE is set in configopts. Ignoring 'build_type' easyconfig parameter.") else: options['CMAKE_BUILD_TYPE'] = self.build_type if '-DCMAKE_INSTALL_LIBDIR=' in self.cfg['configopts']: - self.log.warning( + self.log.info( "CMAKE_INSTALL_LIBDIR is set in configopts. Ignoring 'install_libdir' easyconfig parameter." ) else: From 6235fab1538e5b623abb29d6f7c81114fe95df0b Mon Sep 17 00:00:00 2001 From: Alex Domingo Date: Wed, 6 Mar 2024 18:34:21 +0100 Subject: [PATCH 3/5] fix typo in warning message about BUILD_SHARED_LIBS in configopts --- easybuild/easyblocks/generic/cmakemake.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/generic/cmakemake.py b/easybuild/easyblocks/generic/cmakemake.py index 0aeaf77307..c44bbe7479 100644 --- a/easybuild/easyblocks/generic/cmakemake.py +++ b/easybuild/easyblocks/generic/cmakemake.py @@ -240,7 +240,7 @@ def configure_step(self, srcdir=None, builddir=None): # Usually you want to remove -DBUILD_SHARED_LIBS from configopts and set build_shared_libs to True or False # If you need it in configopts don't set build_shared_libs (or explicitely set it to `None` (Default)) if '-DBUILD_SHARED_LIBS=' in self.cfg['configopts']: - print_warning('Ignoring BUILD_SHARED_LIBS is set in configopts because build_shared_libs is set') + print_warning('Ignoring BUILD_SHARED_LIBS setting in configopts because build_shared_libs is set') self.cfg.update('configopts', '-DBUILD_SHARED_LIBS=%s' % ('ON' if build_shared_libs else 'OFF')) # If the cache does not exist CMake reads the environment variables From 3880cc12bf14ceb46d251dac9b16924efbd01de6 Mon Sep 17 00:00:00 2001 From: Alex Domingo Date: Fri, 3 May 2024 09:30:37 +0200 Subject: [PATCH 4/5] set CMAKE_INSTALL_LIBDIR as a path type --- easybuild/easyblocks/generic/cmakemake.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/easybuild/easyblocks/generic/cmakemake.py b/easybuild/easyblocks/generic/cmakemake.py index 0b83960c77..65d5c9712a 100644 --- a/easybuild/easyblocks/generic/cmakemake.py +++ b/easybuild/easyblocks/generic/cmakemake.py @@ -206,12 +206,16 @@ def configure_step(self, srcdir=None, builddir=None): else: options['CMAKE_BUILD_TYPE'] = self.build_type - if '-DCMAKE_INSTALL_LIBDIR=' in self.cfg['configopts']: + # Set installation directory for libraries + # any CMAKE_INSTALL_DIR[:PATH] setting defined in easyconfig has precedence + cmake_install_dir_pattern = re.compile(r"-DCMAKE_INSTALL_LIBDIR(:PATH)?=[^\s]") + if cmake_install_dir_pattern.search(self.cfg['configopts']): self.log.info( "CMAKE_INSTALL_LIBDIR is set in configopts. Ignoring 'install_libdir' easyconfig parameter." ) else: - options['CMAKE_INSTALL_LIBDIR'] = self.cfg['install_libdir'] + # set CMAKE_INSTALL_LIBDIR including its type to PATH, otherwise CMake can silently ignore it + options['CMAKE_INSTALL_LIBDIR:PATH'] = self.cfg['install_libdir'] # Add -fPIC flag if necessary if self.toolchain.options['pic']: From a1099302f231a84119e519ee7db53d873073d7fc Mon Sep 17 00:00:00 2001 From: Alex Domingo Date: Mon, 27 May 2024 10:27:30 +0200 Subject: [PATCH 5/5] allow disabling CMAKE_INSTALL_LIBDIR injection through install_libdir in CMakeMake --- easybuild/easyblocks/generic/cmakemake.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/easybuild/easyblocks/generic/cmakemake.py b/easybuild/easyblocks/generic/cmakemake.py index 65d5c9712a..a9fb2f630c 100644 --- a/easybuild/easyblocks/generic/cmakemake.py +++ b/easybuild/easyblocks/generic/cmakemake.py @@ -207,15 +207,16 @@ def configure_step(self, srcdir=None, builddir=None): options['CMAKE_BUILD_TYPE'] = self.build_type # Set installation directory for libraries - # any CMAKE_INSTALL_DIR[:PATH] setting defined in easyconfig has precedence - cmake_install_dir_pattern = re.compile(r"-DCMAKE_INSTALL_LIBDIR(:PATH)?=[^\s]") - if cmake_install_dir_pattern.search(self.cfg['configopts']): - self.log.info( - "CMAKE_INSTALL_LIBDIR is set in configopts. Ignoring 'install_libdir' easyconfig parameter." - ) - else: - # set CMAKE_INSTALL_LIBDIR including its type to PATH, otherwise CMake can silently ignore it - options['CMAKE_INSTALL_LIBDIR:PATH'] = self.cfg['install_libdir'] + # any CMAKE_INSTALL_DIR[:PATH] setting defined in 'configopts' has precedence over 'install_libdir' + if self.cfg['install_libdir'] is not None: + cmake_install_dir_pattern = re.compile(r"-DCMAKE_INSTALL_LIBDIR(:PATH)?=[^\s]") + if cmake_install_dir_pattern.search(self.cfg['configopts']): + self.log.info( + "CMAKE_INSTALL_LIBDIR is set in configopts. Ignoring 'install_libdir' easyconfig parameter." + ) + else: + # set CMAKE_INSTALL_LIBDIR including its type to PATH, otherwise CMake can silently ignore it + options['CMAKE_INSTALL_LIBDIR:PATH'] = self.cfg['install_libdir'] # Add -fPIC flag if necessary if self.toolchain.options['pic']: