Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

cmake: support find_package(psimd) #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR)

INCLUDE(GNUInstallDirs)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're in here it'd be good to move this include to after PROJECT since the GNUInstallDirs module uses platform information initialized by PROJECT to determine the default lib directory:

CMake Warning (dev) at /opt/cmake/3.27.7/share/cmake-3.27/Modules/GNUInstallDirs.cmake:243 (message):
  Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
  target architecture is known.  Please enable at least one language before
  including GNUInstallDirs.
Call Stack (most recent call first):
  CMakeLists.txt:3 (INCLUDE)
This warning is for project developers.  Use -Wno-dev to suppress it.


# ---[ Project
PROJECT(psimd C)

# ---[ psimd library
IF(${CMAKE_VERSION} VERSION_LESS "3.0")
ADD_LIBRARY(psimd STATIC include/psimd.h)
SET_TARGET_PROPERTIES(psimd PROPERTIES LINKER_LANGUAGE C)
ELSE()
ADD_LIBRARY(psimd INTERFACE)
ENDIF()
TARGET_INCLUDE_DIRECTORIES(psimd INTERFACE include)
ADD_LIBRARY(psimd INTERFACE)
TARGET_INCLUDE_DIRECTORIES(psimd INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

INSTALL(FILES include/psimd.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
INCLUDE(CMakePackageConfigHelpers)
CONFIGURE_PACKAGE_CONFIG_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
)

INSTALL(TARGETS psimd EXPORT ${CMAKE_PROJECT_NAME}Targets)
INSTALL(EXPORT ${CMAKE_PROJECT_NAME}Targets
FILE ${CMAKE_PROJECT_NAME}-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
)
INSTALL(DIRECTORY include/ DESTINATION include)
5 changes: 5 additions & 0 deletions cmake/psimd-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/psimdTargets.cmake")

check_required_components(psimd)