cmake 错误提示改明显
This commit is contained in:
@@ -0,0 +1,80 @@
|
|||||||
|
include_guard(GLOBAL)
|
||||||
|
#[[
|
||||||
|
\033[1;31;40m <!--1-高亮显示 31-前景色红色 40-背景色黑色-->
|
||||||
|
\033[0m <!--采用终端默认设置,即取消颜色设置-->
|
||||||
|
显示方式
|
||||||
|
0 终端默认设置
|
||||||
|
1 高亮显示
|
||||||
|
4 使用下划线
|
||||||
|
5 闪烁
|
||||||
|
7 反白显示
|
||||||
|
8 不可见
|
||||||
|
|
||||||
|
前景色 背景色 颜色
|
||||||
|
---------------------------------------
|
||||||
|
30 40 黑色
|
||||||
|
31 41 红色
|
||||||
|
32 42 绿色
|
||||||
|
33 43 黃色
|
||||||
|
34 44 蓝色
|
||||||
|
35 45 紫红色
|
||||||
|
36 46 青蓝色
|
||||||
|
37 47 白色
|
||||||
|
]]
|
||||||
|
|
||||||
|
# 0x1b
|
||||||
|
string(ASCII 27 Esc)
|
||||||
|
|
||||||
|
# Esc[0;31m
|
||||||
|
set(R "${Esc}[0;31m") #红色
|
||||||
|
set(P "${Esc}[0;35m") #紫红色
|
||||||
|
#Esc[0m
|
||||||
|
set(E "${Esc}[m") #结束颜色设置
|
||||||
|
|
||||||
|
set(B "${Esc}[1;34m") #蓝色高亮
|
||||||
|
|
||||||
|
set(_dbg_title "${Esc}[1;31;40m")
|
||||||
|
set(_h1 "${Esc}[4;34m")
|
||||||
|
|
||||||
|
set(__target_name_ "${Esc}[1;33m")
|
||||||
|
|
||||||
|
|
||||||
|
set(Default "${Esc}[0m") # 0 - 终端默认设置
|
||||||
|
set(Bold "${Esc}[1m") # 1 - 高亮显示(粗体)
|
||||||
|
set(Underline "${Esc}[4m") # 4 - 使用下划线
|
||||||
|
set(Blink "${Esc}[5m") # 5 - 闪烁
|
||||||
|
set(Reverse "${Esc}[7m") # 7 - 反白显示
|
||||||
|
set(Invisible "${Esc}[8m") # 8 - 不可见
|
||||||
|
#message("${Default}终端默认设置: 这是一段默认文本${Default}")
|
||||||
|
#message("${Bold}高亮显示: 这是一段高亮(粗体)文本${Default}")
|
||||||
|
#message("${Underline}使用下划线: 这是一段带下划线的文本${Default}")
|
||||||
|
#message("${Blink}闪烁: 这是一段闪烁的文本(如果终端支持)${Default}")
|
||||||
|
#message("${Reverse}反白显示: 这是一段反白显示的文本${Default}")
|
||||||
|
#message("${Invisible}不可见: 这段文本应该不可见(如果终端支持)${Default}")
|
||||||
|
|
||||||
|
|
||||||
|
# 形参命名规范
|
||||||
|
# 1.如果前缀是下划线_,代表传参是变量名,否则是传值
|
||||||
|
# 2.如果后缀是_list,代表这个变量是列表变量
|
||||||
|
# 3 单返回值时,返回值放在最后一个参数,命名要么是 _ret 要么是 _ret_list
|
||||||
|
|
||||||
|
# 函数命名规范
|
||||||
|
# 自定义函数统一加前缀下划线_
|
||||||
|
# 如果函数内部使用临时的列表变量,那么临时的列表变量要在函数开头置空 (为了防止外部定义了该列表变量,使用这个非空的变量导致错误)
|
||||||
|
# 如果函数特意要使用固定名称的外部变量,那么
|
||||||
|
|
||||||
|
|
||||||
|
# 用于检测 防止穿错参数
|
||||||
|
macro(__check_none_extr_params argc argn argv)
|
||||||
|
#__check_none_extr_params(${ARGC} "${ARGN}" "${ARGV}")
|
||||||
|
set(_err_msg "")
|
||||||
|
if (NOT "${argn}" STREQUAL "")
|
||||||
|
string(APPEND _err_msg "检查到多余参数!参数: ${argc} ${argv} 额外的参数: ${argn}")
|
||||||
|
endif ()
|
||||||
|
if (NOT "${_err_msg}" STREQUAL "")
|
||||||
|
message(FATAL_ERROR "${_err_msg}")
|
||||||
|
endif ()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
include(${CMAKE_CURRENT_LIST_DIR}/register_libaray/rcl_register_ex.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/register_libaray/rcl_register_ex.cmake)
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/package_zip.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/cmake/package_zip.cmake)
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/color_output.cmake)
|
||||||
macro(w_install files dir)
|
macro(w_install files dir)
|
||||||
install(FILES ${files} DESTINATION "${dir}")
|
install(FILES ${files} DESTINATION "${dir}")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ endfunction()
|
|||||||
# 参数: namespace_name 是命名空间;output_variable 是接收目录的变量名。
|
# 参数: namespace_name 是命名空间;output_variable 是接收目录的变量名。
|
||||||
function(__rcl_default_root_dir namespace_name output_variable)
|
function(__rcl_default_root_dir namespace_name output_variable)
|
||||||
__rcl_namespace_storage_id("${namespace_name}" _namespace_storage_id)
|
__rcl_namespace_storage_id("${namespace_name}" _namespace_storage_id)
|
||||||
if(DEFINED EXTERNAL_DIR AND NOT "${EXTERNAL_DIR}" STREQUAL "" AND DEFINED G_Architecture_Name AND NOT "${G_Architecture_Name}" STREQUAL "")
|
if (DEFINED EXTERNAL_DIR AND NOT "${EXTERNAL_DIR}" STREQUAL "" AND DEFINED G_Architecture_Name AND NOT "${G_Architecture_Name}" STREQUAL "")
|
||||||
set(_root_dir "${EXTERNAL_DIR}/${G_Architecture_Name}_${_namespace_storage_id}")
|
set(_root_dir "${EXTERNAL_DIR}/${G_Architecture_Name}_${_namespace_storage_id}")
|
||||||
elseif(DEFINED EXTERNAL_DIR AND NOT "${EXTERNAL_DIR}" STREQUAL "")
|
elseif (DEFINED EXTERNAL_DIR AND NOT "${EXTERNAL_DIR}" STREQUAL "")
|
||||||
set(_root_dir "${EXTERNAL_DIR}/_rcl_external_${_namespace_storage_id}")
|
set(_root_dir "${EXTERNAL_DIR}/_rcl_external_${_namespace_storage_id}")
|
||||||
else()
|
else ()
|
||||||
set(_root_dir "${CMAKE_BINARY_DIR}/_rcl_external_${_namespace_storage_id}")
|
set(_root_dir "${CMAKE_BINARY_DIR}/_rcl_external_${_namespace_storage_id}")
|
||||||
endif()
|
endif ()
|
||||||
set(${output_variable} "${_root_dir}" PARENT_SCOPE)
|
set(${output_variable} "${_root_dir}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
# INTERNAL: __rcl_split_library_name(<library_name> <namespace_output> <id_output>)
|
# INTERNAL: __rcl_split_library_name(<library_name> <namespace_output> <id_output>)
|
||||||
@@ -35,9 +35,9 @@ endfunction()
|
|||||||
# 参数: namespace_name 是命名空间;可选 root_dir 是命名空间根目录。
|
# 参数: namespace_name 是命名空间;可选 root_dir 是命名空间根目录。
|
||||||
function(rcl_init namespace_name)
|
function(rcl_init namespace_name)
|
||||||
set(_root_dir "${ARGV1}")
|
set(_root_dir "${ARGV1}")
|
||||||
if("${_root_dir}" STREQUAL "")
|
if ("${_root_dir}" STREQUAL "")
|
||||||
__rcl_default_root_dir("${namespace_name}" _root_dir)
|
__rcl_default_root_dir("${namespace_name}" _root_dir)
|
||||||
endif()
|
endif ()
|
||||||
library_create("${namespace_name}" "${_root_dir}")
|
library_create("${namespace_name}" "${_root_dir}")
|
||||||
library_get_global("${namespace_name}" INSTALL_CACHE_ROOT _install_cache_root)
|
library_get_global("${namespace_name}" INSTALL_CACHE_ROOT _install_cache_root)
|
||||||
list(APPEND CMAKE_PREFIX_PATH "${_install_cache_root}")
|
list(APPEND CMAKE_PREFIX_PATH "${_install_cache_root}")
|
||||||
@@ -107,10 +107,10 @@ endfunction()
|
|||||||
function(rcl_set_install_cache_root namespace_name install_cache_root)
|
function(rcl_set_install_cache_root namespace_name install_cache_root)
|
||||||
library_set_global("${namespace_name}" INSTALL_CACHE_ROOT "${install_cache_root}")
|
library_set_global("${namespace_name}" INSTALL_CACHE_ROOT "${install_cache_root}")
|
||||||
library_get_global("${namespace_name}" DATA_EXPORT_DIR_EXPLICIT _data_export_dir_explicit)
|
library_get_global("${namespace_name}" DATA_EXPORT_DIR_EXPLICIT _data_export_dir_explicit)
|
||||||
if(NOT _data_export_dir_explicit)
|
if (NOT _data_export_dir_explicit)
|
||||||
get_filename_component(_context_root "${install_cache_root}" DIRECTORY)
|
get_filename_component(_context_root "${install_cache_root}" DIRECTORY)
|
||||||
library_set_global("${namespace_name}" DATA_EXPORT_DIR "${_context_root}/library_data")
|
library_set_global("${namespace_name}" DATA_EXPORT_DIR "${_context_root}/library_data")
|
||||||
endif()
|
endif ()
|
||||||
endfunction()
|
endfunction()
|
||||||
# API: rcl_get_install_cache_root(<namespace_name> <output_variable>)
|
# API: rcl_get_install_cache_root(<namespace_name> <output_variable>)
|
||||||
# 作用: 读取安装缓存根目录。
|
# 作用: 读取安装缓存根目录。
|
||||||
@@ -451,16 +451,16 @@ endfunction()
|
|||||||
function(__rcl_add_unique_target_dependencies target_name)
|
function(__rcl_add_unique_target_dependencies target_name)
|
||||||
get_property(_existing_dependencies TARGET "${target_name}" PROPERTY MANUALLY_ADDED_DEPENDENCIES)
|
get_property(_existing_dependencies TARGET "${target_name}" PROPERTY MANUALLY_ADDED_DEPENDENCIES)
|
||||||
set(_new_dependencies)
|
set(_new_dependencies)
|
||||||
foreach(_dependency_target IN LISTS ARGN)
|
foreach (_dependency_target IN LISTS ARGN)
|
||||||
list(FIND _existing_dependencies "${_dependency_target}" _existing_index)
|
list(FIND _existing_dependencies "${_dependency_target}" _existing_index)
|
||||||
list(FIND _new_dependencies "${_dependency_target}" _new_index)
|
list(FIND _new_dependencies "${_dependency_target}" _new_index)
|
||||||
if(_existing_index EQUAL -1 AND _new_index EQUAL -1)
|
if (_existing_index EQUAL -1 AND _new_index EQUAL -1)
|
||||||
list(APPEND _new_dependencies "${_dependency_target}")
|
list(APPEND _new_dependencies "${_dependency_target}")
|
||||||
endif()
|
endif ()
|
||||||
endforeach()
|
endforeach ()
|
||||||
if(_new_dependencies)
|
if (_new_dependencies)
|
||||||
add_dependencies("${target_name}" ${_new_dependencies})
|
add_dependencies("${target_name}" ${_new_dependencies})
|
||||||
endif()
|
endif ()
|
||||||
endfunction()
|
endfunction()
|
||||||
# API GROUP: dependency target loading
|
# API GROUP: dependency target loading
|
||||||
# API: rcl_add_dependency_action_targets_with_depth(<target_name> <dependency_depth> [library_names...])
|
# API: rcl_add_dependency_action_targets_with_depth(<target_name> <dependency_depth> [library_names...])
|
||||||
@@ -471,31 +471,31 @@ endfunction()
|
|||||||
function(rcl_add_dependency_action_targets_with_depth target_name dependency_depth)
|
function(rcl_add_dependency_action_targets_with_depth target_name dependency_depth)
|
||||||
library_dependency_order_with_depth("${dependency_depth}" _dependency_order ${ARGN})
|
library_dependency_order_with_depth("${dependency_depth}" _dependency_order ${ARGN})
|
||||||
set(_dependency_action_targets)
|
set(_dependency_action_targets)
|
||||||
foreach(_library_name IN LISTS _dependency_order)
|
foreach (_library_name IN LISTS _dependency_order)
|
||||||
rcl_generate_registered_cmake_library("${_library_name}")
|
rcl_generate_registered_cmake_library("${_library_name}")
|
||||||
__rcl_library_action_target_name("${_library_name}" auto _library_action_target)
|
__rcl_library_action_target_name("${_library_name}" auto _library_action_target)
|
||||||
if(NOT TARGET "${_library_action_target}")
|
if (NOT TARGET "${_library_action_target}")
|
||||||
message(FATAL_ERROR "dependency action target was not generated: ${_library_action_target}")
|
message(FATAL_ERROR "dependency action target was not generated: ${_library_action_target}")
|
||||||
endif()
|
endif ()
|
||||||
list(APPEND _dependency_action_targets "${_library_action_target}")
|
list(APPEND _dependency_action_targets "${_library_action_target}")
|
||||||
endforeach()
|
endforeach ()
|
||||||
foreach(_library_name IN LISTS _dependency_order)
|
foreach (_library_name IN LISTS _dependency_order)
|
||||||
__rcl_split_library_name("${_library_name}" _namespace_name _library_id)
|
__rcl_split_library_name("${_library_name}" _namespace_name _library_id)
|
||||||
library_get("${_namespace_name}" "${_library_name}" RESOLVED_DEPENDENCIES _direct_dependencies)
|
library_get("${_namespace_name}" "${_library_name}" RESOLVED_DEPENDENCIES _direct_dependencies)
|
||||||
__rcl_library_action_target_name("${_library_name}" auto _library_action_target)
|
__rcl_library_action_target_name("${_library_name}" auto _library_action_target)
|
||||||
set(_direct_dependency_targets)
|
set(_direct_dependency_targets)
|
||||||
foreach(_dependency_name IN LISTS _direct_dependencies)
|
foreach (_dependency_name IN LISTS _direct_dependencies)
|
||||||
list(FIND _dependency_order "${_dependency_name}" _dependency_index)
|
list(FIND _dependency_order "${_dependency_name}" _dependency_index)
|
||||||
if(NOT _dependency_index EQUAL -1)
|
if (NOT _dependency_index EQUAL -1)
|
||||||
__rcl_library_action_target_name("${_dependency_name}" auto _dependency_action_target)
|
__rcl_library_action_target_name("${_dependency_name}" auto _dependency_action_target)
|
||||||
list(APPEND _direct_dependency_targets "${_dependency_action_target}")
|
list(APPEND _direct_dependency_targets "${_dependency_action_target}")
|
||||||
endif()
|
endif ()
|
||||||
endforeach()
|
endforeach ()
|
||||||
__rcl_add_unique_target_dependencies("${_library_action_target}" ${_direct_dependency_targets})
|
__rcl_add_unique_target_dependencies("${_library_action_target}" ${_direct_dependency_targets})
|
||||||
endforeach()
|
endforeach ()
|
||||||
if(NOT TARGET "${target_name}")
|
if (NOT TARGET "${target_name}")
|
||||||
add_custom_target("${target_name}")
|
add_custom_target("${target_name}")
|
||||||
endif()
|
endif ()
|
||||||
__rcl_add_unique_target_dependencies("${target_name}" ${_dependency_action_targets})
|
__rcl_add_unique_target_dependencies("${target_name}" ${_dependency_action_targets})
|
||||||
endfunction()
|
endfunction()
|
||||||
# API: rcl_add_dependency_action_targets(<target_name> [library_names...])
|
# API: rcl_add_dependency_action_targets(<target_name> [library_names...])
|
||||||
@@ -505,3 +505,30 @@ endfunction()
|
|||||||
function(rcl_add_dependency_action_targets target_name)
|
function(rcl_add_dependency_action_targets target_name)
|
||||||
rcl_add_dependency_action_targets_with_depth("${target_name}" 0 ${ARGN})
|
rcl_add_dependency_action_targets_with_depth("${target_name}" 0 ${ARGN})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
set_property(GLOBAL PROPERTY rcl_log_list "")
|
||||||
|
macro(rcl_log_append text)
|
||||||
|
set(rcl_log_location "${CMAKE_CURRENT_LIST_FILE}")
|
||||||
|
if (NOT "${CMAKE_CURRENT_FUNCTION}" STREQUAL "")
|
||||||
|
string(APPEND rcl_log_location " -> ${CMAKE_CURRENT_FUNCTION}()")
|
||||||
|
endif ()
|
||||||
|
set_property(GLOBAL APPEND PROPERTY rcl_log_list "${rcl_log_location}|${text}")
|
||||||
|
endmacro()
|
||||||
|
function(rcl_log_print)
|
||||||
|
get_property(rcl_log_list GLOBAL PROPERTY rcl_log_list)
|
||||||
|
if ("${rcl_log_list}" STREQUAL "")
|
||||||
|
message("${B}全部加载完成!${E}")
|
||||||
|
return()
|
||||||
|
endif ()
|
||||||
|
set(rcl_log_output "")
|
||||||
|
foreach (rcl_log IN LISTS rcl_log_list)
|
||||||
|
string(FIND "${rcl_log}" "|" split_pos)
|
||||||
|
string(SUBSTRING "${rcl_log}" 0 ${split_pos} location)
|
||||||
|
math(EXPR text_pos "${split_pos} + 1")
|
||||||
|
string(SUBSTRING "${rcl_log}" ${text_pos} -1 text)
|
||||||
|
string(APPEND rcl_log_output "${R}严重错误${E} ${R}${text}${E}\n")
|
||||||
|
string(APPEND rcl_log_output "${P}调用位置 ${E} file:///${location}\n")
|
||||||
|
endforeach ()
|
||||||
|
message("${rcl_log_output}")
|
||||||
|
endfunction()
|
||||||
@@ -17,5 +17,5 @@ include(${register_dir}/export.cmake)
|
|||||||
#rcl_generate_registered_cmake_libraries(osg_earth)
|
#rcl_generate_registered_cmake_libraries(osg_earth)
|
||||||
#rcl_generate_registered_cmake_libraries(vsg_cesium)
|
#rcl_generate_registered_cmake_libraries(vsg_cesium)
|
||||||
|
|
||||||
|
rcl_log_print()
|
||||||
|
|
||||||
message("全部加载完成!")
|
|
||||||
|
|||||||
+1
-1
@@ -2,6 +2,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/0_cmake_library/main.cmake)
|
|||||||
_load_cmake_library()
|
_load_cmake_library()
|
||||||
rcl_init(global)
|
rcl_init(global)
|
||||||
rcl_set_root_dir(global "${EXTERNAL_DIR}/${G_Architecture_Name}_global")
|
rcl_set_root_dir(global "${EXTERNAL_DIR}/${G_Architecture_Name}_global")
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/0_cmake_library/register/export.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/0_cmake_library/register/export.cmake)
|
||||||
#set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
#set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
set(ENABLE_BUILD_TIMER ON CACHE BOOL "" FORCE)
|
set(ENABLE_BUILD_TIMER ON CACHE BOOL "" FORCE)
|
||||||
@@ -25,4 +26,3 @@ include(${dqi}/Cppcheck/export.cmake) # 静态代码分析工具:检测 C
|
|||||||
include(${dqi}/lizard/export.cmake) # 代码复杂度分析工具:统计圈复杂度、函数规模等指标
|
include(${dqi}/lizard/export.cmake) # 代码复杂度分析工具:统计圈复杂度、函数规模等指标
|
||||||
include(${dqi}/cloc_tokei/export.cmake) # 代码统计工具:统计代码行数、语言组成等信息
|
include(${dqi}/cloc_tokei/export.cmake) # 代码统计工具:统计代码行数、语言组成等信息
|
||||||
include(${dqi}/CodeMetrics/export.cmake) # 软件度量工具:分析代码质量指标
|
include(${dqi}/CodeMetrics/export.cmake) # 软件度量工具:分析代码质量指标
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user