From 70951375c9f7db7401cf144c5c81acf4533fe443 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 17 Oct 2013 14:03:36 -0500 Subject: [PATCH] Add support for building *.deb file using CPack, install ~/fp-lib-table either from kicad-install.sh or from make install_user_configuration_files --- CMakeLists.txt | 63 ++++++++++++++----- CMakeModules/Functions.cmake | 14 +++++ CMakeModules/cmake_uninstall.cmake.in | 6 +- scripts/kicad-install.sh | 12 +++- template/CMakeLists.txt | 7 ++- template/{fp_global_table => fp-lib-table} | 0 .../{fp_global_table.csv => fp-lib-table.csv} | 0 7 files changed, 79 insertions(+), 23 deletions(-) rename template/{fp_global_table => fp-lib-table} (100%) rename template/{fp_global_table.csv => fp-lib-table.csv} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d34e3d2a45..4b468ea0e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,13 @@ endif() set( DOWNLOAD_DIR ${PROJECT_SOURCE_DIR}/.downloads-by-cmake CACHE PATH "Location of KiCad downloads, suggested is a dir common to all builds, i.e. global." ) +if( UNIX ) + set( KICAD_USER_CONFIG_DIR $ENV{HOME} CACHE PATH "Location of user specifig KiCad config files" ) +elseif( MINGW ) + set( KICAD_USER_CONFIG_DIR $ENV{%APPDATA%} CACHE PATH "Location of user specifig KiCad config files" ) +endif() +mark_as_advanced( KICAD_USER_CONFIG_DIR ) + #================================================ # Set flags for GCC. @@ -415,20 +422,26 @@ endif() #================================================ -# make uninstall rules +# "make uninstall" rules #================================================ configure_file( - "${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY ) + "${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY ) add_custom_target( uninstall - "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" ) + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" ) #================================================ -# Installation parameters +# Installation #================================================ + +add_custom_target( install_user_configuration_files + "${CMAKE_COMMAND}" -E copy "${PROJECT_SOURCE_DIR}/template/fp-lib-table" ${KICAD_USER_CONFIG_DIR}/ + COMMENT "Install template fp-lib-table into your home directory." + ) + install( FILES INSTALL.txt DESTINATION ${KICAD_DOCS} COMPONENT resources ) @@ -442,15 +455,16 @@ install( FILES resources/freeroute.jnlp ### if( UNIX ) install( DIRECTORY scripts - DESTINATION ${KICAD_DOCS} - COMPONENT resources - PATTERN ".svn" EXCLUDE ) + DESTINATION ${KICAD_DOCS} + COMPONENT resources + ) endif() ### # FreeDesktop .desktop and MIME resources ### if( UNIX ) + # Set paths set( UNIX_MIME_DIR resources/linux/mime ) set( UNIX_MIMELNK_FILES ${UNIX_MIME_DIR}/mimelnk ) @@ -462,25 +476,46 @@ if( UNIX ) install( DIRECTORY ${UNIX_MIMELNK_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share COMPONENT resources - PATTERN ".svn" EXCLUDE ) + ) # Install Mime directory install( DIRECTORY ${UNIX_ICONS_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share COMPONENT resources - PATTERN ".svn" EXCLUDE ) + ) # Install Icons install( DIRECTORY ${UNIX_MIME_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share COMPONENT resources - PATTERN ".svn" EXCLUDE ) + ) # Install Applications directory (.desktop files) install( DIRECTORY ${UNIX_APPLICATIONS_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share COMPONENT resources - PATTERN ".svn" EXCLUDE ) + ) endif() -include( CTest ) +#include( CTest ) + + +if( UNIX AND NOT APPLE ) + + # Create a *.deb file: + set( CPACK_GENERATOR "DEB" ) + set( CPACK_DEBIAN_PACKAGE_MAINTAINER "http://launchpad.net/kicad" ) + + set( CPACK_PACKAGE_VERSION_MAJOR 1 ) + set( CPACK_PACKAGE_VERSION_MINOR 0 ) + set( CPACK_PACKAGE_VERSION_PATCH 0 ) + #set( CPACK_PACKAGE_CONTACT Firstname Lastname ) + set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "KiCad built by CMake build system." ) + + # Tell debian CPack about all files which are configuration files + add_conffiles() # clear file + add_conffiles( ${KICAD_USER_CONFIG_DIR}/fp-lib-table ) # append to it + + include( CPack ) + +endif() diff --git a/CMakeModules/Functions.cmake b/CMakeModules/Functions.cmake index 3d9ec9d21b..e3d7f8c9ec 100644 --- a/CMakeModules/Functions.cmake +++ b/CMakeModules/Functions.cmake @@ -55,3 +55,17 @@ function( make_lexer inputFile outHeaderFile outCppFile enum ) endfunction() + +# Is a macro instead of function so there's a higher probability that the +# scope of CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA is global +macro( add_conffiles ) + if( ${ARGC} STREQUAL "0" ) + # remove the file when user passes no arguments, which he should do exactly once at top + file( REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conffiles ) + else() + foreach( filename ${ARGV} ) + file( APPEND ${CMAKE_CURRENT_BINARY_DIR}/conffiles "${filename}\n" ) + endforeach() + set( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/conffiles ) + endif() +endmacro( add_conffiles ) diff --git a/CMakeModules/cmake_uninstall.cmake.in b/CMakeModules/cmake_uninstall.cmake.in index 1a2e75c7ae..fdb4804295 100644 --- a/CMakeModules/cmake_uninstall.cmake.in +++ b/CMakeModules/cmake_uninstall.cmake.in @@ -8,13 +8,13 @@ string( REGEX REPLACE "\n" ";" files "${files}" ) foreach( file ${files} ) message( STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"" ) if( EXISTS "$ENV{DESTDIR}${file}" ) - EXEC_PROGRAM( + exec_program( "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval ) - if( NOT "${rm_retval}" STREQUAL 0 ) - message( FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"" ) + if( NOT "${rm_retval}" STREQUAL "0" ) + message( STATUS "Problem when removing \"$ENV{DESTDIR}${file}\"" ) endif() else() message( STATUS "File \"$ENV{DESTDIR}${file}\" does not exist." ) diff --git a/scripts/kicad-install.sh b/scripts/kicad-install.sh index 243773adbe..d92d7e22ed 100755 --- a/scripts/kicad-install.sh +++ b/scripts/kicad-install.sh @@ -95,10 +95,16 @@ install_or_update() echo "step 7) installing KiCad program files..." sudo make install - echo " kicad installed." + echo " kicad program files installed." - echo "step 8) installing libraries..." + echo "step 8) as non-root, install user configuration files..." + # install ~/fp-lib-table [and friends] + make install_user_configuration_files + echo " kicad user-configuration files installed." + + + echo "step 9) installing libraries..." cd ../../kicad-lib.bzr rm -rf build && mkdir build && cd build cmake ../ @@ -106,7 +112,7 @@ install_or_update() echo " kicad-lib installed." - echo "step 9) installing documentation..." + echo "step 10) installing documentation..." cd ../../kicad-doc.bzr rm -rf build && mkdir build && cd build cmake ../ diff --git a/template/CMakeLists.txt b/template/CMakeLists.txt index c634135bb0..98ad854b9b 100644 --- a/template/CMakeLists.txt +++ b/template/CMakeLists.txt @@ -1,3 +1,4 @@ -install(FILES kicad.pro fp_global_table - DESTINATION ${KICAD_TEMPLATE} - COMPONENT resources) +install( FILES kicad.pro fp-lib-table + DESTINATION ${KICAD_TEMPLATE} + COMPONENT resources + ) diff --git a/template/fp_global_table b/template/fp-lib-table similarity index 100% rename from template/fp_global_table rename to template/fp-lib-table diff --git a/template/fp_global_table.csv b/template/fp-lib-table.csv similarity index 100% rename from template/fp_global_table.csv rename to template/fp-lib-table.csv