Skip to content

Commit

Permalink
perf: add common modules and runpath paths
Browse files Browse the repository at this point in the history
Signed-off-by: msclock <[email protected]>
  • Loading branch information
msclock committed Oct 12, 2023
1 parent 45431df commit 46858f0
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
38 changes: 38 additions & 0 deletions cmake/configure/Common.cmake
Original file line number Diff line number Diff line change
@@ -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()
5 changes: 0 additions & 5 deletions cmake/configure/ConfigDebug.cmake

This file was deleted.

16 changes: 16 additions & 0 deletions cmake/install/Common.cmake
Original file line number Diff line number Diff line change
@@ -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()
6 changes: 6 additions & 0 deletions cmake/install/Runpath.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<IF:$<PLATFORM_ID:Windows>,bin,lib>)
set(RUNPATH_VCPKG_DPENDENCY_PATH
${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<IF:$<CONFIG:Debug>,/deubg/${RUNPATH_SHARED_LOCATION},/${RUNPATH_SHARED_LOCATION}>
)

0 comments on commit 46858f0

Please sign in to comment.