@cryptotaxi247 / netdata-1 / commits / cf681acd0

Fix up CMake feature handling for Windows. (#18229)

* Fix up CMake feature handling for Windows. * Better handle detection of Go on Windows. * Provide Windows copy of Go for Windows build. * Explicitly set GOROOT in environment. * Explicitly disable Prometheus remote write exporter. * Add note about DEFAULT_FEATURE_STATE_OPTION.

Austin S. Hemmelgarn committed Jul 29, 2024 at 14:07 UTC cf681acd0fe0b958706d61eb521b7c9d534e1ec2
4 files changed +32 -6
.github/workflows/build.yml
+10
@@ -1065,6 +1065,16 @@ jobs:
1065 with:
1066 submodules: recursive
1067 lfs: true
1068 + - name: Set Up Go
1069 + id: golang
1070 + if: needs.file-check.outputs.run == 'true'
1071 + uses: actions/setup-go@v5
1072 + with:
1073 + go-version: "^1.22"
1074 + - name: Set GOROOT
1075 + id: goroot
1076 + if: needs.file-check.outputs.run == 'true'
1077 + run: Add-Content -Path "$env:GITHUB_ENV" -Value "GOROOT=$(go.exe env GOROOT)"
1078 - name: Set Up Dependencies
1079 id: deps
1080 if: needs.file-check.outputs.run == 'true'
CMakeLists.txt
+4 -2
@@ -141,6 +141,8 @@ endif()
141
142 # This is intended to make life easier for developers who are working on one
143 # specific feature.
144 +#
145 +# NOTE: DO NOT USE THIS OPTION FOR PRODUCTION BUILDS.
146 option(DEFAULT_FEATURE_STATE "Specify the default state for most optional features" True)
147 mark_as_advanced(DEFAULT_FEATURE_STATE)
148
@@ -151,10 +153,10 @@ option(ENABLE_ML "Enable machine learning features" ${DEFAULT_FEATURE_STATE})
153 option(ENABLE_DBENGINE "Enable dbengine metrics storage" True)
154
155 # Data collection plugins
154 -option(ENABLE_PLUGIN_APPS "Enable per-process resource usage monitoring" ${DEFAULT_FEATURE_STATE})
156 option(ENABLE_PLUGIN_GO "Enable metric collectors written in Go" ${DEFAULT_FEATURE_STATE})
157
157 -cmake_dependent_option(ENABLE_PLUGIN_CUPS "Enable CUPS monitoring" ${DEFAULT_FEATURE_STATE} "OS_LINUX OR OS_FREEBSD OR OS_MACOS" False)
158 +cmake_dependent_option(ENABLE_PLUGIN_APPS "Enable per-process resource usage monitoring" ${DEFAULT_FEATURE_STATE} "NOT OS_WINDOWS" False)
159 +cmake_dependent_option(ENABLE_PLUGIN_CUPS "Enable CUPS monitoring" ${DEFAULT_FEATURE_STATE} "NOT OS_WINDOWS" False)
160
161 cmake_dependent_option(ENABLE_PLUGIN_FREEIPMI "Enable IPMI monitoring" ${DEFAULT_FEATURE_STATE} "OS_LINUX OR OS_FREEBSD" False)
162
packaging/cmake/Modules/FindGo.cmake
+15 -2
@@ -15,8 +15,21 @@ if(GO_FOUND)
15 return()
16 endif()
17
18 -# Two passes are needed here so that we prefer a copy in `/usr/local/go/bin` over a system copy.
19 -find_program(GO_EXECUTABLE go PATHS /usr/local/go/bin DOC "Go toolchain" NO_DEFAULT_PATH)
18 +# The complexity below is needed to account for the complex rules we use for finding the Go install.
19 +#
20 +# If GOROOT is set, we honor that. Otherwise, we check known third-party install paths for the platform in question
21 +# and fall back to looking in PATH. For the specific case of MSYS2, we prefer a Windows install over an MSYS2 install.
22 +if(DEFINED $ENV{GOROOT})
23 + find_program(GO_EXECUTABLE go PATHS "$ENV{GOROOT}/bin" DOC "Go toolchain" NO_DEFAULT_PATH)
24 +elseif(OS_WINDOWS)
25 + if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
26 + find_program(GO_EXECUTABLE go PATHS C:/go/bin "C:/Program Files/go/bin" DOC "Go toolchain" NO_DEFAULT_PATH)
27 + else()
28 + find_program(GO_EXECUTABLE go PATHS /c/go/bin "/c/Program Files/go/bin" /mingw64/bin /ucrt64/bin /clang64/bin DOC "Go toolchain" NO_DEFAULT_PATH)
29 + endif()
30 +else()
31 + find_program(GO_EXECUTABLE go PATHS /usr/local/go/bin DOC "Go toolchain" NO_DEFAULT_PATH)
32 +endif()
33 find_program(GO_EXECUTABLE go DOC "Go toolchain")
34
35 if (GO_EXECUTABLE)
packaging/windows/compile-on-windows.sh
+3 -2
@@ -40,11 +40,12 @@ ${GITHUB_ACTIONS+echo "::group::Configuring"}
40 -DCMAKE_C_FLAGS="-fstack-protector-all -O0 -ggdb -Wall -Wextra -Wno-char-subscripts -Wa,-mbig-obj -pipe -DNETDATA_INTERNAL_CHECKS=1 -D_FILE_OFFSET_BITS=64 -D__USE_MINGW_ANSI_STDIO=1" \
41 -DBUILD_FOR_PACKAGING=On \
42 -DNETDATA_USER="${USER}" \
43 - -DDEFAULT_FEATURE_STATE=Off \
44 - -DENABLE_H2O=Off \
43 -DENABLE_ACLK=On \
44 -DENABLE_CLOUD=On \
45 + -DENABLE_H2O=Off \
46 -DENABLE_ML=On \
47 + -DENABLE_PLUGIN_GO=On \
48 + -DENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE=Off \
49 -DENABLE_BUNDLED_JSONC=On \
50 -DENABLE_BUNDLED_PROTOBUF=Off \
51 ${EXTRA_CMAKE_OPTIONS:-}