From 7aa7201db5e7471b55773f8cc6e44afbdf0f90a5 Mon Sep 17 00:00:00 2001 From: honglongyu Date: Fri, 23 Aug 2024 09:57:57 +0800 Subject: [PATCH 1/2] install dll --- src/CMakeLists.txt | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6c6640d..d36fa53 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,7 +32,8 @@ if (HWINFO_BATTERY) install(TARGETS hwinfo_battery EXPORT hwinfoTargets LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin) install(FILES ${HWINFO_INCLUDE_DIR}/hwinfo/battery.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hwinfo) endif () # ______________________________________________________________________________________________________________________ @@ -63,7 +64,8 @@ if (HWINFO_CPU) install(TARGETS hwinfo_cpu EXPORT hwinfoTargets LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin) install(FILES ${HWINFO_INCLUDE_DIR}/hwinfo/cpu.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hwinfo) endif() # ______________________________________________________________________________________________________________________ @@ -97,7 +99,8 @@ if (HWINFO_DISK) install(TARGETS hwinfo_disk EXPORT hwinfoTargets LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin) install(FILES ${HWINFO_INCLUDE_DIR}/hwinfo/disk.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hwinfo) endif () # ______________________________________________________________________________________________________________________ @@ -139,7 +142,8 @@ if (HWINFO_GPU) install(TARGETS hwinfo_gpu EXPORT hwinfoTargets LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin) install(FILES ${HWINFO_INCLUDE_DIR}/hwinfo/gpu.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hwinfo) if(HWINFO_GPU_OPENCL) install(DIRECTORY ${HWINFO_INCLUDE_DIR}/hwinfo/opencl DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hwinfo) @@ -173,7 +177,8 @@ if (HWINFO_MAINBOARD) install(TARGETS hwinfo_mainboard EXPORT hwinfoTargets LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin) install(FILES ${HWINFO_INCLUDE_DIR}/hwinfo/mainboard.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hwinfo) endif () # ______________________________________________________________________________________________________________________ @@ -206,7 +211,8 @@ if (HWINFO_OS) install(TARGETS hwinfo_os EXPORT hwinfoTargets LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin) install(FILES ${HWINFO_INCLUDE_DIR}/hwinfo/os.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hwinfo) endif () # ______________________________________________________________________________________________________________________ @@ -237,7 +243,9 @@ if (HWINFO_RAM) install(TARGETS hwinfo_ram EXPORT hwinfoTargets LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin) + install(FILES ${HWINFO_INCLUDE_DIR}/hwinfo/ram.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hwinfo) endif () # ______________________________________________________________________________________________________________________ @@ -248,4 +256,5 @@ install(TARGETS hwinfo EXPORT hwinfoTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin ) \ No newline at end of file From d3bdfd197371af60e142529fbf617c643fbbd8cc Mon Sep 17 00:00:00 2001 From: honglongyu Date: Fri, 30 Aug 2024 12:20:31 +0800 Subject: [PATCH 2/2] rename --- CMakeLists.txt | 16 ++++++++-------- README.md | 4 ++-- cmake/hwinfoConfig.cmake.in | 3 --- cmake/lfreist-hwinfoConfig.cmake.in | 3 +++ examples/CMakeLists.txt | 2 +- src/CMakeLists.txt | 18 +++++++++--------- 6 files changed, 23 insertions(+), 23 deletions(-) delete mode 100644 cmake/hwinfoConfig.cmake.in create mode 100644 cmake/lfreist-hwinfoConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 35b8df1..26b449e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,22 +46,22 @@ add_subdirectory(src) include(CMakePackageConfigHelpers) write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/hwinfoConfigVersion.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/lfreist-hwinfoConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion ) -configure_file(cmake/hwinfoConfig.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/hwinfoConfig.cmake" +configure_file(cmake/lfreist-hwinfoConfig.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/lfreist-hwinfoConfig.cmake" @ONLY ) install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/hwinfoConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/hwinfoConfigVersion.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/lfreist-hwinfoConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/lfreist-hwinfoConfigVersion.cmake" DESTINATION lib/cmake/hwinfo ) -install(EXPORT hwinfoTargets - FILE hwinfoTargets.cmake - NAMESPACE hwinfo:: +install(EXPORT lfreist-hwinfoTargets + FILE lfreist-hwinfoTargets.cmake + NAMESPACE lfreist-hwinfo:: DESTINATION lib/cmake/hwinfo ) diff --git a/README.md b/README.md index 5f540c8..c36c5ad 100644 --- a/README.md +++ b/README.md @@ -228,7 +228,7 @@ Disk 4: 4. Link it in cmake ```cmake add_executable(your_executable your_executable.cpp) - target_link_libraries(your_executable PUBLIC hwinfo::hwinfo) + target_link_libraries(your_executable PUBLIC lfreist-hwinfo::hwinfo) ``` @@ -261,5 +261,5 @@ Disk 4: 4. Link it in cmake ```cmake add_executable(your_executable your_executable.cpp) - target_link_libraries(your_executable PUBLIC hwinfo::hwinfo) + target_link_libraries(your_executable PUBLIC lfreist-hwinfo::hwinfo) ``` diff --git a/cmake/hwinfoConfig.cmake.in b/cmake/hwinfoConfig.cmake.in deleted file mode 100644 index 63fe9b5..0000000 --- a/cmake/hwinfoConfig.cmake.in +++ /dev/null @@ -1,3 +0,0 @@ -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/hwinfoTargets.cmake") diff --git a/cmake/lfreist-hwinfoConfig.cmake.in b/cmake/lfreist-hwinfoConfig.cmake.in new file mode 100644 index 0000000..eaa393b --- /dev/null +++ b/cmake/lfreist-hwinfoConfig.cmake.in @@ -0,0 +1,3 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/lfreist-hwinfoTargets.cmake") diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 23e05df..b0cfbb5 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -14,6 +14,6 @@ endif () add_executable(system_info system_infoMain.cpp) -target_link_libraries(system_info PRIVATE hwinfo::hwinfo fmt::fmt) +target_link_libraries(system_info PRIVATE lfreist-hwinfo::hwinfo fmt::fmt) install(TARGETS system_info) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d36fa53..1233817 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ # ----- hwinfo --------------------------------------------------------------------------------------------------------- add_library(hwinfo INTERFACE) target_include_directories(hwinfo INTERFACE $ $) -add_library(hwinfo::hwinfo ALIAS hwinfo) +add_library(lfreist-hwinfo::hwinfo ALIAS hwinfo) set_target_properties(hwinfo PROPERTIES OUTPUT_NAME "hwinfo") # === Components ======================================================================================================= @@ -30,7 +30,7 @@ if (HWINFO_BATTERY) set_target_properties(hwinfo_battery PROPERTIES OUTPUT_NAME "hwinfo_battery") install(TARGETS hwinfo_battery - EXPORT hwinfoTargets + EXPORT lfreist-hwinfoTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) @@ -62,7 +62,7 @@ if (HWINFO_CPU) set_target_properties(hwinfo_cpu PROPERTIES OUTPUT_NAME "hwinfo_cpu") install(TARGETS hwinfo_cpu - EXPORT hwinfoTargets + EXPORT lfreist-hwinfoTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) @@ -97,7 +97,7 @@ if (HWINFO_DISK) set_target_properties(hwinfo_disk PROPERTIES OUTPUT_NAME "hwinfo_disk") install(TARGETS hwinfo_disk - EXPORT hwinfoTargets + EXPORT lfreist-hwinfoTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) @@ -140,7 +140,7 @@ if (HWINFO_GPU) set_target_properties(hwinfo_gpu PROPERTIES OUTPUT_NAME "hwinfo_gpu") install(TARGETS hwinfo_gpu - EXPORT hwinfoTargets + EXPORT lfreist-hwinfoTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) @@ -175,7 +175,7 @@ if (HWINFO_MAINBOARD) set_target_properties(hwinfo_mainboard PROPERTIES OUTPUT_NAME "hwinfo_mainboard") install(TARGETS hwinfo_mainboard - EXPORT hwinfoTargets + EXPORT lfreist-hwinfoTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) @@ -209,7 +209,7 @@ if (HWINFO_OS) set_target_properties(hwinfo_os PROPERTIES OUTPUT_NAME "hwinfo_os") install(TARGETS hwinfo_os - EXPORT hwinfoTargets + EXPORT lfreist-hwinfoTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) @@ -241,7 +241,7 @@ if (HWINFO_RAM) set_target_properties(hwinfo_ram PROPERTIES OUTPUT_NAME "hwinfo_ram") install(TARGETS hwinfo_ram - EXPORT hwinfoTargets + EXPORT lfreist-hwinfoTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) @@ -253,7 +253,7 @@ endif () install(FILES ${HWINFO_INCLUDE_DIR}/hwinfo/platform.h ${HWINFO_INCLUDE_DIR}/hwinfo/hwinfo.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hwinfo) install(DIRECTORY ${HWINFO_INCLUDE_DIR}/hwinfo/utils DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hwinfo) install(TARGETS hwinfo - EXPORT hwinfoTargets + EXPORT lfreist-hwinfoTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin