Skip to content

Commit 39b2f63

Browse files
authored
Merge pull request #737 from Pulse-Eight/fix/windows-install-layout
windows: use the GNUInstallDirs layout so consumers need no patches
2 parents cb353b4 + 5e10abd commit 39b2f63

11 files changed

Lines changed: 44 additions & 30 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ python windows\create-installer.py -ni # build libCEC + LibCecSharp, no i
5555
python windows\create-installer.py -vs # generate Visual Studio project files for development
5656
```
5757

58-
Useful flags: `-a {x64,x86,arm,arm64}` (default x64), `-m {Release,Debug,RelWithDebInfo}` (default Release), `-t <toolchain>` (e.g. `2019c`, `2022`, `2026c`), `-nc` (no clean / incremental), `-ne` (skip EventGhost plugin), `-ni` (no installer). Build artifacts land in `build\<target>\<arch>\`. The orchestrator's structure is in `windows/toolchain.py` (toolchain/arch enums) and `windows/mixins.py` / `windows/pathbuilder.py` (helpers).
58+
Useful flags: `-a {x64,x86,arm,arm64}` (default x64), `-m {Release,Debug,RelWithDebInfo}` (default Release), `-t <toolchain>` (e.g. `2019c`, `2022`, `2026c`), `-nc` (no clean / incremental), `-ne` (skip EventGhost plugin), `-ni` (no installer). Build artifacts land in `build\<target>\<arch>\`, laid out per GNUInstallDirs like every other platform: `bin\` (cec.dll, cec-client.exe, cecc-client.exe, cec.pdb), `lib\` (the import library `cec.lib`, plus `cec-static.lib` and `cmake\libcec\`), `include\libcec\`. The NSIS scripts take their payload from those subdirectories; what the *installer* then lays down under `Program Files` is unchanged and still flat. Two things to keep in mind: the DLL's import library and the static library are both `cec.lib` by default, so the static target is renamed `cec-static` on Windows to stop it overwriting the import library in the build **and** install trees; and the Windows layout used to be flat (everything in the prefix root), which is what downstream consumers such as Kodi's `FindCEC.cmake` had to patch around — keep it GNUInstallDirs-conformant so they don't have to. The orchestrator's structure is in `windows/toolchain.py` (toolchain/arch enums) and `windows/mixins.py` / `windows/pathbuilder.py` (helpers).
5959

6060
**Code signing** is Azure Artifact Signing (formerly Trusted Signing), driven by `windows/codesigner.py` and enabled by the presence of `AZURE_SIGNING_JSON` — the `/dmdf` metadata blob holding Endpoint, CodeSigningAccountName and CertificateProfileName. The dlib comes from the `Microsoft.ArtifactSigning.Client` NuGet package, found by globbing `C:\jenkins-deps\Microsoft.ArtifactSigning.Client*` (override with `AZURE_SIGNING_DLIB`), and it is native x64 so all signing goes through the x64 `signtool.exe`. Credentials are read from `AZURE_TENANT_ID`/`AZURE_CLIENT_ID`/`AZURE_CLIENT_SECRET` in the environment by the Azure SDK; nothing is stored in the repo. `create-installer.py` signs the payload before makensis packages it and the installer afterwards, and writes `support/private/sign-binary.cmd` (a gitignored path) that `project/libCEC.nsi` already looks for to sign the uninstaller. Without `AZURE_SIGNING_JSON` the build says so and produces unsigned output.
6161

docs/README.windows.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ toolchain (`node-gyp`). Point it at libCEC's headers and import library with the
3030
```
3131
cd src\nodejs
3232
set LIBCEC_INCLUDE_DIR=..\..\include
33-
set LIBCEC_LIB_DIR=..\..\build\Release\x64
33+
set LIBCEC_LIB_DIR=..\..\build\Release\x64\lib
3434
npm install
3535
```
3636
`create-installer.py` does exactly this and stages the result (for x64 builds

project/nsis/libcec-pdb.nsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Section "libCEC debug symbols" SecPDB
33
SectionIn 1
44

55
SetOutPath "$INSTDIR"
6-
File "${BINARY_SOURCE_DIR}\cec.pdb"
6+
File "${BINARY_SOURCE_DIR}\bin\cec.pdb"
77

88
SetOutPath "$INSTDIR\net8.0"
99
File /nonfatal "${BINARY_SOURCE_DIR}\net8.0\cec-tray.pdb"

project/nsis/nodejs.nsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Section "libCEC for Node.js" SecNodeJs
77
; its own directory without the install dir being on PATH.
88
SetOutPath "$INSTDIR\nodejs\build\Release"
99
File "${BINARY_SOURCE_DIR}\nodejs\build\Release\cec_native.node"
10-
File "${BINARY_SOURCE_DIR}\cec.dll"
10+
File "${BINARY_SOURCE_DIR}\bin\cec.dll"
1111

1212
SetOutPath "$INSTDIR\nodejs\lib"
1313
File "${BINARY_SOURCE_DIR}\nodejs\lib\*.js"

project/nsis/sections.nsh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Section "libCEC" SecLibCec
5151
File "..\docs\README.windows.md"
5252
File "..\support\windows\tv_on.cmd"
5353
File "..\support\windows\tv_off.cmd"
54-
File "${BINARY_SOURCE_DIR}\cec.dll"
54+
File "${BINARY_SOURCE_DIR}\bin\cec.dll"
5555
File "/oname=p8-logo.ico" "favicon.ico"
5656

5757
; Copy the headers
@@ -106,7 +106,7 @@ Section "libCEC for Python" SecPythonCec
106106
; Copy binaries
107107
SetOutPath "$INSTDIR\python\cec"
108108

109-
File "${BINARY_SOURCE_DIR}\cec.dll"
109+
File "${BINARY_SOURCE_DIR}\bin\cec.dll"
110110
File "${BINARY_SOURCE_DIR}\python\cec\_pycec.pyd"
111111
File "${BINARY_SOURCE_DIR}\python\cec\cec.py"
112112
!ifdef NSIS_X86
@@ -122,7 +122,7 @@ Section "libCEC for .Net" SecDotNetCore
122122

123123
; Copy binaries (pure C# LibCecSharp; no Ijwhost.dll / runtimeconfig for the library)
124124
SetOutPath "$INSTDIR\net8.0"
125-
File "${BINARY_SOURCE_DIR}\cec.dll"
125+
File "${BINARY_SOURCE_DIR}\bin\cec.dll"
126126
File "${BINARY_SOURCE_DIR}\net8.0\LibCecSharp.deps.json"
127127
File "${BINARY_SOURCE_DIR}\net8.0\LibCecSharp.dll"
128128
File "${BINARY_SOURCE_DIR}\net8.0\LibCecSharp.xml"
@@ -145,8 +145,8 @@ Section "libCEC client (cec-client)" SecCecClient
145145

146146
; Copy binaries
147147
SetOutPath "$INSTDIR"
148-
File "${BINARY_SOURCE_DIR}\cec-client.exe"
149-
File "${BINARY_SOURCE_DIR}\cecc-client.exe"
148+
File "${BINARY_SOURCE_DIR}\bin\cec-client.exe"
149+
File "${BINARY_SOURCE_DIR}\bin\cecc-client.exe"
150150

151151
; Start menu item
152152
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application

src/cec-client/CMakeLists.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ include_directories(${PROJECT_SOURCE_DIR}
7676
# write env.h
7777
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/env.h.in ${CMAKE_CURRENT_SOURCE_DIR}/env.h)
7878

79-
if (WIN32)
80-
install(TARGETS cec-client
81-
DESTINATION .)
82-
else()
83-
install(TARGETS cec-client
84-
DESTINATION ${CMAKE_INSTALL_BINDIR})
85-
endif()
79+
# bin/ on every platform: Windows used to drop executables in the prefix root,
80+
# which left the install tree half GNUInstallDirs and half flat
81+
install(TARGETS cec-client
82+
DESTINATION ${CMAKE_INSTALL_BINDIR})

src/cecc-client/CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ include_directories(${PROJECT_SOURCE_DIR}
4545
# write env.h
4646
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/env.h.in ${CMAKE_CURRENT_SOURCE_DIR}/env.h)
4747

48-
if (WIN32)
49-
install(TARGETS cecc-client
50-
DESTINATION .)
51-
else()
52-
install(TARGETS cecc-client
53-
DESTINATION ${CMAKE_INSTALL_BINDIR})
54-
endif()
48+
# bin/ on every platform, as for cec-client
49+
install(TARGETS cecc-client
50+
DESTINATION ${CMAKE_INSTALL_BINDIR})

src/libcec/CMakeLists.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,21 @@ target_link_libraries(cec-shared ${cec_depends})
213213

214214

215215
if(NOT DISABLE_STATIC)
216+
# Windows names the DLL's import library cec.lib too, so a static library
217+
# called cec overwrites it - in the build tree and again on install, with
218+
# whichever target links last winning. Anything then linking the install tree
219+
# gets unresolved __imp_libcec_* symbols, or silently links libCEC statically.
220+
# Unix has no such clash: libcec.a next to libcec.so.
221+
set(CEC_STATIC_NAME cec)
222+
if(WIN32)
223+
set(CEC_STATIC_NAME cec-static)
224+
endif()
225+
216226
add_library(cec-static STATIC $<TARGET_OBJECTS:libobj>)
217227
set_target_properties(cec-static PROPERTIES
218228
VERSION ${LIBCEC_VERSION_MAJOR}.${LIBCEC_VERSION_MINOR}.${LIBCEC_VERSION_PATCH}
219229
SOVERSION ${LIBCEC_VERSION_MAJOR}
220-
OUTPUT_NAME cec)
230+
OUTPUT_NAME ${CEC_STATIC_NAME})
221231
target_link_libraries(cec-static ${cec_depends})
222232
endif()
223233

@@ -248,10 +258,13 @@ if(NOT DISABLE_STATIC)
248258
list(APPEND CEC_INSTALL_TARGETS cec-static)
249259
endif()
250260

261+
# ARCHIVE is its own destination rather than LIB_DESTINATION: on Windows that is
262+
# bin/, which is where the .dll belongs but not the import library. Everywhere
263+
# else the two are the same value, so this only moves the Windows .lib.
251264
install(TARGETS ${CEC_INSTALL_TARGETS}
252265
EXPORT libcec
253266
RUNTIME DESTINATION ${LIB_DESTINATION}
254-
ARCHIVE DESTINATION ${LIB_DESTINATION}
267+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
255268
LIBRARY DESTINATION ${LIB_DESTINATION})
256269

257270
include(CMakePackageConfigHelpers)

src/libcec/cmake/CheckPlatformSupport.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ set(RPI_LIB_DIR "" CACHE FILEPATH "path to Raspberry Pi libs")
4040
if(WIN32)
4141
# Windows
4242
add_definitions(-DTARGET_WINDOWS -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_WINSOCKAPI_)
43-
set(LIB_DESTINATION ".")
43+
# cec.dll goes to bin/, matching the include/ and lib/cmake/libcec the rest of
44+
# the install already uses. It used to land in the prefix root, which every
45+
# consumer expecting the GNUInstallDirs layout had to patch around.
46+
# GNUInstallDirs is included before this file, so this is "bin" by default.
47+
set(LIB_DESTINATION "${CMAKE_INSTALL_BINDIR}")
4448

4549
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
4650

src/nodejs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ installed *USB-CEC Adapter* SDK). From a repo build:
3838

3939
```
4040
set LIBCEC_INCLUDE_DIR=..\..\include
41-
set LIBCEC_LIB_DIR=..\..\build\Release\x64
41+
set LIBCEC_LIB_DIR=..\..\build\Release\x64\lib
4242
npm install
4343
```
4444

0 commit comments

Comments
 (0)