| 1 |
set(DEBIAN_INSTALL_FILE "${CMAKE_BINARY_DIR}/mariadb-plugin-columnstore.install.generated") |
| 2 |
file(WRITE ${DEBIAN_INSTALL_FILE} "#File is generated by ColumnstoreLibrary.cmake, do not edit\n") |
| 3 |
|
| 4 |
macro(add_to_debian_install_file file_path) |
| 5 |
string(SUBSTRING "${file_path}" 1 -1 BINARY_ENTRY) |
| 6 |
file(RELATIVE_PATH CMAKEFILE "${CMAKE_SOURCE_DIR}/storage/columnstore/columnstore" ${CMAKE_CURRENT_LIST_FILE}) |
| 7 |
string(STRIP "${BINARY_ENTRY}" BINARY_ENTRY) |
| 8 |
|
| 9 |
file(APPEND ${DEBIAN_INSTALL_FILE} "${BINARY_ENTRY} # added in ${CMAKEFILE}\n") |
| 10 |
endmacro() |
| 11 |
|
| 12 |
function(get_target_output_filename TARGET_NAME OUTPUT_VAR) |
| 13 |
# 1. Get the target's OUTPUT_NAME (falls back to TARGET_NAME) |
| 14 |
get_target_property(OUTPUT_NAME ${TARGET_NAME} OUTPUT_NAME) |
| 15 |
if(NOT OUTPUT_NAME) |
| 16 |
set(OUTPUT_NAME "${TARGET_NAME}") |
| 17 |
endif() |
| 18 |
|
| 19 |
# 1. Get the correct suffix based on target type |
| 20 |
get_target_property(TARGET_TYPE ${TARGET_NAME} TYPE) |
| 21 |
if(TARGET_TYPE STREQUAL "EXECUTABLE") |
| 22 |
set(SUFFIX "${CMAKE_EXECUTABLE_SUFFIX}") |
| 23 |
set(PREFIX "") # No prefix for executables |
| 24 |
elseif(TARGET_TYPE STREQUAL "SHARED_LIBRARY") |
| 25 |
set(SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}") |
| 26 |
set(PREFIX "lib") |
| 27 |
elseif(TARGET_TYPE STREQUAL "STATIC_LIBRARY") |
| 28 |
set(SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}") |
| 29 |
set(PREFIX "lib") |
| 30 |
else() |
| 31 |
message(WARNING "Unknown target type for ${TARGET_NAME}") |
| 32 |
set(SUFFIX "") |
| 33 |
endif() |
| 34 |
|
| 35 |
# 1. Combine into the final filename |
| 36 |
set(${OUTPUT_VAR} |
| 37 |
"${PREFIX}${OUTPUT_NAME}${SUFFIX}" |
| 38 |
PARENT_SCOPE |
| 39 |
) |
| 40 |
endfunction() |
| 41 |
|
| 42 |
macro(columnstore_install_target target destination) |
| 43 |
install( |
| 44 |
TARGETS ${target} |
| 45 |
DESTINATION ${destination} |
| 46 |
COMPONENT columnstore-engine |
| 47 |
) |
| 48 |
get_target_output_filename(${target} OUTPUT_FILENAME) |
| 49 |
add_to_debian_install_file("${destination}/${OUTPUT_FILENAME}") |
| 50 |
endmacro() |
| 51 |
|
| 52 |
macro(columnstore_install_file file destination) |
| 53 |
install( |
| 54 |
FILES ${file} |
| 55 |
DESTINATION ${destination} |
| 56 |
COMPONENT columnstore-engine |
| 57 |
) |
| 58 |
get_filename_component(FILENAME ${file} NAME) |
| 59 |
add_to_debian_install_file("${destination}/${FILENAME}") |
| 60 |
endmacro() |
| 61 |
|
| 62 |
macro(columnstore_install_program file destination) |
| 63 |
install( |
| 64 |
PROGRAMS ${file} |
| 65 |
DESTINATION ${destination} |
| 66 |
COMPONENT columnstore-engine |
| 67 |
) |
| 68 |
get_filename_component(FILENAME ${file} NAME) |
| 69 |
add_to_debian_install_file( |
| 70 |
"${destination}/${FILENAME} |
| 71 |
" |
| 72 |
) |
| 73 |
endmacro() |
| 74 |
|
| 75 |
macro(columnstore_static_library libname) |
| 76 |
add_definitions(-fPIC -DPIC) |
| 77 |
add_library(${libname} STATIC ${ARGN}) |
| 78 |
endmacro() |
| 79 |
|
| 80 |
macro(columnstore_shared_library libname) |
| 81 |
add_library(${libname} SHARED ${ARGN}) |
| 82 |
columnstore_install_target(${libname} ${ENGINE_LIBDIR}) |
| 83 |
endmacro() |
| 84 |
|
| 85 |
macro(columnstore_library libname) |
| 86 |
if(COLUMNSTORE_STATIC_LIBRARIES) |
| 87 |
columnstore_static_library(${libname} ${ARGN}) |
| 88 |
else() |
| 89 |
columnstore_shared_library(${libname} ${ARGN}) |
| 90 |
endif() |
| 91 |
endmacro() |
| 92 |
|
| 93 |
macro(columnstore_mysql_plugin_library libname) |
| 94 |
add_library(${libname} SHARED ${ARGN}) |
| 95 |
columnstore_install_target(${libname} ${MARIADB_PLUGINDIR}) |
| 96 |
endmacro() |
| 97 |
|
| 98 |
macro(columnstore_link libname) |
| 99 |
target_link_libraries(${libname} ${ARGN}) |
| 100 |
endmacro() |
| 101 |
|
| 102 |
macro(columnstore_executable executable_name) |
| 103 |
if(WITH_COLUMNSTORE_ASAN) |
| 104 |
add_executable(${executable_name} ${ARGN} ${CMAKE_BINARY_DIR}/asan_options.cpp) |
| 105 |
else() |
| 106 |
add_executable(${executable_name} ${ARGN}) |
| 107 |
endif() |
| 108 |
columnstore_install_target(${executable_name} ${ENGINE_BINDIR}) |
| 109 |
endmacro() |
| 110 |
|
| 111 |
# Read /etc/os-release and output: ID (lowercase) and VERSION_ID major number |
| 112 |
function(columnstore_detect_os OUT_ID OUT_VER_MAJOR) |
| 113 |
set(_os_id "") |
| 114 |
set(_os_version_major "") |
| 115 |
|
| 116 |
set(_os_release "/etc/os-release") |
| 117 |
if(EXISTS "${_os_release}") |
| 118 |
file(READ "${_os_release}" _osr) |
| 119 |
# Extract ID |
| 120 |
string(REGEX MATCH "\nID=([^\n]+)" _id_match "\nID=([^\n]+)" ${_osr}) |
| 121 |
if(_id_match) |
| 122 |
string(REGEX REPLACE ".*\nID=\"?([^\"\n]+)\"?.*" "\\1" _os_id "${_osr}") |
| 123 |
string(TOLOWER "${_os_id}" _os_id) |
| 124 |
endif() |
| 125 |
# Extract VERSION_ID major digits |
| 126 |
string(REGEX MATCH "\nVERSION_ID=([^\n]+)" _vid_match "\nVERSION_ID=([^\n]+)" ${_osr}) |
| 127 |
if(_vid_match) |
| 128 |
string(REGEX REPLACE ".*\nVERSION_ID=\"?([0-9]+).*" "\\1" _os_version_major "${_osr}") |
| 129 |
endif() |
| 130 |
endif() |
| 131 |
|
| 132 |
set(${OUT_ID} |
| 133 |
"${_os_id}" |
| 134 |
PARENT_SCOPE |
| 135 |
) |
| 136 |
set(${OUT_VER_MAJOR} |
| 137 |
"${_os_version_major}" |
| 138 |
PARENT_SCOPE |
| 139 |
) |
| 140 |
endfunction() |
| 141 |
|
| 142 |
# Check whether a given lowercase OS ID is RHEL-like (RHEL/Rocky/Alma/CentOS/RedHat) |
| 143 |
function(columnstore_is_rhel_like OS_ID OUT_BOOL) |
| 144 |
set(_is_rhel_like FALSE) |
| 145 |
if(${OS_ID} MATCHES "^(rhel|rocky|almalinux|centos|redhatenterpriseserver|redhatenterprise|redhat)$") |
| 146 |
set(_is_rhel_like TRUE) |
| 147 |
endif() |
| 148 |
set(${OUT_BOOL} |
| 149 |
"${_is_rhel_like}" |
| 150 |
PARENT_SCOPE |
| 151 |
) |
| 152 |
endfunction() |