From 9ea7ca67de66764fb78a2ce454ace4f0f6e2bf9e Mon Sep 17 00:00:00 2001 From: Patrick Kappl Date: Thu, 11 Jan 2024 13:11:50 +0100 Subject: [PATCH 1/5] Remove build directory and update .gitignore --- .gitignore | 19 ++++++------------- build/notes.txt | 6 ------ 2 files changed, 6 insertions(+), 19 deletions(-) delete mode 100644 build/notes.txt diff --git a/.gitignore b/.gitignore index b3d7771..b9cdc00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,7 @@ +.cache/ +.vs/ +.vscode/ +/[Bb]uild -# ignore dir -#build/ -build/*.txt -build/Makefile -build/*.cmake -build/CMakeFiles -build/sdk_core -build/sample - -#whitelist -!build/notes.txt - - +compile_commands.json +CMakeUserPresets.json diff --git a/build/notes.txt b/build/notes.txt deleted file mode 100644 index a3eb7a4..0000000 --- a/build/notes.txt +++ /dev/null @@ -1,6 +0,0 @@ -// 2019/01/07 -The purpose of adding this file is to commit the build folder to git. - -// Must build the project in this folder,for example: -cmake .. // generate makefile,in the project root directory. -make // build the project. From 0a07f736e019eb8b6103c2fed2ab5046e04cc459 Mon Sep 17 00:00:00 2001 From: Patrick Kappl Date: Thu, 11 Jan 2024 13:13:01 +0100 Subject: [PATCH 2/5] Add alias livox_sdk::livox_sdk for library target --- sdk_core/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk_core/CMakeLists.txt b/sdk_core/CMakeLists.txt index 60037f6..8679e71 100644 --- a/sdk_core/CMakeLists.txt +++ b/sdk_core/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.0) set(SDK_LIBRARY ${PROJECT_NAME}_static) add_library(${SDK_LIBRARY} STATIC "") +add_library(livox_sdk::livox_sdk ALIAS ${SDK_LIBRARY}) set(LIVOX_SDK_MAJOR_VERSION "2") set(LIVOX_SDK_MINOR_VERSION "3") From 16715218dd1d144d01b8c7a46def95bbd9ec8d56 Mon Sep 17 00:00:00 2001 From: Patrick Kappl Date: Thu, 11 Jan 2024 13:26:32 +0100 Subject: [PATCH 3/5] Add public include directories only when in build tree --- sdk_core/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk_core/CMakeLists.txt b/sdk_core/CMakeLists.txt index 8679e71..4f66366 100644 --- a/sdk_core/CMakeLists.txt +++ b/sdk_core/CMakeLists.txt @@ -12,10 +12,10 @@ set(LIVOX_SDK_VERSION_STRING "${LIVOX_SDK_MAJOR_VERSION}.${LIVOX_SDK_MINOR_VERSI target_include_directories(${SDK_LIBRARY} PUBLIC - include - include/third_party/FastCRC - include/third_party/spdlog - include/third_party/cmdline + "$" + "$" + "$" + "$" PRIVATE src) From 583b2f382dd6ec9d462714ca4412be95d8d9cc45 Mon Sep 17 00:00:00 2001 From: Patrick Kappl Date: Thu, 11 Jan 2024 13:26:41 +0100 Subject: [PATCH 4/5] Add proper installation rules for library --- cmake/install-config.cmake | 1 + cmake/install-rules.cmake | 32 ++++++++++++++++++++++++++++++++ sdk_core/CMakeLists.txt | 10 +++++----- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 cmake/install-config.cmake create mode 100644 cmake/install-rules.cmake diff --git a/cmake/install-config.cmake b/cmake/install-config.cmake new file mode 100644 index 0000000..0022412 --- /dev/null +++ b/cmake/install-config.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/livox_sdkTargets.cmake") diff --git a/cmake/install-rules.cmake b/cmake/install-rules.cmake new file mode 100644 index 0000000..e206bc0 --- /dev/null +++ b/cmake/install-rules.cmake @@ -0,0 +1,32 @@ +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +# Name of the package to use when calling find_package() in consumer code +set(package livox_sdk) + +# Install target types (ARCHIVE, LIBRARY, PUBLIC_HEADER, ...) to default locations (lib, include) +# and create an export. +install(TARGETS ${SDK_LIBRARY} EXPORT livox_sdkTargets) + +# Allow package maintainers to freely override the path for the configs +set(livox_sdk_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${package}" + CACHE PATH "CMake package config location relative to the install prefix") +mark_as_advanced(livox_sdk_INSTALL_CMAKEDIR) + +# Copy the package config file to the install location and give it the correct name +install(FILES ../cmake/install-config.cmake + DESTINATION ${livox_sdk_INSTALL_CMAKEDIR} + RENAME "${package}Config.cmake") + +write_basic_package_version_file("../${package}ConfigVersion.cmake" + VERSION ${LIVOX_SDK_VERSION_STRING} + COMPATIBILITY SameMajorVersion) + +# Copy the package version file the the install location +install(FILES "${PROJECT_BINARY_DIR}/${package}ConfigVersion.cmake" + DESTINATION ${livox_sdk_INSTALL_CMAKEDIR}) + +# Generate and install a CMake file with code for installing targets from the given export +install(EXPORT livox_sdkTargets + NAMESPACE livox_sdk:: + DESTINATION ${livox_sdk_INSTALL_CMAKEDIR}) diff --git a/sdk_core/CMakeLists.txt b/sdk_core/CMakeLists.txt index 4f66366..461e595 100644 --- a/sdk_core/CMakeLists.txt +++ b/sdk_core/CMakeLists.txt @@ -4,6 +4,10 @@ set(SDK_LIBRARY ${PROJECT_NAME}_static) add_library(${SDK_LIBRARY} STATIC "") add_library(livox_sdk::livox_sdk ALIAS ${SDK_LIBRARY}) +set_target_properties(${SDK_LIBRARY} PROPERTIES + EXPORT_NAME livox_sdk + OUTPUT_NAME livox_sdk) + set(LIVOX_SDK_MAJOR_VERSION "2") set(LIVOX_SDK_MINOR_VERSION "3") set(LIVOX_SDK_PATCH_VERSION "0") @@ -85,8 +89,4 @@ target_sources(${SDK_LIBRARY} src/base/wake_up/wake_up_pipe.h src/base/wake_up/${PLATFORM}/wake_up_pipe.cpp) - -install(TARGETS ${SDK_LIBRARY} - PUBLIC_HEADER DESTINATION include - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib) \ No newline at end of file +include(../cmake/install-rules.cmake) From 758113809c0219280423cd0d2da2712305245f2a Mon Sep 17 00:00:00 2001 From: Patrick Kappl Date: Thu, 11 Jan 2024 13:27:44 +0100 Subject: [PATCH 5/5] Change installation directories for library I prefer putting the headers and library files not directly into the lib or include directory, but into a package-specific subdirectory. --- cmake/install-rules.cmake | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cmake/install-rules.cmake b/cmake/install-rules.cmake index e206bc0..3af7c17 100644 --- a/cmake/install-rules.cmake +++ b/cmake/install-rules.cmake @@ -4,14 +4,15 @@ include(CMakePackageConfigHelpers) # Name of the package to use when calling find_package() in consumer code set(package livox_sdk) -# Install target types (ARCHIVE, LIBRARY, PUBLIC_HEADER, ...) to default locations (lib, include) -# and create an export. -install(TARGETS ${SDK_LIBRARY} EXPORT livox_sdkTargets) +set(livox_sdk_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${package}") +set(livox_sdk_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${package}") +set(livox_sdk_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${package}") -# Allow package maintainers to freely override the path for the configs -set(livox_sdk_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${package}" - CACHE PATH "CMake package config location relative to the install prefix") -mark_as_advanced(livox_sdk_INSTALL_CMAKEDIR) +# Install target types to the given destinations and create an export. +install(TARGETS ${SDK_LIBRARY} EXPORT livox_sdkTargets + ARCHIVE DESTINATION "${livox_sdk_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${livox_sdk_INSTALL_LIBDIR}" + PUBLIC_HEADER DESTINATION "${livox_sdk_INSTALL_INCLUDEDIR}") # Copy the package config file to the install location and give it the correct name install(FILES ../cmake/install-config.cmake