lfreist/hwinfo

windows add hwinfo as submodule compile failed

Closed this issue · 1 comments

[cmake]   failed with:
[cmake] 
[cmake]    ninja: error: build.ninja:307: multiple rules generate lib/hwinfo_battery.lib

build.ninja line 220-234

#############################################
# Link the shared library hwinfo_battery.dll

build hwinfo_battery.dll lib\hwinfo_battery.lib: CXX_SHARED_LIBRARY_LINKER__hwinfo_battery_Release submodule\hwinfo\src\CMakeFiles\hwinfo_battery.dir\battery.cpp.obj submodule\hwinfo\src\CMakeFiles\hwinfo_battery.dir\apple\battery.cpp.obj submodule\hwinfo\src\CMakeFiles\hwinfo_battery.dir\linux\battery.cpp.obj submodule\hwinfo\src\CMakeFiles\hwinfo_battery.dir\windows\battery.cpp.obj submodule\hwinfo\src\CMakeFiles\hwinfo_battery.dir\windows\utils\wmi_wrapper.cpp.obj
  LANGUAGE_COMPILE_FLAGS = /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /O2 /Ob2 /DNDEBUG
  LINK_FLAGS = /machine:x64 /INCREMENTAL:NO  /DEF:submodule\hwinfo\src\CMakeFiles\hwinfo_battery.dir\.\exports.def
  LINK_LIBRARIES = kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
  OBJECT_DIR = submodule\hwinfo\src\CMakeFiles\hwinfo_battery.dir
  POST_BUILD = C:\Windows\system32\cmd.exe /C "cd /D D:\dev\8k\out\build\windows-x64-Release\submodule\hwinfo\src && "C:\Program Files\PowerShell\7\pwsh.exe" -noprofile -executionpolicy Bypass -file D:/dev/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary D:/dev/8k/out/build/windows-x64-Release/hwinfo_battery.dll -installedDir D:/dev/8k/out/build/windows-x64-Release/vcpkg_installed/x64-windows/bin -OutVariable out"
  PRE_LINK = C:\Windows\system32\cmd.exe /C ""C:\Program Files\CMake\bin\cmake.exe" -E __create_def D:\dev\8k\out\build\windows-x64-Release\submodule\hwinfo\src\CMakeFiles\hwinfo_battery.dir\.\exports.def D:\dev\8k\out\build\windows-x64-Release\submodule\hwinfo\src\CMakeFiles\hwinfo_battery.dir\.\exports.def.objs && cd D:\dev\8k\out\build\windows-x64-Release"
  RESTAT = 1
  TARGET_COMPILE_PDB = submodule\hwinfo\src\CMakeFiles\hwinfo_battery.dir\
  TARGET_FILE = hwinfo_battery.dll
  TARGET_IMPLIB = lib\hwinfo_battery.lib
  TARGET_PDB = hwinfo_battery.pdb

build.ninja line 296-307

#############################################
# Link the static library lib\hwinfo_battery.lib

build lib\hwinfo_battery.lib: CXX_STATIC_LIBRARY_LINKER__hwinfo_battery_static_Release submodule\hwinfo\src\CMakeFiles\hwinfo_battery_static.dir\battery.cpp.obj submodule\hwinfo\src\CMakeFiles\hwinfo_battery_static.dir\apple\battery.cpp.obj submodule\hwinfo\src\CMakeFiles\hwinfo_battery_static.dir\linux\battery.cpp.obj submodule\hwinfo\src\CMakeFiles\hwinfo_battery_static.dir\windows\battery.cpp.obj submodule\hwinfo\src\CMakeFiles\hwinfo_battery_static.dir\windows\utils\wmi_wrapper.cpp.obj
  LANGUAGE_COMPILE_FLAGS = /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /O2 /Ob2 /DNDEBUG
  LINK_FLAGS = /machine:x64
  OBJECT_DIR = submodule\hwinfo\src\CMakeFiles\hwinfo_battery_static.dir
  POST_BUILD = cd .
  PRE_LINK = cd .
  TARGET_COMPILE_PDB = submodule\hwinfo\src\CMakeFiles\hwinfo_battery_static.dir\hwinfo_battery_static.pdb
  TARGET_FILE = lib\hwinfo_battery.lib
  TARGET_PDB = lib\hwinfo_battery.pdb

submodule work fine in linux, but failed in windows.

I try commit 59a0b534b6422bca342ef37b11fc84311638f432, it is ok.

And if i use cmake install, hwinfo will install to my application install path, which i dont want. May be need add PROJECT_IS_TOP_LEVEL for install

By the way, can you add hwinfo to vcpkg?

By the way, can you add hwinfo to vcpkg?

I will submit a PR for this.

Update: https://github.com/Hlongyu/vcpkg/tree/add_hwinfo waitting for #103 merge