From 7cab6382396e979146cecadc4a283461493a4990 Mon Sep 17 00:00:00 2001 From: "HARMEL, Bernard" Date: Sun, 3 Mar 2024 16:10:35 +0100 Subject: [PATCH] Add gen of DepManifest.txt --- CMakeLists.txt | 51 +++++++++++++++++++++------------ cmake/fetch_content.cmake | 5 ++++ tests/src/ut_circularbuffer.cpp | 2 +- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c92755..e4005b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,8 @@ #cmake --build . --config Release -j 16 #cmake --install . --config Debug + +#vcpkg list --x-install-root=C:/bld/bofstd-win/vcpkg_installed/ cmake_minimum_required(VERSION 3.25) # Paranoid check : in-source generation is forbidden @@ -49,6 +51,7 @@ string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER) string(REPLACE "-" "_" PROJECT_NAME_UNDERSCORE ${PROJECT_NAME}) string(REPLACE "-" "_" PROJECT_NAME_LOWER_UNDERSCORE ${PROJECT_NAME_LOWER}) string(REPLACE "-" "_" PROJECT_NAME_UPPER_UNDERSCORE ${PROJECT_NAME_UPPER}) +file(REMOVE ${CMAKE_BINARY_DIR}/DepManifest.txt) option(BOFSTD_BUILD_EXAMPLES "Build example of BofStd project" ON) option(BOFSTD_BUILD_TESTS "Build units tests of BofStd project" ON) @@ -241,14 +244,6 @@ endif() set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${COMPILED_BINARIES_DIR}/lib) -# =============== -# == PACKAGING == -# =============== - -if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - # make package only if BofStd is the main project (not a submodule) - include(packaging.cmake) -endif() # ======================= # == POPULATE PROJECTS == @@ -313,6 +308,27 @@ install( COMPONENT bofstd-devel ) +# =============== +# == PACKAGING == +# =============== + +#if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) +# # make package only if BofStd is the main project (not a submodule) +# include(packaging.cmake) +#endif() +if (PROJECT_IS_TOP_LEVEL) + include(cmake/cpack_main.cmake) +endif() + +set(INTERNAL_NAMESPACE ONBINGS) +# Create and install the cmake configuration file based on our template +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/bofstd-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR} +) +unset(INTERNAL_NAMESPACE) + # Install dependencies set(INCLUDE_REGEXES "^${CMAKE_BINARY_DIR}/vcpkg_installed/") set(EXCLUDE_REGEXES @@ -335,17 +351,6 @@ install(RUNTIME_DEPENDENCY_SET bofstd-imported-runtime-set # our dependees can find us include(CMakePackageConfigHelpers) -set(INTERNAL_NAMESPACE ONBINGS) - -# Create and install the cmake configuration file based on our template -configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/bofstd-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR} -) - -unset(INTERNAL_NAMESPACE) - # Give the file a nice naming convention configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies.cmake @@ -370,3 +375,11 @@ install(FILES ) #list_cmake_vars_containing("") +# Add a custom command to run the vcpkg list command during configuration +execute_process( + COMMAND ${CMAKE_COMMAND} -E env vcpkg list --x-install-root=./vcpkg_installed + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} # Change to your desired working directory + OUTPUT_VARIABLE DepVcpkg +) +file(APPEND ${CMAKE_BINARY_DIR}/DepManifest.txt "Vcpkg Dependencies for ${PROJECT_NAME}:\n") +file(APPEND ${CMAKE_BINARY_DIR}/DepManifest.txt "${DepVcpkg}") \ No newline at end of file diff --git a/cmake/fetch_content.cmake b/cmake/fetch_content.cmake index cae25b6..c23fa93 100644 --- a/cmake/fetch_content.cmake +++ b/cmake/fetch_content.cmake @@ -9,6 +9,11 @@ function(fetch_external_library_add LIB_NAME LIST_OF_LIB GIT_URL GIT_TAG) GIT_REPOSITORY ${GIT_URL} GIT_TAG ${GIT_TAG} ) + list(LENGTH LIST_OF_LIB LIST_SIZE) + if(LIST_SIZE EQUAL 0) + file(APPEND ${CMAKE_BINARY_DIR}/DepManifest.txt "FetchContent Dependencies for ${PROJECT_NAME}:\n") + endif() + file(APPEND ${CMAKE_BINARY_DIR}/DepManifest.txt "${LIB_NAME}\t${GIT_TAG}\t${GIT_URL}\n") list(APPEND LIST_OF_LIB ${LIB_NAME}) # Append library name to the provided list set(LIST_OF_LIB "${LIST_OF_LIB}" PARENT_SCOPE) message(STATUS "End of of fetch external library add '${LIB_NAME}'") diff --git a/tests/src/ut_circularbuffer.cpp b/tests/src/ut_circularbuffer.cpp index 770c3bf..e3524d4 100644 --- a/tests/src/ut_circularbuffer.cpp +++ b/tests/src/ut_circularbuffer.cpp @@ -659,7 +659,7 @@ TEST(CircularBuffer_Test, Perf) Index_U32 = 0; } } - printf("%ld Push Min %ld Mean %ld Max %ld Lck %ld\n", Profiler.GetNbSample(0), Profiler.GetMin(0), Profiler.GetMean(0), Profiler.GetMax(0), Profiler.GetLockCount(0)); + printf("%zd Push Min %zd Mean %zd Max %zd Lck %zd\n", Profiler.GetNbSample(0), Profiler.GetMin(0), Profiler.GetMean(0), Profiler.GetMax(0), Profiler.GetLockCount(0)); Index_U32 = 0; for (i_U32 = 0; i_U32 < NB_QUEUE_OP; i_U32++)