Skip to content

Commit

Permalink
Add CMake export target feature for MIPP
Browse files Browse the repository at this point in the history
  • Loading branch information
fpruvost committed Oct 26, 2023
1 parent be3bd60 commit cd97791
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 5 deletions.
33 changes: 29 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(MY_INTRINSICS_PLUS_PLUS CXX)

set(CMAKE_CXX_STANDARD 11)
Expand Down Expand Up @@ -29,15 +29,40 @@ set( MIPP_MATH_HEADERS

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

install( FILES ${MIPP_HEADERS} DESTINATION include/mipp)
install( FILES ${MIPP_MATH_HEADERS} DESTINATION include/mipp/math)
# Install headers files
install( FILES ${MIPP_HEADERS} DESTINATION include/mipp)
install( FILES ${MIPP_MATH_HEADERS} DESTINATION include/mipp/math)

# Create the header only library in the cmake sense
add_library(mipp INTERFACE)
target_compile_definitions(mipp INTERFACE HAVE_MIPP=1)
target_compile_features(mipp INTERFACE cxx_std_11)
target_include_directories(mipp INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include/mipp>)

# Target export
install(EXPORT mippTargets
NAMESPACE MIPP::
DESTINATION lib/cmake/mipp)
# Install targets file
install(TARGETS mipp EXPORT mippTargets)
# Prepare the MIPPConfig.cmake file to be installed for users
include(CMakePackageConfigHelpers)
set(INC_INSTALL_DIR "include/mipp" CACHE STRING "where to install headers relative to prefix" )
configure_package_config_file(cmake/MIPPConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/MIPPConfig.cmake
INSTALL_DESTINATION lib/cmake/mipp
PATH_VARS INC_INSTALL_DIR)
# Install MIPPConfig.cmake
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MIPPConfig.cmake
DESTINATION lib/cmake/mipp)

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

add_custom_target(uninstall
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,37 @@ compliant). However, this is no more the case on ARMv8 processors, so the
by the C++11 and so we have to add the `-std=c++11` flag to compile the code.
You are now ready to run your code with the MIPP wrapper.

In the case where MIPP is installed on the system it can be integrated into a
cmake projet in a standard way. Example
```sh
# install MIPP
cd MIPP/
export MIPP_ROOT=$PWD/build/install
cmake -B build -DCMAKE_INSTALL_PREFIX=$MIPP_ROOT
cmake --build build -j5
cmake --install build
```

In your `CMakeLists.txt`:
```cmake
# find the installation of MIPP on the system
find_package(MIPP REQUIRED)
# define your executable
add_executable(gemm gemm.cpp)
# link your executable to MIPP
target_link_libraries(gemm PRIVATE MIPP::mipp)
```

```sh
cd your_project/
# if MIPP is installed in a system standard path: MIPP will be found automatically with cmake
cmake -B build
# if MIPP is installed in a non-standard path: use CMAKE_PREFIX_PATH
cmake -B build -DCMAKE_PREFIX_PATH=$MIPP_ROOT
```

### Sequential Mode

By default, MIPP tries to recognize the instruction set from the preprocessor
Expand Down
8 changes: 8 additions & 0 deletions cmake/MIPPConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(MIPP_VERSION @MIPP_VERSION@)

@PACKAGE_INIT@

set_and_check(MIPP_INC_DIR "@PACKAGE_INC_INSTALL_DIR@")

# Add the targets file
include("${CMAKE_CURRENT_LIST_DIR}/mippTargets.cmake")
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.5)

project(MIPP_tests CXX)

Expand Down

0 comments on commit cd97791

Please sign in to comment.