xref: /aosp_15_r20/external/cpu_features/CMakeLists.txt (revision eca53ba6d2e951e174b64682eaf56a36b8204c89)
1*eca53ba6SRoland Levillaincmake_minimum_required(VERSION 3.13)
2*eca53ba6SRoland Levillain
3*eca53ba6SRoland Levillain# option() honors normal variables.
4*eca53ba6SRoland Levillain# see: https://cmake.org/cmake/help/git-stage/policy/CMP0077.html
5*eca53ba6SRoland Levillainif(POLICY CMP0077)
6*eca53ba6SRoland Levillain  cmake_policy(SET CMP0077 NEW)
7*eca53ba6SRoland Levillainendif()
8*eca53ba6SRoland Levillain
9*eca53ba6SRoland Levillainproject(CpuFeatures VERSION 0.9.0 LANGUAGES C)
10*eca53ba6SRoland Levillain
11*eca53ba6SRoland Levillainset(CMAKE_C_STANDARD 99)
12*eca53ba6SRoland Levillain
13*eca53ba6SRoland Levillain# when cpu_features is included as subproject (i.e. using add_subdirectory(cpu_features))
14*eca53ba6SRoland Levillain# in the source tree of a project that uses it, test rules are disabled.
15*eca53ba6SRoland Levillainif(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
16*eca53ba6SRoland Levillain  option(BUILD_TESTING "Enable test rule" OFF)
17*eca53ba6SRoland Levillainelse()
18*eca53ba6SRoland Levillain  option(BUILD_TESTING "Enable test rule" ON)
19*eca53ba6SRoland Levillainendif()
20*eca53ba6SRoland Levillain
21*eca53ba6SRoland Levillain# Default Build Type to be Release
22*eca53ba6SRoland Levillainif(NOT CMAKE_BUILD_TYPE)
23*eca53ba6SRoland Levillain  set(CMAKE_BUILD_TYPE "Release" CACHE STRING
24*eca53ba6SRoland Levillain      "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
25*eca53ba6SRoland Levillain      FORCE)
26*eca53ba6SRoland Levillainendif(NOT CMAKE_BUILD_TYPE)
27*eca53ba6SRoland Levillain
28*eca53ba6SRoland Levillain# An option to enable/disable the executable target list_cpu_features.
29*eca53ba6SRoland Levillain# Disable it by default if the project is included as a subproject.
30*eca53ba6SRoland Levillainif(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
31*eca53ba6SRoland Levillain  option(BUILD_EXECUTABLE "Build list_cpu_features executable." OFF)
32*eca53ba6SRoland Levillainelse()
33*eca53ba6SRoland Levillain  option(BUILD_EXECUTABLE "Build list_cpu_features executable." ON)
34*eca53ba6SRoland Levillainendif()
35*eca53ba6SRoland Levillain
36*eca53ba6SRoland Levillain# An option which allows to switch off install steps. Useful for embedding.
37*eca53ba6SRoland Levillain# Disable it by default if the project is included as a subproject.
38*eca53ba6SRoland Levillainif(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
39*eca53ba6SRoland Levillain  option(ENABLE_INSTALL "Enable install targets" OFF)
40*eca53ba6SRoland Levillainelse()
41*eca53ba6SRoland Levillain  option(ENABLE_INSTALL "Enable install targets" ON)
42*eca53ba6SRoland Levillainendif()
43*eca53ba6SRoland Levillain
44*eca53ba6SRoland Levillain# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make
45*eca53ba6SRoland Levillain# it prominent in the GUI.
46*eca53ba6SRoland Levillain# cpu_features uses bit-fields which are - to some extends - implementation-defined (see https://en.cppreference.com/w/c/language/bit_field).
47*eca53ba6SRoland Levillain# As a consequence it is discouraged to use cpu_features as a shared library because different compilers may interpret the code in different ways.
48*eca53ba6SRoland Levillain# Prefer static linking from source whenever possible.
49*eca53ba6SRoland Levillainoption(BUILD_SHARED_LIBS "Build library as shared." OFF)
50*eca53ba6SRoland Levillain
51*eca53ba6SRoland Levillain# Force PIC on unix when building shared libs
52*eca53ba6SRoland Levillain# see: https://en.wikipedia.org/wiki/Position-independent_code
53*eca53ba6SRoland Levillainif(BUILD_SHARED_LIBS AND UNIX)
54*eca53ba6SRoland Levillain  option(CMAKE_POSITION_INDEPENDENT_CODE "Build with Position Independant Code." ON)
55*eca53ba6SRoland Levillainendif()
56*eca53ba6SRoland Levillain
57*eca53ba6SRoland Levillaininclude(CheckIncludeFile)
58*eca53ba6SRoland Levillaininclude(CheckSymbolExists)
59*eca53ba6SRoland Levillaininclude(GNUInstallDirs)
60*eca53ba6SRoland Levillain
61*eca53ba6SRoland Levillainmacro(setup_include_and_definitions TARGET_NAME)
62*eca53ba6SRoland Levillain  target_include_directories(${TARGET_NAME}
63*eca53ba6SRoland Levillain    PUBLIC  $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
64*eca53ba6SRoland Levillain    PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/internal>
65*eca53ba6SRoland Levillain  )
66*eca53ba6SRoland Levillain  target_compile_definitions(${TARGET_NAME}
67*eca53ba6SRoland Levillain    PUBLIC STACK_LINE_READER_BUFFER_SIZE=1024
68*eca53ba6SRoland Levillain  )
69*eca53ba6SRoland Levillainendmacro()
70*eca53ba6SRoland Levillain
71*eca53ba6SRoland Levillainset(PROCESSOR_IS_MIPS FALSE)
72*eca53ba6SRoland Levillainset(PROCESSOR_IS_ARM FALSE)
73*eca53ba6SRoland Levillainset(PROCESSOR_IS_AARCH64 FALSE)
74*eca53ba6SRoland Levillainset(PROCESSOR_IS_X86 FALSE)
75*eca53ba6SRoland Levillainset(PROCESSOR_IS_POWER FALSE)
76*eca53ba6SRoland Levillainset(PROCESSOR_IS_S390X FALSE)
77*eca53ba6SRoland Levillainset(PROCESSOR_IS_RISCV FALSE)
78*eca53ba6SRoland Levillainset(PROCESSOR_IS_LOONGARCH FALSE)
79*eca53ba6SRoland Levillain
80*eca53ba6SRoland Levillainif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
81*eca53ba6SRoland Levillain  set(PROCESSOR_IS_MIPS TRUE)
82*eca53ba6SRoland Levillainelseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(^aarch64)|(^arm64)|(^ARM64)")
83*eca53ba6SRoland Levillain  set(PROCESSOR_IS_AARCH64 TRUE)
84*eca53ba6SRoland Levillainelseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
85*eca53ba6SRoland Levillain  set(PROCESSOR_IS_ARM TRUE)
86*eca53ba6SRoland Levillainelseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(x86_64)|(AMD64|amd64)|(^i.86$)")
87*eca53ba6SRoland Levillain  set(PROCESSOR_IS_X86 TRUE)
88*eca53ba6SRoland Levillainelseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
89*eca53ba6SRoland Levillain  set(PROCESSOR_IS_POWER TRUE)
90*eca53ba6SRoland Levillainelseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x)")
91*eca53ba6SRoland Levillain  set(PROCESSOR_IS_S390X TRUE)
92*eca53ba6SRoland Levillainelseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv")
93*eca53ba6SRoland Levillain  set(PROCESSOR_IS_RISCV TRUE)
94*eca53ba6SRoland Levillainelseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch")
95*eca53ba6SRoland Levillain  set(PROCESSOR_IS_LOONGARCH TRUE)
96*eca53ba6SRoland Levillainendif()
97*eca53ba6SRoland Levillain
98*eca53ba6SRoland Levillainmacro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME)
99*eca53ba6SRoland Levillain  list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpu_features_macros.h)
100*eca53ba6SRoland Levillain  list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpu_features_cache_info.h)
101*eca53ba6SRoland Levillain  file(GLOB IMPL_SOURCES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/impl_*.c")
102*eca53ba6SRoland Levillain  list(APPEND ${SRCS_LIST_NAME} ${IMPL_SOURCES})
103*eca53ba6SRoland Levillain  if(PROCESSOR_IS_MIPS)
104*eca53ba6SRoland Levillain      list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_mips.h)
105*eca53ba6SRoland Levillain  elseif(PROCESSOR_IS_ARM)
106*eca53ba6SRoland Levillain      list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_arm.h)
107*eca53ba6SRoland Levillain  elseif(PROCESSOR_IS_AARCH64)
108*eca53ba6SRoland Levillain      list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_aarch64.h)
109*eca53ba6SRoland Levillain      list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/internal/windows_utils.h)
110*eca53ba6SRoland Levillain  elseif(PROCESSOR_IS_X86)
111*eca53ba6SRoland Levillain      list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_x86.h)
112*eca53ba6SRoland Levillain      list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/internal/cpuid_x86.h)
113*eca53ba6SRoland Levillain      list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/internal/windows_utils.h)
114*eca53ba6SRoland Levillain  elseif(PROCESSOR_IS_POWER)
115*eca53ba6SRoland Levillain      list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_ppc.h)
116*eca53ba6SRoland Levillain  elseif(PROCESSOR_IS_S390X)
117*eca53ba6SRoland Levillain      list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_s390x.h)
118*eca53ba6SRoland Levillain  elseif(PROCESSOR_IS_RISCV)
119*eca53ba6SRoland Levillain      list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_riscv.h)
120*eca53ba6SRoland Levillain  elseif(PROCESSOR_IS_LOONGARCH)
121*eca53ba6SRoland Levillain      list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_loongarch.h)
122*eca53ba6SRoland Levillain  else()
123*eca53ba6SRoland Levillain    message(FATAL_ERROR "Unsupported architectures ${CMAKE_SYSTEM_PROCESSOR}")
124*eca53ba6SRoland Levillain  endif()
125*eca53ba6SRoland Levillainendmacro()
126*eca53ba6SRoland Levillain
127*eca53ba6SRoland Levillain#
128*eca53ba6SRoland Levillain# library : utils
129*eca53ba6SRoland Levillain#
130*eca53ba6SRoland Levillain
131*eca53ba6SRoland Levillainadd_library(utils OBJECT
132*eca53ba6SRoland Levillain  ${PROJECT_SOURCE_DIR}/include/internal/bit_utils.h
133*eca53ba6SRoland Levillain  ${PROJECT_SOURCE_DIR}/include/internal/filesystem.h
134*eca53ba6SRoland Levillain  ${PROJECT_SOURCE_DIR}/include/internal/stack_line_reader.h
135*eca53ba6SRoland Levillain  ${PROJECT_SOURCE_DIR}/include/internal/string_view.h
136*eca53ba6SRoland Levillain  ${PROJECT_SOURCE_DIR}/src/filesystem.c
137*eca53ba6SRoland Levillain  ${PROJECT_SOURCE_DIR}/src/stack_line_reader.c
138*eca53ba6SRoland Levillain  ${PROJECT_SOURCE_DIR}/src/string_view.c
139*eca53ba6SRoland Levillain)
140*eca53ba6SRoland Levillainsetup_include_and_definitions(utils)
141*eca53ba6SRoland Levillain
142*eca53ba6SRoland Levillain#
143*eca53ba6SRoland Levillain# library : unix_based_hardware_detection
144*eca53ba6SRoland Levillain#
145*eca53ba6SRoland Levillain
146*eca53ba6SRoland Levillainif(UNIX)
147*eca53ba6SRoland Levillain  add_library(unix_based_hardware_detection OBJECT
148*eca53ba6SRoland Levillain    ${PROJECT_SOURCE_DIR}/include/internal/hwcaps.h
149*eca53ba6SRoland Levillain    ${PROJECT_SOURCE_DIR}/src/hwcaps.c
150*eca53ba6SRoland Levillain  )
151*eca53ba6SRoland Levillain  setup_include_and_definitions(unix_based_hardware_detection)
152*eca53ba6SRoland Levillain  check_include_file(dlfcn.h HAVE_DLFCN_H)
153*eca53ba6SRoland Levillain  if(HAVE_DLFCN_H)
154*eca53ba6SRoland Levillain    target_compile_definitions(unix_based_hardware_detection PRIVATE HAVE_DLFCN_H)
155*eca53ba6SRoland Levillain  endif()
156*eca53ba6SRoland Levillain  check_symbol_exists(getauxval "sys/auxv.h" HAVE_STRONG_GETAUXVAL)
157*eca53ba6SRoland Levillain  if(HAVE_STRONG_GETAUXVAL)
158*eca53ba6SRoland Levillain    target_compile_definitions(unix_based_hardware_detection PRIVATE HAVE_STRONG_GETAUXVAL)
159*eca53ba6SRoland Levillain  endif()
160*eca53ba6SRoland Levillainendif()
161*eca53ba6SRoland Levillain
162*eca53ba6SRoland Levillain#
163*eca53ba6SRoland Levillain# library : cpu_features
164*eca53ba6SRoland Levillain#
165*eca53ba6SRoland Levillainset (CPU_FEATURES_HDRS)
166*eca53ba6SRoland Levillainset (CPU_FEATURES_SRCS)
167*eca53ba6SRoland Levillainadd_cpu_features_headers_and_sources(CPU_FEATURES_HDRS CPU_FEATURES_SRCS)
168*eca53ba6SRoland Levillainlist(APPEND CPU_FEATURES_SRCS $<TARGET_OBJECTS:utils>)
169*eca53ba6SRoland Levillainif(NOT PROCESSOR_IS_X86 AND UNIX)
170*eca53ba6SRoland Levillain  list(APPEND CPU_FEATURES_SRCS $<TARGET_OBJECTS:unix_based_hardware_detection>)
171*eca53ba6SRoland Levillainendif()
172*eca53ba6SRoland Levillainadd_library(cpu_features ${CPU_FEATURES_HDRS} ${CPU_FEATURES_SRCS})
173*eca53ba6SRoland Levillainset_target_properties(cpu_features PROPERTIES PUBLIC_HEADER "${CPU_FEATURES_HDRS}")
174*eca53ba6SRoland Levillainsetup_include_and_definitions(cpu_features)
175*eca53ba6SRoland Levillaintarget_link_libraries(cpu_features PUBLIC ${CMAKE_DL_LIBS})
176*eca53ba6SRoland Levillaintarget_include_directories(cpu_features
177*eca53ba6SRoland Levillain  PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cpu_features>
178*eca53ba6SRoland Levillain)
179*eca53ba6SRoland Levillain
180*eca53ba6SRoland Levillainif(APPLE)
181*eca53ba6SRoland Levillain  target_compile_definitions(cpu_features PRIVATE HAVE_SYSCTLBYNAME)
182*eca53ba6SRoland Levillainendif()
183*eca53ba6SRoland Levillainadd_library(CpuFeatures::cpu_features ALIAS cpu_features)
184*eca53ba6SRoland Levillain
185*eca53ba6SRoland Levillain#
186*eca53ba6SRoland Levillain# program : list_cpu_features
187*eca53ba6SRoland Levillain#
188*eca53ba6SRoland Levillain
189*eca53ba6SRoland Levillainif(BUILD_EXECUTABLE)
190*eca53ba6SRoland Levillain  add_executable(list_cpu_features ${PROJECT_SOURCE_DIR}/src/utils/list_cpu_features.c)
191*eca53ba6SRoland Levillain  target_link_libraries(list_cpu_features PRIVATE cpu_features)
192*eca53ba6SRoland Levillain  add_executable(CpuFeatures::list_cpu_features ALIAS list_cpu_features)
193*eca53ba6SRoland Levillainendif()
194*eca53ba6SRoland Levillain
195*eca53ba6SRoland Levillain#
196*eca53ba6SRoland Levillain# ndk_compat
197*eca53ba6SRoland Levillain#
198*eca53ba6SRoland Levillain
199*eca53ba6SRoland Levillainif(ANDROID)
200*eca53ba6SRoland Levillainadd_subdirectory(ndk_compat)
201*eca53ba6SRoland Levillainendif()
202*eca53ba6SRoland Levillain
203*eca53ba6SRoland Levillain#
204*eca53ba6SRoland Levillain# tests
205*eca53ba6SRoland Levillain#
206*eca53ba6SRoland Levillain
207*eca53ba6SRoland Levillaininclude(CTest)
208*eca53ba6SRoland Levillainif(BUILD_TESTING)
209*eca53ba6SRoland Levillain  # Automatically incorporate googletest into the CMake Project if target not
210*eca53ba6SRoland Levillain  # found.
211*eca53ba6SRoland Levillain  enable_language(CXX)
212*eca53ba6SRoland Levillain
213*eca53ba6SRoland Levillain  set(CMAKE_CXX_STANDARD 14)
214*eca53ba6SRoland Levillain  set(CMAKE_CXX_STANDARD_REQUIRED ON)
215*eca53ba6SRoland Levillain  set(CMAKE_CXX_EXTENSIONS OFF) # prefer use of -std14 instead of -gnustd14
216*eca53ba6SRoland Levillain
217*eca53ba6SRoland Levillain  if(NOT TARGET gtest OR NOT TARGET gmock_main)
218*eca53ba6SRoland Levillain    # Download and unpack googletest at configure time.
219*eca53ba6SRoland Levillain    configure_file(
220*eca53ba6SRoland Levillain      cmake/googletest.CMakeLists.txt.in
221*eca53ba6SRoland Levillain      googletest-download/CMakeLists.txt
222*eca53ba6SRoland Levillain    )
223*eca53ba6SRoland Levillain
224*eca53ba6SRoland Levillain    execute_process(
225*eca53ba6SRoland Levillain      COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
226*eca53ba6SRoland Levillain      RESULT_VARIABLE result
227*eca53ba6SRoland Levillain      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download)
228*eca53ba6SRoland Levillain
229*eca53ba6SRoland Levillain    if(result)
230*eca53ba6SRoland Levillain      message(FATAL_ERROR "CMake step for googletest failed: ${result}")
231*eca53ba6SRoland Levillain    endif()
232*eca53ba6SRoland Levillain
233*eca53ba6SRoland Levillain    execute_process(
234*eca53ba6SRoland Levillain      COMMAND ${CMAKE_COMMAND} --build .
235*eca53ba6SRoland Levillain      RESULT_VARIABLE result
236*eca53ba6SRoland Levillain      WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download)
237*eca53ba6SRoland Levillain
238*eca53ba6SRoland Levillain    if(result)
239*eca53ba6SRoland Levillain      message(FATAL_ERROR "Build step for googletest failed: ${result}")
240*eca53ba6SRoland Levillain    endif()
241*eca53ba6SRoland Levillain
242*eca53ba6SRoland Levillain    # Prevent overriding the parent project's compiler/linker settings on
243*eca53ba6SRoland Levillain    # Windows.
244*eca53ba6SRoland Levillain    set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
245*eca53ba6SRoland Levillain
246*eca53ba6SRoland Levillain    # Add googletest directly to our build. This defines the gtest and
247*eca53ba6SRoland Levillain    # gtest_main targets.
248*eca53ba6SRoland Levillain    add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
249*eca53ba6SRoland Levillain                     ${CMAKE_BINARY_DIR}/googletest-build
250*eca53ba6SRoland Levillain                     EXCLUDE_FROM_ALL)
251*eca53ba6SRoland Levillain  endif()
252*eca53ba6SRoland Levillain
253*eca53ba6SRoland Levillain  add_subdirectory(test)
254*eca53ba6SRoland Levillainendif()
255*eca53ba6SRoland Levillain
256*eca53ba6SRoland Levillain#
257*eca53ba6SRoland Levillain# Install cpu_features and list_cpu_features
258*eca53ba6SRoland Levillain#
259*eca53ba6SRoland Levillainif(ENABLE_INSTALL)
260*eca53ba6SRoland Levillain  include(GNUInstallDirs)
261*eca53ba6SRoland Levillain  install(TARGETS cpu_features
262*eca53ba6SRoland Levillain    EXPORT CpuFeaturesTargets
263*eca53ba6SRoland Levillain    PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpu_features
264*eca53ba6SRoland Levillain    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
265*eca53ba6SRoland Levillain    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
266*eca53ba6SRoland Levillain    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
267*eca53ba6SRoland Levillain    BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
268*eca53ba6SRoland Levillain  )
269*eca53ba6SRoland Levillain  if(BUILD_EXECUTABLE)
270*eca53ba6SRoland Levillain    install(TARGETS list_cpu_features
271*eca53ba6SRoland Levillain      EXPORT CpuFeaturesTargets
272*eca53ba6SRoland Levillain      PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpu_features
273*eca53ba6SRoland Levillain      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
274*eca53ba6SRoland Levillain      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
275*eca53ba6SRoland Levillain      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
276*eca53ba6SRoland Levillain      BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
277*eca53ba6SRoland Levillain    )
278*eca53ba6SRoland Levillain  endif()
279*eca53ba6SRoland Levillain  install(EXPORT CpuFeaturesTargets
280*eca53ba6SRoland Levillain    NAMESPACE CpuFeatures::
281*eca53ba6SRoland Levillain    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures
282*eca53ba6SRoland Levillain    COMPONENT Devel
283*eca53ba6SRoland Levillain  )
284*eca53ba6SRoland Levillain  include(CMakePackageConfigHelpers)
285*eca53ba6SRoland Levillain  configure_package_config_file(cmake/CpuFeaturesConfig.cmake.in
286*eca53ba6SRoland Levillain    "${PROJECT_BINARY_DIR}/CpuFeaturesConfig.cmake"
287*eca53ba6SRoland Levillain    INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures"
288*eca53ba6SRoland Levillain    NO_SET_AND_CHECK_MACRO
289*eca53ba6SRoland Levillain    NO_CHECK_REQUIRED_COMPONENTS_MACRO
290*eca53ba6SRoland Levillain  )
291*eca53ba6SRoland Levillain  write_basic_package_version_file(
292*eca53ba6SRoland Levillain    "${PROJECT_BINARY_DIR}/CpuFeaturesConfigVersion.cmake"
293*eca53ba6SRoland Levillain    COMPATIBILITY SameMajorVersion
294*eca53ba6SRoland Levillain  )
295*eca53ba6SRoland Levillain  install(
296*eca53ba6SRoland Levillain    FILES
297*eca53ba6SRoland Levillain      "${PROJECT_BINARY_DIR}/CpuFeaturesConfig.cmake"
298*eca53ba6SRoland Levillain      "${PROJECT_BINARY_DIR}/CpuFeaturesConfigVersion.cmake"
299*eca53ba6SRoland Levillain    DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures"
300*eca53ba6SRoland Levillain    COMPONENT Devel
301*eca53ba6SRoland Levillain  )
302*eca53ba6SRoland Levillainendif()
303