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

Change CMakeLists.txt for generating deb and rpm #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,61 @@
set(VERSION 1.0.2)
cmake_minimum_required(VERSION 2.8.0)
project(CrazyDiskInfo CXX)
add_executable(CrazyDiskInfo main.cpp)
set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
SET_TARGET_PROPERTIES(CrazyDiskInfo PROPERTIES OUTPUT_NAME crazy)
set_target_properties(CrazyDiskInfo PROPERTIES OUTPUT_NAME crazy)
target_link_libraries(CrazyDiskInfo atasmart)
target_link_libraries(CrazyDiskInfo ncursesw)
INSTALL(TARGETS CrazyDiskInfo RUNTIME DESTINATION /usr/sbin)
set(CMAKE_INSTALL_PREFIX /usr)
install(TARGETS CrazyDiskInfo RUNTIME DESTINATION sbin)
install(FILES LICENSE README.md DESTINATION share/doc/CrazyDiskInfo)
# CPACK
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_SOURCE_IGNORE_FILES \\\\.git/ \\\\..*\\\\.swp /build/ Changelog.tmp)
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_NAME "CrazyDiskInfo")
set(CPACK_PACKAGE_CONTACT "https://github.com/otakuto")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CrazyDiskInfo is an interactive TUI S.M.A.R.T viewer for Unix systems")
set(CPACK_PACKAGE_VENDOR "otakuto")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
# find dpkg or rpm and switch the package name
string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE)
find_program(DPKG_PROGRAM dpkg)
if(DPKG_PROGRAM)
execute_process(
COMMAND ${DPKG_PROGRAM} --print-architecture
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME_LOWERCASE}_${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
set(CPACK_GENERATOR "DEB" ${CPACK_GENERATOR})
else(DPKG_PROGRAM)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
find_program(RPM_PROGRAM rpm)
if(RPM_PROGRAM)
set(CPACK_GENERATOR "RPM" ${CPACK_GENERATOR})
endif(RPM_PROGRAM)
endif(DPKG_PROGRAM)
# making rpm
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_GROUP "Utilities")
set(CPACK_RPM_PACKAGE_REQUIRES "libatasmart ncurses-libs")
set(CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/sbin)
execute_process(COMMAND git log --format=*\ %cd\ %aN%n-\ \(%h\)\ %s%d%n --date=local
OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Changelog.tmp)
execute_process(COMMAND sed -r s/[0-9]+:[0-9]+:[0-9]+\ //
INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Changelog.tmp
OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Changelog)
set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Changelog")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libatasmart4, libncurses5, libncursesw5")
set(CPACK_DEBIAN_PACKAGE_SECTION "admin")
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}")
include(CPack)
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,29 @@ $ make && make install
$ sudo crazy
```

## Build rpm or deb packge, Install and Run
In rpm environment:
```
$ sudo yum install ncurses-devel libatasmart-devel gcc-c++ cmake
$ mkdir build
$ cd build
$ cmake ..
$ cpack --config CPackConfig.cmake
$ sudo rpm -ihv CrazyDiskInfo-*.rpm
$ sudo crazy
```

In deb environment:
```
$ sudo apt-get install libatasmart-dev libncurses5-dev libncursesw5-dev cmake g++
$ mkdir build
$ cd build
$ cmake ..
$ cpack --config CPackConfig.cmake
$ sudo dpkg -i crazydiskinfo_*.deb
$ sudo crazy
```

### Binary Package
Debian package is available from [OBS(Open Build Service)](https://build.opensuse.org/package/show/home:tsuroot/CrazyDiskInfo)
Direct Links:
Expand Down