milvus/core/cmake/DefineOptions.cmake

166 lines
5.6 KiB
CMake
Raw Normal View History

macro(set_option_category name)
set(MILVUS_OPTION_CATEGORY ${name})
list(APPEND "MILVUS_OPTION_CATEGORIES" ${name})
endmacro()
macro(define_option name description default)
option(${name} ${description} ${default})
list(APPEND "MILVUS_${MILVUS_OPTION_CATEGORY}_OPTION_NAMES" ${name})
set("${name}_OPTION_DESCRIPTION" ${description})
set("${name}_OPTION_DEFAULT" ${default})
set("${name}_OPTION_TYPE" "bool")
endmacro()
function(list_join lst glue out)
2019-11-07 07:35:53 +00:00
if ("${${lst}}" STREQUAL "")
set(${out} "" PARENT_SCOPE)
return()
2019-11-07 07:35:53 +00:00
endif ()
list(GET ${lst} 0 joined)
list(REMOVE_AT ${lst} 0)
2019-11-07 07:35:53 +00:00
foreach (item ${${lst}})
set(joined "${joined}${glue}${item}")
2019-11-07 07:35:53 +00:00
endforeach ()
set(${out} ${joined} PARENT_SCOPE)
endfunction()
macro(define_option_string name description default)
set(${name} ${default} CACHE STRING ${description})
list(APPEND "MILVUS_${MILVUS_OPTION_CATEGORY}_OPTION_NAMES" ${name})
set("${name}_OPTION_DESCRIPTION" ${description})
set("${name}_OPTION_DEFAULT" "\"${default}\"")
set("${name}_OPTION_TYPE" "string")
set("${name}_OPTION_ENUM" ${ARGN})
list_join("${name}_OPTION_ENUM" "|" "${name}_OPTION_ENUM")
2019-11-07 07:35:53 +00:00
if (NOT ("${${name}_OPTION_ENUM}" STREQUAL ""))
set_property(CACHE ${name} PROPERTY STRINGS ${ARGN})
2019-11-07 07:35:53 +00:00
endif ()
endmacro()
2019-11-05 02:23:59 +00:00
#----------------------------------------------------------------------
2019-11-07 07:35:53 +00:00
set_option_category("GPU version")
2019-11-05 02:23:59 +00:00
2019-11-07 07:35:53 +00:00
define_option(MILVUS_GPU_VERSION "Build GPU version" OFF)
2019-11-05 02:23:59 +00:00
#----------------------------------------------------------------------
set_option_category("Thirdparty")
2019-11-12 03:12:03 +00:00
set(MILVUS_DEPENDENCY_SOURCE_DEFAULT "BUNDLED")
define_option_string(MILVUS_DEPENDENCY_SOURCE
2019-11-07 07:35:53 +00:00
"Method to use for acquiring MILVUS's build dependencies"
"${MILVUS_DEPENDENCY_SOURCE_DEFAULT}"
"AUTO"
"BUNDLED"
"SYSTEM")
define_option(MILVUS_USE_CCACHE "Use ccache when compiling (if available)" ON)
define_option(MILVUS_VERBOSE_THIRDPARTY_BUILD
"Show output from ExternalProjects rather than just logging to files" ON)
define_option(MILVUS_WITH_EASYLOGGINGPP "Build with Easylogging++ library" ON)
define_option(MILVUS_WITH_PROMETHEUS "Build with PROMETHEUS library" ON)
define_option(MILVUS_WITH_SQLITE "Build with SQLite library" ON)
define_option(MILVUS_WITH_SQLITE_ORM "Build with SQLite ORM library" ON)
define_option(MILVUS_WITH_MYSQLPP "Build with MySQL++" ON)
define_option(MILVUS_WITH_YAMLCPP "Build with yaml-cpp library" ON)
if (MILVUS_ENABLE_PROFILING STREQUAL "ON")
define_option(MILVUS_WITH_LIBUNWIND "Build with libunwind" ON)
define_option(MILVUS_WITH_GPERFTOOLS "Build with gperftools" ON)
2019-11-07 07:35:53 +00:00
endif ()
define_option(MILVUS_WITH_GRPC "Build with GRPC" ON)
define_option(MILVUS_WITH_ZLIB "Build with zlib compression" ON)
#----------------------------------------------------------------------
set_option_category("Test and benchmark")
unset(MILVUS_BUILD_TESTS CACHE)
if (BUILD_UNIT_TEST)
define_option(MILVUS_BUILD_TESTS "Build the MILVUS googletest unit tests" ON)
2019-11-07 07:35:53 +00:00
else ()
define_option(MILVUS_BUILD_TESTS "Build the MILVUS googletest unit tests" OFF)
2019-11-07 07:35:53 +00:00
endif (BUILD_UNIT_TEST)
#----------------------------------------------------------------------
macro(config_summary)
message(STATUS "---------------------------------------------------------------------")
message(STATUS "MILVUS version: ${MILVUS_VERSION}")
message(STATUS)
message(STATUS "Build configuration summary:")
message(STATUS " Generator: ${CMAKE_GENERATOR}")
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS " Source directory: ${CMAKE_CURRENT_SOURCE_DIR}")
2019-11-07 07:35:53 +00:00
if (${CMAKE_EXPORT_COMPILE_COMMANDS})
message(
STATUS " Compile commands: ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json")
2019-11-07 07:35:53 +00:00
endif ()
2019-11-07 07:35:53 +00:00
foreach (category ${MILVUS_OPTION_CATEGORIES})
message(STATUS)
message(STATUS "${category} options:")
set(option_names ${MILVUS_${category}_OPTION_NAMES})
set(max_value_length 0)
2019-11-07 07:35:53 +00:00
foreach (name ${option_names})
string(LENGTH "\"${${name}}\"" value_length)
2019-11-07 07:35:53 +00:00
if (${max_value_length} LESS ${value_length})
set(max_value_length ${value_length})
2019-11-07 07:35:53 +00:00
endif ()
endforeach ()
2019-11-07 07:35:53 +00:00
foreach (name ${option_names})
if ("${${name}_OPTION_TYPE}" STREQUAL "string")
set(value "\"${${name}}\"")
2019-11-07 07:35:53 +00:00
else ()
set(value "${${name}}")
2019-11-07 07:35:53 +00:00
endif ()
set(default ${${name}_OPTION_DEFAULT})
set(description ${${name}_OPTION_DESCRIPTION})
string(LENGTH ${description} description_length)
2019-11-07 07:35:53 +00:00
if (${description_length} LESS 70)
string(
SUBSTRING
" "
${description_length} -1 description_padding)
2019-11-07 07:35:53 +00:00
else ()
set(description_padding "
")
2019-11-07 07:35:53 +00:00
endif ()
set(comment "[${name}]")
2019-11-07 07:35:53 +00:00
if ("${value}" STREQUAL "${default}")
set(comment "[default] ${comment}")
2019-11-07 07:35:53 +00:00
endif ()
2019-11-07 07:35:53 +00:00
if (NOT ("${${name}_OPTION_ENUM}" STREQUAL ""))
set(comment "${comment} [${${name}_OPTION_ENUM}]")
2019-11-07 07:35:53 +00:00
endif ()
string(
SUBSTRING "${value} "
0 ${max_value_length} value)
message(STATUS " ${description} ${description_padding} ${value} ${comment}")
2019-11-07 07:35:53 +00:00
endforeach ()
2019-11-07 07:35:53 +00:00
endforeach ()
endmacro()