am7xxx: MinGW does not have endian.h, provide fallbacks
[libam7xxx.git] / cmake_modules / MaintenanceTools.cmake
1 # Use git for some maintenance tasks
2 find_package(Git)
3 if(GIT_FOUND)
4
5   # Add an 'archive' target to generate a compressed archive from the git source code
6   set(ARCHIVE_PREFIX ${CMAKE_PROJECT_NAME}-${PROJECT_VER})
7   find_program(DATE_EXECUTABLE date DOC "date command line program")
8   if (DATE_EXECUTABLE)
9     message(STATUS "Found date: " ${DATE_EXECUTABLE})
10     message(STATUS "Generator is: " ${CMAKE_GENERATOR})
11
12     # XXX: using $(shell CMD) works only with Unix Makefile
13     if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
14       message(STATUS " - \"git archive\" will use the date too!")
15       set(ARCHIVE_PREFIX ${ARCHIVE_PREFIX}-$\(shell ${DATE_EXECUTABLE} +%Y%m%d%H%M\))
16     endif()
17   endif()
18   add_custom_target(archive
19     COMMAND ${GIT_EXECUTABLE} archive -o \"${CMAKE_BINARY_DIR}/${ARCHIVE_PREFIX}.tar.gz\" --prefix=\"${ARCHIVE_PREFIX}/\" HEAD
20     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
21
22   # Add a 'changelog' target to generate a qausi-GNU-style changelog, it may
23   # be used by distributors to ship when building their packages.
24   add_custom_target(changelog
25     COMMAND ${GIT_EXECUTABLE} log --pretty=\"format:%ai  %aN  <%aE>%n%n%x09* %s%d%n\" > \"${CMAKE_BINARY_DIR}/ChangeLog\"
26     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
27 endif(GIT_FOUND)