Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake modernization to 1.2.x #203

Open
wants to merge 19 commits into
base: release/1.2
Choose a base branch
from

Conversation

loriab
Copy link
Contributor

@loriab loriab commented Apr 6, 2023

Description

CMake and Windows and OSX arm64 modernization for the 1.2.x branch. Recommend forward-porting to master bevore the 1.3.1 release.

How Has This Been Tested?

Todos

  • Developer Interest

Most of this is a standard checklist. there's pcm specialities at the end.

  • update old files

    • copy over xhost.cmake that has new compilers. import it instead of one-liner. adapt if C, not CXX. no such file
    • expand safeguards to new build types, RelWithDebInfo, and MinSizeRel
    • update cmake min version to 3.16
    • replace SameMajorVersion with now-available SameMinorVersion if appropriate
    • remove any ${PN} in main project CMake as they tend to get clobbered in/after find_package
    • any new project-specific options, prepend in project-case, like ambit_ENABLE_PYTHON. does not apply to e.g., BUILD_TESTING, BUILD_SHARED_LIBS none that I see
  • Python

    • if still on old NumPy/pb11 Py detection, switch to approx. find_package(Python 3.7 COMPONENTS Interpreter Development NumPy REQUIRED)
    • update any set(Python_ADDITIONAL_VERSIONS none
    • update cmake_minimum_required(VERSION 3.16) for Py detection
    • update any PYTHON_EXECUTABLE to Python_EXECUTABLE
    • remove any old FindPythonLibsNew.cmake none
    • if any pybind11, check that find_package(Python) before find_package(pybind11) no pb11
    • if any pybind11 target, remove PREFIX/SUFFIX from properties no pb11
    • psi4: update the call in external/
  • editable config.cmake location

    • add option(<project>_INSTALL_CMAKEDIR) to make Config.cmake location editable with variable, incl any subprojects like TargetLAPACK.
      • Initially I didn't do this, but CMAKECONFIG_INSTALL_DIR wasn't editable, so may as well.
    • recipe: specify in bld.bat as -D <project>_INSTALL_CMAKEDIR="Library\share\cmake\<project>" ^ if CMAKE_INSTALL_PREFIX="%PREFIX%" no need since it was LIBRARY_PREFIX in recipe for Win
    • psi4: add the call in external/ (CMAKE_ARGS and <project>_DIR and any TargetLAPACK, etc.)
  • modernize target install/export

    • for install(TARGETS), use full runtime/arch/lib DESTINATIONs so Windows can work
    • for install(TARGETS), consider a descriptive EXPORT so not repeating targets filename
    • for install(EXPORT), use descriptive EXPORT and lang or type names to Targets files
  • make properties target-centered, particularly for FetchContent usage. target and find_package(<package>) should provide same info.

    • define export_properties variable and append it to all base targets (e.g., static and shared always-built libs)
    • set the version on the target. use casing like in the config file, probaly project(CheMPS2) --> CheMPS2_VERSION
      • I'd really like to get version attached to the target for FetchContent consumption, but b/c computed at config-time, I think it's impossible. Might work with a function call. Not done.
    • set all other properties that were project-specific vars in the config (like Libint_MAX_AM_ERI) on the target
      • did PCMSolver_PYMOD
    • check through find_package() that targets are fully loaded (--log-level verbose and extra stuff in Config.cmake can help)
    • define aliases matching imported targets, add_library(ambit::ambit ALIAS ambit-shared). Favor shared if both can be built together.
    • rename any CMAKE_SOURCE_DIR/CMAKE_BINARY_DIR to PROJECT_SOURCE_DIR/PROJECT_BINARY_DIR
    • check fetch_content works
  • modernize <project>Config.cmake.in

    • kill off all PN with something like set(amb ambit) # NameSpace. PN gets overwritten a lot, so let's specialize it.
    • remove find_header, find_file, find_library find_exe reminicent of Find<project>.cmake rather than <project>Config.cmake
    • read find_project variables off target, rather than setting from file_header/lib/exe results
    • ~if any Find files installed, add list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) ~ none
    • check components with check_required_components(<project>) (probably already present)
    • NEVER load exported <project>Targets.cmake before all components confirmed found and all dependencies confirmed found
    • run a find_project(<project>) to check that vars match target (same as 4th bullet prev. section)
  • check that all dependencies are handled (sometimes outsourced to psi4, like BLAS for dkh)

    • add TargetLAPACK if using BLAS/LAPACK none
    • copy over new FindTargetLAPACK, FindTargetHDF5 as needed. modify if only use BLAS none
    • install the Find files with the Config none
    • in config file, add any find_dependency that we were leaving for psi4 before still just zlib
  • handling lib and pylib as separate projects

    • MOSTLY DELETED SINCE PCMSOLVER PY ISN'T INTF
    • CHOOSING YES, do have a PCMSolver_PYMOD variable attached to the target and Config
    • details on separate pylib
      • for installation positioning, use PYMOD_INSTALL_LIBDIR if var already exists b/c in psi orbit. otherwise emulate libint (LIBINT2_INSTALL_PYMODDIR) or libxc (PYLIBXC_INSTALL_PYMODDIR)
        • used existing PYMOD_INSTALL_LIBDIR but added prefix / to match other psi-like projects
  • particular for this project: pcmsolver

    • as mentioned above, PYMOD_INSTALL_LIBDIR defaults to /python (slash added) to match other projects
    • boost and eigen detection are a little chattier to facilitate detecting pre-built.
      • boost doesn't tidy up after itself on Windows.
      • hid FindEigen since it was interfering with modern installations
    • promote run_pcm to an exported target (so I could test the c-f package) with install, alias, export, etc.
    • modernized some Py syntax in getkw.py, pcmparser.py, pyparsing.py
    • added enormous 3rd-party-licensing file to satisfy c-f packaging requirements. Looks like I standardized versioner.py license back to psi-like in the process, but I don't really care -- change it back if you wish.
    • expanded c++11 flags testing to Windows format
    • includes v1211 #193 (except the tmpnam bit removed b/c I can't trigger the bug it fixed) (closes v1211 #193)
    • includes Fix CMake to work with FetchContent #196
    • note that this branch through b32d5e1 is what got merged from Add PCMSolver conda-forge/staged-recipes#22286 into the big squashed patch at https://github.com/conda-forge/pcmsolver-split-feedstock . This, this works for Linux, Mac, and Windows. The big patch can get removed if you mint a v1.2.4 or when this PR presumably gets incorporated into v1.3.1 -- I've no preferences as to which.
    • catch header needed a patch for osx arm64
  • User-Facing for Release Notes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Status

  • Ready to go
  • Cherry-pick to latest release branch

@loriab loriab mentioned this pull request May 31, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant