1
0
mirror of https://github.com/microsoft/DirectXMath synced 2024-11-22 04:10:06 +00:00
DirectXMath/CMakeLists.txt

120 lines
4.0 KiB
CMake
Raw Normal View History

2021-02-27 07:17:26 +00:00
# Copyright (c) Microsoft Corporation.
2020-12-19 21:18:06 +00:00
# Licensed under the MIT License.
2022-11-22 19:21:24 +00:00
cmake_minimum_required (VERSION 3.20)
2020-12-19 21:18:06 +00:00
set(DIRECTXMATH_VERSION 3.19)
2020-12-19 21:18:06 +00:00
project(DirectXMath
VERSION ${DIRECTXMATH_VERSION}
DESCRIPTION "DirectXMath SIMD C++ math library"
HOMEPAGE_URL "https://go.microsoft.com/fwlink/?LinkID=615560"
LANGUAGES CXX)
2022-05-02 10:40:03 +00:00
include(GNUInstallDirs)
2020-12-19 21:18:06 +00:00
#--- Library
set(LIBRARY_HEADERS
Inc/DirectXCollision.h
Inc/DirectXCollision.inl
Inc/DirectXColors.h
Inc/DirectXMath.h
Inc/DirectXMathConvert.inl
Inc/DirectXMathMatrix.inl
Inc/DirectXMathMisc.inl
Inc/DirectXMathVector.inl
Inc/DirectXPackedVector.h
Inc/DirectXPackedVector.inl)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Inc>
2022-06-03 07:43:12 +00:00
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/directxmath>)
2020-12-19 21:18:06 +00:00
2022-05-31 00:13:34 +00:00
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11)
2020-12-19 21:18:06 +00:00
#--- Package
include(CMakePackageConfigHelpers)
string(TOLOWER ${PROJECT_NAME} PACKAGE_NAME)
2020-12-19 21:18:06 +00:00
write_basic_package_version_file(
2022-05-02 10:40:03 +00:00
${PACKAGE_NAME}-config-version.cmake
2020-12-19 21:18:06 +00:00
VERSION ${DIRECTXMATH_VERSION}
2022-06-03 07:43:12 +00:00
COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT)
2020-12-19 21:18:06 +00:00
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
2022-05-02 10:40:03 +00:00
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2020-12-19 21:18:06 +00:00
2022-12-05 08:00:28 +00:00
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/build/${PROJECT_NAME}-config.cmake.in
2022-05-02 10:40:03 +00:00
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
2022-06-03 07:43:12 +00:00
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
2020-12-19 21:18:06 +00:00
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE Microsoft::
2022-06-03 07:43:12 +00:00
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
2020-12-19 21:18:06 +00:00
install(FILES ${LIBRARY_HEADERS}
2022-06-03 07:43:12 +00:00
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/directxmath)
2020-12-19 21:18:06 +00:00
2022-05-02 10:40:03 +00:00
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake
2022-06-03 07:43:12 +00:00
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
2022-11-22 19:21:24 +00:00
2023-12-21 07:05:46 +00:00
# Create pkg-config file
include(build/JoinPaths.cmake)
# from: https://github.com/jtojnar/cmake-snips#concatenating-paths-when-building-pkg-config-files
join_paths(DIRECTXMATH_INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}/directxmath")
2023-12-21 07:05:46 +00:00
join_paths(DIRECTXMATH_LIBDIR_FOR_PKG_CONFIG "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/build/DirectXMath.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/DirectXMath.pc" @ONLY)
# Install the pkg-config file
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DirectXMath.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
2022-11-22 19:21:24 +00:00
#--- Test suite
2024-02-09 18:13:58 +00:00
if(DEFINED VCPKG_TARGET_ARCHITECTURE)
2022-11-22 19:21:24 +00:00
set(DXMATH_ARCHITECTURE ${VCPKG_TARGET_ARCHITECTURE})
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$")
set(DXMATH_ARCHITECTURE x86)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$")
set(DXMATH_ARCHITECTURE x64)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$")
set(DXMATH_ARCHITECTURE arm)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$")
set(DXMATH_ARCHITECTURE arm64)
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64EC$")
set(DXMATH_ARCHITECTURE arm64ec)
2024-02-09 18:13:58 +00:00
elseif(CMAKE_VS_PLATFORM_NAME_DEFAULT MATCHES "^[Ww][Ii][Nn]32$")
set(DXMATH_ARCHITECTURE x86)
elseif(CMAKE_VS_PLATFORM_NAME_DEFAULT MATCHES "^[Xx]64$")
set(DXMATH_ARCHITECTURE x64)
elseif(CMAKE_VS_PLATFORM_NAME_DEFAULT MATCHES "^[Aa][Rr][Mm]$")
set(DXMATH_ARCHITECTURE arm)
elseif(CMAKE_VS_PLATFORM_NAME_DEFAULT MATCHES "^[Aa][Rr][Mm]64$")
set(DXMATH_ARCHITECTURE arm64)
elseif(CMAKE_VS_PLATFORM_NAME_DEFAULT MATCHES "^[Aa][Rr][Mm]64EC$")
set(DXMATH_ARCHITECTURE arm64ec)
2024-02-09 18:13:58 +00:00
elseif(NOT (DEFINED DXMATH_ARCHITECTURE))
2022-11-22 19:21:24 +00:00
set(DXMATH_ARCHITECTURE "x64")
endif()
#--- Test suite
if(NOT WINDOWS_STORE)
include(CTest)
if(BUILD_TESTING AND WIN32 AND (NOT WINDOWS_STORE) AND (EXISTS "${CMAKE_CURRENT_LIST_DIR}/Tests/CMakeLists.txt"))
enable_testing()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Tests)
endif()
2022-11-22 19:21:24 +00:00
endif()