From a9313c6e7994d5bb175815905993f53fc8507623 Mon Sep 17 00:00:00 2001 From: Elliot Briggs Date: Wed, 25 Feb 2015 20:27:46 +0000 Subject: [PATCH] adding install rules to CMakeLists.txt for Linux platforms --- CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++ cmake/cmake_uninstall.cmake.in | 32 ++++++++++++++++++ modules/CMakeLists.txt | 5 ++- ne10.pc.in | 13 ++++++++ 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 cmake/cmake_uninstall.cmake.in create mode 100644 ne10.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index ed8b498c..a250647e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,3 +176,62 @@ endif() if(IOS_PLATFORM AND IOS_DEMO) add_subdirectory(ios) endif() + +if(GNULINUX_PLATFORM) + # package config + set(prefix ${CMAKE_INSTALL_PREFIX}) + set(exec_prefix "\${prefix}") + set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}") + set(includedir "\${prefix}/include") + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/ne10.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/ne10.pc + @ONLY) + + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/ne10.pc + DESTINATION lib${LIB_SUFFIX}/pkgconfig) + + # install rules + install( DIRECTORY inc/ + DESTINATION include/ne10 + FILES_MATCHING PATTERN "*.h") + install( DIRECTORY common/ + DESTINATION include/ne10 + FILES_MATCHING PATTERN "*.h") + + if(NE10_ENABLE_DSP) + install( DIRECTORY modules/dsp/ + DESTINATION include/ne10/dsp + FILES_MATCHING PATTERN "*.h") + endif() + + if(NE10_ENABLE_MATH) + install( DIRECTORY modules/math/ + DESTINATION include/ne10/math + FILES_MATCHING PATTERN "*.h") + endif() + + if(NE10_ENABLE_IMGPROC) + install( DIRECTORY modules/imgproc/ + DESTINATION include/ne10/imgproc + FILES_MATCHING PATTERN "*.h") + endif() + + if(NE10_ENABLE_PHYSICS) + install( DIRECTORY modules/physics/ + DESTINATION include/ne10/physics + FILES_MATCHING PATTERN "*.h") + endif() + # uninstall rules + configure_file( + ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake + @ONLY) + + add_custom_target(uninstall + ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake + ) +endif() + diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in new file mode 100644 index 00000000..9ae1ae4b --- /dev/null +++ b/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,32 @@ +# http://www.vtk.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F + +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(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +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(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + ENDIF(NOT "${rm_retval}" STREQUAL 0) + ELSEIF(IS_SYMLINK "$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(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + ENDIF(NOT "${rm_retval}" STREQUAL 0) + ELSE(EXISTS "$ENV{DESTDIR}${file}") + MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + ENDIF(EXISTS "$ENV{DESTDIR}${file}") +ENDFOREACH(file) diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 58e5c6ed..f17d6a73 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -372,6 +372,8 @@ if(NE10_BUILD_STATIC OR ANDROID_PLATFORM OR IOS_DEMO) VERSION ${NE10_VERSION} ) + install(TARGETS NE10 DESTINATION lib) + if(IOS_DEMO) install(TARGETS NE10 DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../ios/NE10Demo/libs/) @@ -409,5 +411,6 @@ if(NE10_BUILD_SHARED) ) target_link_libraries(NE10_test m) - + install(TARGETS NE10_shared DESTINATION lib) + endif() diff --git a/ne10.pc.in b/ne10.pc.in new file mode 100644 index 00000000..6c22e486 --- /dev/null +++ b/ne10.pc.in @@ -0,0 +1,13 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +LV_CXXFLAGS=@LV_CXXFLAGS@ + + +Name: ne10 +Description: Ne10: An open optimized software library project for the ARMĀ® Architecture +Requires: +Version: @LIBVER@ +Libs: -L${libdir} -lne10 +Cflags: -I${includedir} ${LV_CXXFLAGS}