|
| 1 | +include_guard(GLOBAL) |
| 2 | + |
| 3 | +function(indent_message header content indent_num) |
| 4 | + if(indent_num GREATER 0) |
| 5 | + string(REPEAT " " ${indent_num} indentation) |
| 6 | + string(REPEAT "." ${indent_num} tail) |
| 7 | + string(REGEX REPLACE "${tail}$" "" header "${header}") |
| 8 | + endif() |
| 9 | + message("${indentation}${header} ${content}") |
| 10 | +endfunction() |
| 11 | + |
| 12 | +# Print compiler's flags on best-effort. Include the abstracted |
| 13 | +# CMake flags that we touch ourselves. |
| 14 | +function(print_flags_per_config config indent_num) |
| 15 | + string(STRIP "${CMAKE_CXX_COMPILER_ARG1} ${CMAKE_CXX_FLAGS}" combined_cxx_flags) |
| 16 | + string(TOUPPER "${config}" config_uppercase) |
| 17 | + string(STRIP "${combined_cxx_flags} ${CMAKE_CXX_FLAGS_${config_uppercase}}" combined_cxx_flags) |
| 18 | + string(STRIP "${combined_cxx_flags} ${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION}" combined_cxx_flags) |
| 19 | + if(CMAKE_POSITION_INDEPENDENT_CODE) |
| 20 | + string(JOIN " " combined_cxx_flags ${combined_cxx_flags} ${CMAKE_CXX_COMPILE_OPTIONS_PIC}) |
| 21 | + endif() |
| 22 | + if(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY AND CMAKE_CXX_VISIBILITY_PRESET) |
| 23 | + string(JOIN " " combined_cxx_flags ${combined_cxx_flags} ${CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY}${CMAKE_CXX_VISIBILITY_PRESET}) |
| 24 | + endif() |
| 25 | + get_directory_property(compile_options COMPILE_OPTIONS) |
| 26 | + string(JOIN " " combined_cxx_flags ${combined_cxx_flags} ${compile_options}) |
| 27 | + indent_message("CXXFLAGS .............................." "${combined_cxx_flags}" ${indent_num}) |
| 28 | +endfunction() |
| 29 | + |
| 30 | +function(print_configure_summary) |
| 31 | + message("") |
| 32 | + if(PROJECT_IS_TOP_LEVEL) |
| 33 | + message("Configure summary") |
| 34 | + message("=================") |
| 35 | + else() |
| 36 | + message("minisketch configure summary") |
| 37 | + message("============================") |
| 38 | + endif() |
| 39 | + if(BUILD_SHARED_LIBS) |
| 40 | + set(library_type "Shared") |
| 41 | + else() |
| 42 | + set(library_type "Static") |
| 43 | + endif() |
| 44 | + message("Library type .......................... ${library_type}") |
| 45 | + message("Build options:") |
| 46 | + if(have_disabled_fields) |
| 47 | + set(filed_sizes "${MINISKETCH_FIELDS}") |
| 48 | + else() |
| 49 | + set(filed_sizes "All") |
| 50 | + endif() |
| 51 | + message(" field sizes ........................ ${filed_sizes}") |
| 52 | + if(HAVE_CLMUL) |
| 53 | + set(clmul_status "Enabled") |
| 54 | + else() |
| 55 | + set(clmul_status "Disabled") |
| 56 | + endif() |
| 57 | + message(" clmul fields ........................ ${clmul_status}") |
| 58 | + if(CMAKE_CXX_STANDARD GREATER_EQUAL 20) |
| 59 | + set(clz_status "C++20") |
| 60 | + elseif(HAVE_CLZ) |
| 61 | + set(clz_status "Compiler builtin") |
| 62 | + else() |
| 63 | + set(clz_status "Default") |
| 64 | + endif() |
| 65 | + message(" clz implementation .................. ${clz_status}") |
| 66 | + message("Optional binaries:") |
| 67 | + message(" benchmark ........................... ${MINISKETCH_BUILD_BENCHMARK}") |
| 68 | + message(" tests ............................... ${MINISKETCH_BUILD_TESTS}") |
| 69 | + message("") |
| 70 | + if(CMAKE_CROSSCOMPILING) |
| 71 | + set(cross_status "TRUE, for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}") |
| 72 | + else() |
| 73 | + set(cross_status "FALSE") |
| 74 | + endif() |
| 75 | + message("Cross compiling ....................... ${cross_status}") |
| 76 | + message("C++ compiler .......................... ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, ${CMAKE_CXX_COMPILER}") |
| 77 | + get_property(_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) |
| 78 | + if(_is_multi_config) |
| 79 | + list(JOIN CMAKE_CONFIGURATION_TYPES ", " configs) |
| 80 | + message("Available build configurations ........ ${configs}") |
| 81 | + if(CMAKE_GENERATOR MATCHES "Visual Studio") |
| 82 | + set(default_config "Debug") |
| 83 | + else() |
| 84 | + list(GET CMAKE_CONFIGURATION_TYPES 0 default_config) |
| 85 | + endif() |
| 86 | + message("Default build configuration ........... ${default_config}") |
| 87 | + foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES) |
| 88 | + message("'${config}' build configuration:") |
| 89 | + print_flags_per_config("${config}" 2) |
| 90 | + endforeach() |
| 91 | + else() |
| 92 | + message("CMAKE_BUILD_TYPE ...................... ${CMAKE_BUILD_TYPE}") |
| 93 | + print_flags_per_config("${CMAKE_BUILD_TYPE}" 0) |
| 94 | + endif() |
| 95 | + unset(_is_multi_config) |
| 96 | + |
| 97 | + message([=[ |
| 98 | +
|
| 99 | +NOTE: The summary above may not exactly match the final applied build flags |
| 100 | + if any additional CMAKE_* or environment variables have been modified. |
| 101 | + To see the exact flags applied, build with the --verbose option.]=] |
| 102 | + ) |
| 103 | + |
| 104 | + if(have_disabled_fields AND PROJECT_IS_TOP_LEVEL) |
| 105 | + message("") |
| 106 | + message(WARNING |
| 107 | + "Only compiling in support for field sizes: ${MINISKETCH_FIELDS}\n" |
| 108 | + "This means the library will lack support for other field sizes entirely.\n" |
| 109 | + ) |
| 110 | + endif() |
| 111 | + message("") |
| 112 | +endfunction() |
0 commit comments