From f743a57ca5b83cc19669cac3d3541c23ea89a74a Mon Sep 17 00:00:00 2001 From: ManifoldFR Date: Wed, 23 Oct 2024 11:38:10 +0200 Subject: [PATCH] Switch "# cmake-format: off" to # gersemi off --- dist.cmake | 36 +++++++++++++++----------- header.cmake | 72 ++++++++++++++++++++++++++++++++++++--------------- release.cmake | 58 ++++++++++++++++++++--------------------- 3 files changed, 100 insertions(+), 66 deletions(-) diff --git a/dist.cmake b/dist.cmake index 0099a3e08..50fdd737e 100644 --- a/dist.cmake +++ b/dist.cmake @@ -38,10 +38,10 @@ macro(_SETUP_PROJECT_DIST) if(NOT TARGET distdir) add_custom_target(distdir COMMENT "Generating dist directory...") endif() + # gersemi: off add_custom_target( ${PROJECT_NAME}-distdir COMMAND - # cmake-format: off rm -f /tmp/${PROJECT_NAME}.tar && ${GIT_ARCHIVE_ALL} --prefix ${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}/ ${PROJECT_NAME}.tar && @@ -58,69 +58,75 @@ macro(_SETUP_PROJECT_DIST) ${PROJECT_JRL_CMAKE_MODULE_DIR}/gitlog-to-changelog --srcdir ${PROJECT_SOURCE_DIR} > ${PROJECT_BINARY_DIR}/${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}/ChangeLog && rm -f ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.tar - # cmake-format: on WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMENT "Generating dist directory for ${PROJECT_NAME}...") + # gersemi: on add_dependencies(distdir ${PROJECT_NAME}-distdir) # Create a tar.gz tarball for the project, and generate the signature if(NOT TARGET dist_targz) add_custom_target( - dist_targz COMMENT "Generating tar.gz tarball and its signature...") + dist_targz + COMMENT "Generating tar.gz tarball and its signature..." + ) endif() + # gersemi: off add_custom_target( ${PROJECT_NAME}-dist_targz COMMAND - # cmake-format: off ${TAR} -czf ${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}.tar.gz ${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}/ && ${GPG} --detach-sign --armor -o ${PROJECT_BINARY_DIR}/${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}.tar.gz.sig ${PROJECT_BINARY_DIR}/${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}.tar.gz - # cmake-format: on WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMENT "Generating tar.gz tarball and its signature for ${PROJECT_NAME}...") + # gersemi: on add_dependencies(dist_targz ${PROJECT_NAME}-dist_targz) # Create a tar.bz2 tarball for the project, and generate the signature if(NOT TARGET dist_tarbz2) add_custom_target( - dist_tarbz2 COMMENT "Generating tar.bz2 tarball and its signature...") + dist_tarbz2 + COMMENT "Generating tar.bz2 tarball and its signature..." + ) endif() + # gersemi: off add_custom_target( ${PROJECT_NAME}-dist_tarbz2 COMMAND - # cmake-format: off ${TAR} -cjf ${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}.tar.bz2 ${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}/ && ${GPG} --detach-sign --armor -o ${PROJECT_BINARY_DIR}/${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}.tar.bz2.sig ${PROJECT_BINARY_DIR}/${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}.tar.bz2 - # cmake-format: on WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMENT "Generating tar.bz2 tarball and its signature for ${PROJECT_NAME}...") + # gersemi: on add_dependencies(dist_tarbz2 ${PROJECT_NAME}-dist_tarbz2) # Create a tar.xz tarball for the project, and generate the signature if(NOT TARGET dist_tarxz) add_custom_target( - dist_tarxz COMMENT "Generating tar.xz tarball and its signature...") + dist_tarxz + COMMENT "Generating tar.xz tarball and its signature..." + ) endif() + # gersemi: off add_custom_target( ${PROJECT_NAME}-dist_tarxz COMMAND - # cmake-format: off ${TAR} -cJf ${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}.tar.xz ${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}/ && ${GPG} --detach-sign --armor -o ${PROJECT_BINARY_DIR}/${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}.tar.xz.sig ${PROJECT_BINARY_DIR}/${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}.tar.xz - # cmake-format: on WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMENT "Generating tar.xz tarball and its signature for ${PROJECT_NAME}...") + # gersemi: on add_dependencies(dist_tarxz ${PROJECT_NAME}-dist_tarxz) # Alias: dist = dist_targz (backward compatibility) @@ -134,29 +140,29 @@ macro(_SETUP_PROJECT_DIST) if(NOT TARGET distclean) add_custom_target(distclean COMMENT "Cleaning dist sources...") endif() + # gersemi: off add_custom_target( ${PROJECT_NAME}-distclean COMMAND - # cmake-format: off rm -rf ${PROJECT_BINARY_DIR}/${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}/ - # cmake-format: on WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMENT "Cleaning dist sources for ${PROJECT_NAME}...") + # gersemi: on add_dependencies(distclean ${PROJECT_NAME}-distclean) if(NOT TARGET distorig) add_custom_target(distorig COMMENT "Generating orig tarball...") endif() + # gersemi: off add_custom_target( ${PROJECT_NAME}-distorig COMMAND - # cmake-format: off cmake -E copy ${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}.tar.gz ${PROJECT_NAME}${PROJECT_SUFFIX}-${PROJECT_VERSION}.orig.tar.gz - # cmake-format: on WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMENT "Generating orig tarball for ${PROJECT_NAME}...") + # gersemi: on add_dependencies(distorig ${PROJECT_NAME}-distorig) add_dependencies(${PROJECT_NAME}-dist_targz ${PROJECT_NAME}-distdir) diff --git a/header.cmake b/header.cmake index 468e6f5d9..79a782e94 100644 --- a/header.cmake +++ b/header.cmake @@ -93,7 +93,8 @@ macro(_SETUP_PROJECT_HEADER) # Generate config.hh header. generate_configuration_header( ${HEADER_DIR} config.${PROJECT_CUSTOM_HEADER_EXTENSION} - ${PACKAGE_CPPNAME} ${PACKAGE_CPPNAME_LOWER}_EXPORTS) + ${PACKAGE_CPPNAME} ${PACKAGE_CPPNAME_LOWER}_EXPORTS + ) endif() if(NOT PROJECT_GENERATED_HEADERS_SKIP_DEPRECATED) @@ -101,14 +102,16 @@ macro(_SETUP_PROJECT_HEADER) configure_file( ${PROJECT_JRL_CMAKE_MODULE_DIR}/deprecated.hh.cmake ${CMAKE_CURRENT_BINARY_DIR}/include/${HEADER_DIR}/deprecated.${PROJECT_CUSTOM_HEADER_EXTENSION} - @ONLY) + @ONLY + ) if(INSTALL_GENERATED_HEADERS) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/include/${HEADER_DIR}/deprecated.${PROJECT_CUSTOM_HEADER_EXTENSION} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${HEADER_DIR} - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE) + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + ) endif(INSTALL_GENERATED_HEADERS) endif() @@ -117,30 +120,36 @@ macro(_SETUP_PROJECT_HEADER) configure_file( ${PROJECT_JRL_CMAKE_MODULE_DIR}/warning.hh.cmake ${CMAKE_CURRENT_BINARY_DIR}/include/${HEADER_DIR}/warning.${PROJECT_CUSTOM_HEADER_EXTENSION} - @ONLY) + @ONLY + ) if(INSTALL_GENERATED_HEADERS) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/include/${HEADER_DIR}/warning.${PROJECT_CUSTOM_HEADER_EXTENSION} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${HEADER_DIR} - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE) + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + ) endif(INSTALL_GENERATED_HEADERS) endif() # Generate config.h header. This header, unlike the previous one is *not* # installed and is generated in the top-level directory of the build tree. # Therefore it must not be included by any distributed header. - configure_file(${PROJECT_JRL_CMAKE_MODULE_DIR}/config.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/config.h) + configure_file( + ${PROJECT_JRL_CMAKE_MODULE_DIR}/config.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/config.h + ) # Default include directories: - top-level build directory (for generated # non-distributed headers). - include directory in the build tree (for # generated, distributed headers). - include directory in the source tree # (non-generated, distributed headers). include_directories( - ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/include - ${PROJECT_SOURCE_DIR}/include) + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/include + ${PROJECT_SOURCE_DIR}/include + ) endmacro(_SETUP_PROJECT_HEADER) # GENERATE_CONFIGURATION_HEADER @@ -153,16 +162,20 @@ endmacro(_SETUP_PROJECT_HEADER) # * FILENAME : how the file should be named # * LIBRARY_NAME : CPP symbol prefix, should match the compiled library name # * EXPORT_SYMBOL : controls the switch between symbol import/export -function(GENERATE_CONFIGURATION_HEADER HEADER_DIR FILENAME LIBRARY_NAME - EXPORT_SYMBOL) - # cmake-format: off +function( + GENERATE_CONFIGURATION_HEADER + HEADER_DIR + FILENAME + LIBRARY_NAME + EXPORT_SYMBOL +) generate_configuration_header_v2( INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include HEADER_DIR ${HEADER_DIR} FILENAME ${FILENAME} LIBRARY_NAME ${LIBRARY_NAME} - EXPORT_SYMBOL ${EXPORT_SYMBOL}) - # cmake-format: on + EXPORT_SYMBOL ${EXPORT_SYMBOL} + ) endfunction(GENERATE_CONFIGURATION_HEADER) # ~~~ @@ -193,10 +206,22 @@ endfunction(GENERATE_CONFIGURATION_HEADER) # :param EXPORT_SYMBOL: Controls the switch between symbol import/export. function(GENERATE_CONFIGURATION_HEADER_V2) set(options) - set(oneValueArgs INCLUDE_DIR HEADER_DIR FILENAME LIBRARY_NAME EXPORT_SYMBOL) + set( + oneValueArgs + INCLUDE_DIR + HEADER_DIR + FILENAME + LIBRARY_NAME + EXPORT_SYMBOL + ) set(multiValueArgs) - cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" - ${ARGN}) + cmake_parse_arguments( + ARGS + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) if(${PROJECT_VERSION_MAJOR} MATCHES UNKNOWN) set(PROJECT_VERSION_MAJOR_CONFIG ${ARGS_LIBRARY_NAME}_VERSION_UNKNOWN_TAG) @@ -221,15 +246,19 @@ function(GENERATE_CONFIGURATION_HEADER_V2) set(LIBRARY_NAME ${ARGS_LIBRARY_NAME}) # Generate the header. - configure_file(${PROJECT_JRL_CMAKE_MODULE_DIR}/config.hh.cmake - ${ARGS_INCLUDE_DIR}/${ARGS_HEADER_DIR}/${ARGS_FILENAME} @ONLY) + configure_file( + ${PROJECT_JRL_CMAKE_MODULE_DIR}/config.hh.cmake + ${ARGS_INCLUDE_DIR}/${ARGS_HEADER_DIR}/${ARGS_FILENAME} + @ONLY + ) # Install it if requested. if(INSTALL_GENERATED_HEADERS) install( FILES ${ARGS_INCLUDE_DIR}/${ARGS_HEADER_DIR}/${ARGS_FILENAME} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${ARGS_HEADER_DIR} - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE) + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + ) endif() endfunction(GENERATE_CONFIGURATION_HEADER_V2) @@ -263,6 +292,7 @@ macro(HEADER_INSTALL FILES) install( FILES ${FILE} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${DIR}" - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE) + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE + ) endforeach() endmacro() diff --git a/release.cmake b/release.cmake index 6214742bd..879148f45 100644 --- a/release.cmake +++ b/release.cmake @@ -69,7 +69,8 @@ macro(RELEASE_SETUP) sed -i.back \"s|.*|$$VERSION|g\" package.xml && rm package.xml.back && ${GIT} add package.xml && ${GIT} commit -m "release: Update package.xml version to $$VERSION" && echo - "Updated package.xml and committed") + "Updated package.xml and committed" + ) add_dependencies(release_package_xml ${PROJECT_NAME}-release_package_xml) if(NOT TARGET release_pyproject_toml) @@ -82,19 +83,18 @@ macro(RELEASE_SETUP) COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_JRL_CMAKE_MODULE_DIR}/pyproject.py $$VERSION && if ! (git diff --quiet pyproject.toml) ; then - (${GIT} - add - pyproject.toml - && - ${GIT} - commit - -m - "release: Update pyproject.toml version to $$VERSION" - && - echo - "Updated pyproject.toml and committed") ; fi) - add_dependencies(release_pyproject_toml - ${PROJECT_NAME}-release_pyproject_toml) + ( + ${GIT} + add pyproject.toml && ${GIT} commit -m + "release: Update pyproject.toml version to $$VERSION" && echo + "Updated pyproject.toml and committed" + ) + ; fi + ) + add_dependencies( + release_pyproject_toml + ${PROJECT_NAME}-release_pyproject_toml + ) if(NOT TARGET release_changelog) add_custom_target(release_changelog COMMENT "Update CHANGELOG.md") @@ -109,28 +109,25 @@ macro(RELEASE_SETUP) CHANGELOG.md && sed -i.back "\"s|^\\[Unreleased]: \\(https://.*compare/\\)\\(v.*\\)...HEAD|[Unreleased]: \\1v$$VERSION...HEAD\\n[$$VERSION]: \\1\\2...v$$VERSION|\"" CHANGELOG.md && if ! (git diff --quiet CHANGELOG.md) ; then - (${GIT} - add - CHANGELOG.md - && - ${GIT} - commit - -m - "release: Update CHANGELOG.md for $$VERSION" - && - echo - "Updated CHANGELOG.md and committed") ; fi) + ( + ${GIT} + add CHANGELOG.md && ${GIT} commit -m + "release: Update CHANGELOG.md for $$VERSION" && echo + "Updated CHANGELOG.md and committed" + ) + ; fi + ) add_dependencies(release_changelog ${PROJECT_NAME}-release_changelog) if(NOT TARGET release_pixi_toml) add_custom_target(release_pixi_toml COMMENT "Update pixi.toml") endif() + # gersemi: off add_custom_target( ${PROJECT_NAME}-release_pixi_toml WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMENT "Update pixi.toml for ${PROJECT_NAME}" COMMAND - # cmake-format: off ${PYTHON_EXECUTABLE} ${PROJECT_JRL_CMAKE_MODULE_DIR}/pixi.py $$VERSION && if ! (git diff --quiet pixi.toml) ; then ( @@ -138,8 +135,8 @@ macro(RELEASE_SETUP) ${GIT} commit -m "release: Update pixi.toml version to $$VERSION" && echo "Updated pixi.toml and committed" ) ; fi -# cmake-format: on ) + # gersemi: on add_dependencies(release_pixi_toml ${PROJECT_NAME}-release_pixi_toml) if(NOT TARGET release_citation_cff) @@ -154,19 +151,20 @@ macro(RELEASE_SETUP) "\"s|^version:.*|version: $$VERSION|;s|^date-released:.*|date-released: \\\"${TODAY}\\\"|\"" CITATION.cff && rm CITATION.cff.back && ${GIT} add CITATION.cff && ${GIT} commit -m "release: Update CITATION.cff version to $$VERSION" && - echo "Updated CITATION.cff and committed") + echo "Updated CITATION.cff and committed" + ) add_dependencies(release_citation_cff ${PROJECT_NAME}-release_citation_cff) set(BUILD_CMD ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR} --target) if(NOT TARGET release) add_custom_target(release COMMENT "Create a new release") endif() + # gersemi: off add_custom_target( ${PROJECT_NAME}-release WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMENT "Create a new release for ${PROJECT_NAME}" COMMAND - # cmake-format: off export LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} && export ${LD_LIBRARY_PATH_VARIABLE_NAME}=$ENV{${LD_LIBRARY_PATH_VARIABLE_NAME}} && export PYTHONPATH=$ENV{PYTHONPATH} && @@ -196,8 +194,8 @@ macro(RELEASE_SETUP) ${BUILD_CMD} ${PROJECT_NAME}-dist && ${BUILD_CMD} ${PROJECT_NAME}-distclean && echo "Please, run 'git push --tags' and upload the tarball to github to finalize this release." -# cmake-format: on ) + # gersemi: on add_dependencies(release ${PROJECT_NAME}-release) endif() endmacro()