Skip to content

Commit

Permalink
Merge pull request #3227 from lexming/cmake-libdir
Browse files Browse the repository at this point in the history
set CMake installation `LIBDIR` to `lib` by default in `CMakeMake` easyblock
  • Loading branch information
boegel authored May 29, 2024
2 parents 7830af4 + a109930 commit d0ab8a1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions easybuild/easyblocks/generic/cmakemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -201,10 +202,22 @@ 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.info("CMAKE_BUILD_TYPE is set in configopts. Ignoring 'build_type' easyconfig parameter.")
else:
options['CMAKE_BUILD_TYPE'] = self.build_type

# Set installation directory for libraries
# 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']:
options['CMAKE_POSITION_INDEPENDENT_CODE'] = 'ON'
Expand Down Expand Up @@ -232,7 +245,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
Expand Down

0 comments on commit d0ab8a1

Please sign in to comment.