Skip to content

Commit

Permalink
allow installation and uninstall in ${HOME}/.local, updated README
Browse files Browse the repository at this point in the history
* no need to compile test program for install
* added custom target test
* provide a FindMIPP.cmake for copy/paste from other projects

Signed-off-by: hayati ayguen <[email protected]>
  • Loading branch information
hayguen committed Mar 22, 2022
1 parent 0a81e4e commit ec2fa3a
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 25 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ set( MIPP_MATH_HEADERS
install( FILES ${MIPP_HEADERS} DESTINATION include/mipp)
install( FILES ${MIPP_MATH_HEADERS} DESTINATION include/mipp/math)


# Create uninstall target
configure_file(
${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
@ONLY)

add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake"
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)

######################################################
Expand Down
26 changes: 26 additions & 0 deletions FindMIPP.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

if(MIPP_INCLUDE_DIRS)
set(MIPP_FIND_QUIETLY TRUE)
endif()

find_path(MIPP_INCLUDE_DIRS NAMES mipp.h
HINTS
${MIPP_ROOT}
$ENV{HOME}/.local
PATH_SUFFIXES include/mipp
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MIPP DEFAULT_MSG MIPP_INCLUDE_DIRS)

if(MIPP_FOUND AND NOT TARGET MIPP)
message(STATUS "MIPP_FOUND -> creating interface library MIPP at ${MIPP_INCLUDE_DIRS}")
add_library(MIPP INTERFACE)
target_compile_definitions(MIPP INTERFACE HAVE_MIPP=1)
target_include_directories(MIPP INTERFACE ${MIPP_INCLUDE_DIRS})
target_compile_features(MIPP INTERFACE cxx_std_11)
else()
message(WARNING "MIPP not found.")
endif()

mark_as_advanced(MIPP_INCLUDE_DIRS)
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,30 @@ MIPP also use some nice features provided by the C++11 and so we have to add the
`-std=c++11` flag to compile the code. Your are now ready to run your code with
the mipp.h wrapper.


You can install the header files (locally) to allow finding them
with cmake's `find_package()`:

```
git clone https://github.com/hayguen/MIPP.git
cmake -S MIPP -B MIPP_build -DCMAKE_INSTALL_PREFIX=$HOME/.local
cmake -S MIPP -B MIPP_build # alternative installs into system, defaults to /usr/local
cmake --build MIPP_build --target install # might require sudo
```

for building and running the tests

```
cmake --build MIPP_build --target test
```

for later uninstall:

```
cmake --build MIPP_build --target uninstall
```


### Sequential mode

By default, MIPP try to recognize the instruction set from the preprocessor
Expand Down
32 changes: 32 additions & 0 deletions cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 0 additions & 24 deletions cmake/uninstall.cmake

This file was deleted.

11 changes: 11 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,14 @@ target_set_mipp_intrinsics(run_tests) # allow deactivation of mipp
# target_activate_cxx_compiler_warnings(run_tests) # too many warning

set_target_properties(run_tests PROPERTIES POSITION_INDEPENDENT_CODE ON) # set -fpie

# no need to compile test program for install
set_target_properties(run_tests PROPERTIES EXCLUDE_FROM_ALL TRUE)

######################################################

add_custom_target(test
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/bin/run_tests"
DEPENDS run_tests
)

0 comments on commit ec2fa3a

Please sign in to comment.