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 2023 updates #6

Open
62 tasks done
loriab opened this issue May 23, 2023 · 0 comments
Open
62 tasks done

cmake 2023 updates #6

loriab opened this issue May 23, 2023 · 0 comments

Comments

@loriab
Copy link
Member

loriab commented May 23, 2023

  • update old files

    • copy over xhost.cmake that has new compilers. import it instead of one-liner. adapt if C, not CXX.
      • No, since mostly fortran
    • expand safeguards to new build types, RelWithDebInfo, and MinSizeRel
    • update cmake min version to 3.16
    • replace SameMajorVersion with now-available SameMinorVersion if appropriate
      • AnyNewVersion -> SameMajorVersion
    • 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
  • 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
    • update cmake_minimum_required(VERSION 3.16) for Py detection
    • update any PYTHON_EXECUTABLE to Python_EXECUTABLE
    • remove any old FindPythonLibsNew.cmake
    • if any pybind11, check that find_package(Python) before find_package(pybind11)
    • if any pybind11 target, remove PREFIX/SUFFIX from properties
    • 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.
    • recipe: specify in bld.bat as -D <project>_INSTALL_CMAKEDIR="Library\share\cmake\<project>" ^ if CMAKE_INSTALL_PREFIX="%PREFIX%"
    • 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
    • set all other properties that were project-specific vars in the config (like Libint_MAX_AM_ERI) on the target
    • 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})
    • 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
    • copy over new FindTargetLAPACK, FindTargetHDF5 as needed. modify if only use BLAS
    • install the Find files with the Config
    • in config file, add any find_dependency that we were leaving for psi4 before
  • handling lib and pylib as separate projects

    • there's room for opinion on this. see discussion at GH:jturney/ambit/pyambit/CMakeLists.txt .
    • YES, do have an ENABLE_PYTHON (or better, _ENABLE_PYTHON) so library can be built alone
    • PROBABLY YES, do have a project(pyproject) so python can be built alone after detecting project
    • CHOOSING YES, do have a ambit_PYMOD variable attached to the target and Config?
    • CHOOSING YES, same Config.cmake file for C++ and Py, where latter optional and detected with COMPONENTS Python? It's easy enough to have the targets exported to Targets-Python.cmake so same file can manage.
    • 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)
      • copy over basic and relevant options from main project
      • copy over version from main project. notate where to sync verson
        notes for packagers about config.cmake
      • install whole py intf module, incl tests
      • remove restriction that pb11 module can only link to shared library. remove PIC for pb11 module since it handles that
      • for Linux-style install ONLY, write a Python component to Config.cmake
      • if a Py-style install is wanted, toggle Linux-style and Py-style install with something like LIBINT2_PREFIX_PYTHON_INSTALL
      • leave a note for packagers about lib/pylib and config.cmake choices
  • particular for this project: gdma

    • add executable back
    • add py module
    • add windows
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

No branches or pull requests

1 participant