Skip to content

Commit

Permalink
Switch "# cmake-format: off" to # gersemi off
Browse files Browse the repository at this point in the history
  • Loading branch information
ManifoldFR committed Oct 23, 2024
1 parent 6a26529 commit f743a57
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 66 deletions.
36 changes: 21 additions & 15 deletions dist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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)
Expand All @@ -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)
Expand Down
72 changes: 51 additions & 21 deletions header.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,25 @@ 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)
# Generate deprecated.hh 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()

Expand All @@ -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
Expand All @@ -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)

# ~~~
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down Expand Up @@ -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()
Loading

0 comments on commit f743a57

Please sign in to comment.