-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathnumactl.cmake
More file actions
84 lines (72 loc) · 3.38 KB
/
numactl.cmake
File metadata and controls
84 lines (72 loc) · 3.38 KB
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
update_git_submodule(${THIRD_PARTY_DIR}/numactl "--recursive")
get_submodule_version(${THIRD_PARTY_DIR}/numactl NUMACTL_VERSION)
get_submodule_remote_url(third-party/numactl NUMACTL_SOURCE_URL)
set(NUMACTL_PROJECT_GENERIC_NAME numactl)
set(NUMACTL_PROJECT_GENERIC_NAMESPACE NUMACTL)
set(NUMACTL_ARTIFACT_NAME libnuma)
function(build_numactl PIC_ENABLED)
make_third_party_configuration(${PIC_ENABLED} ${NUMACTL_PROJECT_GENERIC_NAME} ${NUMACTL_PROJECT_GENERIC_NAMESPACE}
project_name
target_name
extra_compile_flags
pic_namespace
pic_lib_specifier
)
set(source_dir ${THIRD_PARTY_DIR}/${NUMACTL_PROJECT_GENERIC_NAME})
set(build_dir ${CMAKE_BINARY_DIR}/third-party/${project_name}/build)
set(install_dir ${CMAKE_BINARY_DIR}/third-party/${project_name}/install)
set(include_dirs ${install_dir}/include)
set(libraries ${install_dir}/lib/${NUMACTL_ARTIFACT_NAME}.a)
# Ensure the build, installation and "include" directories exists
file(MAKE_DIRECTORY ${build_dir})
file(MAKE_DIRECTORY ${install_dir})
file(MAKE_DIRECTORY ${include_dirs})
# The configuration has been based on:
# https://sources.debian.org/src/numactl/2.0.12-1/debian/rules/
set(compile_flags "$ENV{CFLAGS} -Wno-unused-but-set-variable -g0 -fno-lto ${extra_compile_flags}")
message(STATUS "NUMA Summary:
PIC enabled: ${PIC_ENABLED}
Version: ${NUMACTL_VERSION}
Source: ${NUMACTL_SOURCE_URL}
Include dirs: ${include_dirs}
Libraries: ${libraries}
Target name: ${target_name}
Compiler:
C compiler: ${CMAKE_C_COMPILER}
CFLAGS: ${compile_flags}
")
ExternalProject_Add(
${project_name}
PREFIX ${build_dir}
SOURCE_DIR ${source_dir}
INSTALL_DIR ${install_dir}
BINARY_DIR ${build_dir}
BUILD_BYPRODUCTS ${libraries}
CONFIGURE_COMMAND
COMMAND ${CMAKE_COMMAND} -E copy_directory ${source_dir} ${build_dir}
COMMAND ./autogen.sh
COMMAND ${CMAKE_COMMAND} -E env CC=${CMAKE_C_COMPILER} CFLAGS=${compile_flags} ./configure --prefix=${install_dir} --includedir=${install_dir}/include/numactl --disable-shared --enable-static
BUILD_COMMAND
COMMAND make libnuma.la -j
INSTALL_COMMAND
COMMAND make install-libLTLIBRARIES install-includeHEADERS
COMMAND ${CMAKE_COMMAND} -E copy_directory ${include_dirs} ${INCLUDE_DIR}
BUILD_IN_SOURCE 0
)
add_library(${target_name} STATIC IMPORTED)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION ${libraries}
INTERFACE_INCLUDE_DIRECTORIES ${include_dirs}
)
# Ensure that the NUMA is built before they are used
add_dependencies(${target_name} ${project_name})
# Set variables indicating that NUMA has been installed
set(${NUMACTL_PROJECT_GENERIC_NAMESPACE}_${pic_lib_specifier}_ROOT ${install_dir} PARENT_SCOPE)
set(${NUMACTL_PROJECT_GENERIC_NAMESPACE}_${pic_lib_specifier}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE)
set(${NUMACTL_PROJECT_GENERIC_NAMESPACE}_${pic_lib_specifier}_LIBRARIES ${libraries} PARENT_SCOPE)
endfunction()
# PIC is OFF
build_numactl(OFF)
# PIC is ON
build_numactl(ON)
set(NUMACTL_FOUND ON)