-
Notifications
You must be signed in to change notification settings - Fork 240
/
CMakeLists.txt
119 lines (98 loc) · 4.03 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cmake_minimum_required (VERSION 3.20)
set(DIRECTXMATH_VERSION 3.20)
project(DirectXMath
VERSION ${DIRECTXMATH_VERSION}
DESCRIPTION "DirectXMath SIMD C++ math library"
HOMEPAGE_URL "https://go.microsoft.com/fwlink/?LinkID=615560"
LANGUAGES CXX)
include(GNUInstallDirs)
#--- 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>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/directxmath>)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11)
#--- Package
include(CMakePackageConfigHelpers)
string(TOLOWER ${PROJECT_NAME} PACKAGE_NAME)
write_basic_package_version_file(
${PACKAGE_NAME}-config-version.cmake
VERSION ${DIRECTXMATH_VERSION}
COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/build/${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE Microsoft::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
install(FILES ${LIBRARY_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/directxmath)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
# 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")
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)
#--- Test suite
if(DEFINED VCPKG_TARGET_ARCHITECTURE)
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)
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)
elseif(NOT (DEFINED DXMATH_ARCHITECTURE))
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()
endif()