mirror of
https://gitlab.com/kicad/libraries/kicad-footprints.git
synced 2025-03-29 23:16:55 +00:00
Add install/uninstall capability using CMake.
This commit is contained in:
parent
bb1b9aa3b4
commit
e8e24c6d64
58
CMakeLists.txt
Normal file
58
CMakeLists.txt
Normal file
@ -0,0 +1,58 @@
|
||||
project( kicad-footprints )
|
||||
|
||||
cmake_minimum_required( VERSION 2.6.1 FATAL_ERROR )
|
||||
|
||||
|
||||
#================================================
|
||||
# Locations for install targets.
|
||||
#================================================
|
||||
if( APPLE )
|
||||
# Like all variables, CMAKE_INSTALL_PREFIX can be over-ridden on the command line.
|
||||
set( CMAKE_INSTALL_PREFIX "/Library/Application Support/kicad/" CACHE PATH "" )
|
||||
# Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
|
||||
set( KICAD_MODULES modules )
|
||||
set( KICAD_TEMPLATE template )
|
||||
else()
|
||||
# Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
|
||||
set( KICAD_DATA share/kicad
|
||||
CACHE PATH "Location of KiCad data files." )
|
||||
set( KICAD_MODULES ${KICAD_DATA}/modules )
|
||||
set( KICAD_TEMPLATE ${KICAD_DATA}/template )
|
||||
endif()
|
||||
|
||||
mark_as_advanced( KICAD_DATA KICAD_MODULES )
|
||||
|
||||
|
||||
#================================================
|
||||
# "make uninstall" rules
|
||||
#
|
||||
# The uninstaller does not remove folders only files.
|
||||
#================================================
|
||||
configure_file(
|
||||
"${PROJECT_SOURCE_DIR}/CMakeModules/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"
|
||||
)
|
||||
|
||||
|
||||
#================================================
|
||||
# Installed files.
|
||||
#================================================
|
||||
|
||||
# Install the contents of all of the .pretty folders in to the modules path.
|
||||
install( DIRECTORY ./
|
||||
DESTINATION ${KICAD_MODULES}
|
||||
COMPONENT resources
|
||||
FILES_MATCHING PATTERN "*.kicad_mod"
|
||||
PATTERN ".git" EXCLUDE
|
||||
)
|
||||
|
||||
# Install the default global footprint library table in the template folder.
|
||||
install( FILES fp-lib-table
|
||||
DESTINATION ${KICAD_TEMPLATE}
|
||||
COMPONENT resources
|
||||
)
|
22
CMakeModules/cmake_uninstall.cmake.in
Normal file
22
CMakeModules/cmake_uninstall.cmake.in
Normal file
@ -0,0 +1,22 @@
|
||||
if( NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" )
|
||||
message( FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"" )
|
||||
endif()
|
||||
|
||||
file( READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files )
|
||||
string( REGEX REPLACE "\n" ";" files "${files}" )
|
||||
|
||||
foreach( file ${files} )
|
||||
message( STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"" )
|
||||
if( EXISTS "$ENV{DESTDIR}${file}" )
|
||||
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( STATUS "Problem when removing \"$ENV{DESTDIR}${file}\"" )
|
||||
endif()
|
||||
else()
|
||||
message( STATUS "File \"$ENV{DESTDIR}${file}\" does not exist." )
|
||||
endif()
|
||||
endforeach()
|
Loading…
Reference in New Issue
Block a user