From 46858f0fdd8e6203ddf148f26a8a1a2c9461f422 Mon Sep 17 00:00:00 2001 From: msclock Date: Thu, 12 Oct 2023 17:36:35 +0800 Subject: [PATCH] perf: add common modules and runpath paths Signed-off-by: msclock --- cmake/configure/Common.cmake | 38 +++++++++++++++++++++++++++++++ cmake/configure/ConfigDebug.cmake | 5 ---- cmake/install/Common.cmake | 16 +++++++++++++ cmake/install/Runpath.cmake | 6 +++++ 4 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 cmake/configure/Common.cmake delete mode 100644 cmake/configure/ConfigDebug.cmake create mode 100644 cmake/install/Common.cmake diff --git a/cmake/configure/Common.cmake b/cmake/configure/Common.cmake new file mode 100644 index 0000000..b0477d7 --- /dev/null +++ b/cmake/configure/Common.cmake @@ -0,0 +1,38 @@ +#[[ +This module provides some common tools. +]] + +include_guard(GLOBAL) + +#[[ +Show project version friendly +]] +macro(show_project_version) + message(STATUS "PROJECT_VRESION finally:${PROJECT_VERSION}") + message(STATUS "CMAKE_PROJECT_VERSION_MAJOR: ${CMAKE_PROJECT_VERSION_MAJOR}") + message(STATUS "CMAKE_PROJECT_VERSION_MINOR: ${CMAKE_PROJECT_VERSION_MINOR}") + message(STATUS "CMAKE_PROJECT_VERSION_PATCH: ${CMAKE_PROJECT_VERSION_PATCH}") + message(STATUS "CMAKE_PROJECT_VERSION_TWEAK: ${CMAKE_PROJECT_VERSION_TWEAK}") + message(STATUS "CMAKE_PROJECT_VERSION finally:${CMAKE_PROJECT_VERSION}") +endmacro() + +#[[ +Show vcpkg configurition +]] +macro(show_vcpkg_configuration) + message(STATUS "VCPKG_HOST_TRIPLET ${VCPKG_HOST_TRIPLET}") + message(STATUS "VCPKG_INSTALLED_DIR ${VCPKG_INSTALLED_DIR}") + message(STATUS "VCPKG_TARGET_TRIPLET ${VCPKG_TARGET_TRIPLET}") + message(STATUS "VCPKG_LIBRARY_LINKAGE ${VCPKG_LIBRARY_LINKAGE}") + message(STATUS "VCPKG_TARGET_IS_WINDOWS ${VCPKG_TARGET_IS_WINDOWS}") + message(STATUS "VCPKG_TARGET_IS_MINGW ${VCPKG_TARGET_IS_MINGW}") +endmacro() + + +# Debug configuration +macro(add_debug_macro) + if(CMAKE_BUILD_TYPE STREQUAL Debug) + add_definitions(-D_DEBUG) + message(STATUS "Ensure _DEBUG is defined for Debug configuration") + endif() +endmacro() diff --git a/cmake/configure/ConfigDebug.cmake b/cmake/configure/ConfigDebug.cmake deleted file mode 100644 index 800d9f3..0000000 --- a/cmake/configure/ConfigDebug.cmake +++ /dev/null @@ -1,5 +0,0 @@ -# Debug configuration -if(CMAKE_BUILD_TYPE STREQUAL Debug) - add_definitions(-D_DEBUG) - message(STATUS "Ensure _DEBUG is defined for Debug configuration") -endif() diff --git a/cmake/install/Common.cmake b/cmake/install/Common.cmake new file mode 100644 index 0000000..0829058 --- /dev/null +++ b/cmake/install/Common.cmake @@ -0,0 +1,16 @@ +#[[ +This module provides some common tools. +]] + +include_guard(GLOBAL) + +#[[ +Show installation directories +]] +macro(show_installation) + foreach(_p LIB BIN INCLUDE CMAKE) + file(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${_p}DIR} _path) + message(STATUS "Show ${_p} components installation path: ${_path}") + unset(_path) + endforeach() +endmacro() diff --git a/cmake/install/Runpath.cmake b/cmake/install/Runpath.cmake index 01d51b4..c52a4e8 100644 --- a/cmake/install/Runpath.cmake +++ b/cmake/install/Runpath.cmake @@ -27,3 +27,9 @@ message(STATUS "_rpath:${_rpath}") # add auto dly-load path list(APPEND CMAKE_INSTALL_RPATH ${_rpath};$ORIGIN) message(STATUS "CMAKE_INSTALL_RPATH:${CMAKE_INSTALL_RPATH}") + +# dynamic path specify the 3rd party short deps path depends on os-platform +set(RUNPATH_SHARED_LOCATION $,bin,lib>) +set(RUNPATH_VCPKG_DPENDENCY_PATH + ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$,/deubg/${RUNPATH_SHARED_LOCATION},/${RUNPATH_SHARED_LOCATION}> +)