Skip to content

Commit 45e0eb0

Browse files
authored
refs #14579 / refs #10543 - fixed compilation on Alpine Linux / added checks for includes / added Alpine to CI (danmar#8313)
1 parent 54b4364 commit 45e0eb0

File tree

9 files changed

+59
-8
lines changed

9 files changed

+59
-8
lines changed

.github/workflows/CI-unixish-docker.yml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@ jobs:
2020

2121
strategy:
2222
matrix:
23-
image: ["ubuntu:24.04", "ubuntu:25.10"]
23+
include:
24+
- image: "ubuntu:24.04"
25+
with_gui: true
26+
full_build: true
27+
- image: "ubuntu:25.10"
28+
with_gui: true
29+
full_build: true
30+
- image: "alpine:3.23"
31+
with_gui: false # it appears FindQt6.cmake is not provided by any package
32+
full_build: false # FIXME: test-signalhandler.cpp fails to build since feenableexcept() is missing
2433
fail-fast: false # Prefer quick result
2534

2635
runs-on: ubuntu-22.04
@@ -45,9 +54,15 @@ jobs:
4554
apt-get install -y cmake g++ make libxml2-utils libpcre3-dev
4655
4756
- name: Install missing software (gui) on latest ubuntu
57+
if: contains(matrix.image, 'ubuntu')
4858
run: |
4959
apt-get install -y qt6-base-dev qt6-charts-dev qt6-tools-dev
5060
61+
- name: Install missing software on Alpine
62+
if: contains(matrix.image, 'alpine')
63+
run: |
64+
apk add cmake make g++ pcre-dev
65+
5166
# needs to be called after the package installation since
5267
# - it doesn't call "apt-get update"
5368
- name: ccache
@@ -57,9 +72,10 @@ jobs:
5772

5873
- name: Run CMake
5974
run: |
60-
cmake -S . -B cmake.output -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
75+
cmake -S . -B cmake.output -Werror=dev -DHAVE_RULES=On -DBUILD_TESTING=On -DBUILD_GUI=${{ matrix.with_gui }} -DWITH_QCHART=On -DBUILD_TRIAGE=${{ matrix.with_gui }} -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
6176
62-
- name: CMake build (with GUI)
77+
- name: CMake build
78+
if: matrix.full_build
6379
run: |
6480
cmake --build cmake.output -- -j$(nproc)
6581
@@ -71,7 +87,7 @@ jobs:
7187

7288
strategy:
7389
matrix:
74-
image: ["ubuntu:24.04", "ubuntu:25.10"]
90+
image: ["ubuntu:24.04", "ubuntu:25.10", "alpine:3.23"]
7591
fail-fast: false # Prefer quick result
7692

7793
runs-on: ubuntu-22.04
@@ -90,21 +106,28 @@ jobs:
90106
apt-get update
91107
apt-get install -y g++ make python3 libxml2-utils libpcre3-dev
92108
109+
- name: Install missing software on Alpine
110+
if: contains(matrix.image, 'alpine')
111+
run: |
112+
apk add make g++ pcre-dev bash python3 libxml2-utils
113+
93114
# needs to be called after the package installation since
94115
# - it doesn't call "apt-get update"
95116
- name: ccache
96117
uses: hendrikmuhs/ccache-action@v1.2
97118
with:
98119
key: ${{ github.workflow }}-${{ matrix.image }}
99120

121+
# /usr/lib/ccache/bin - Alpine Linux
122+
100123
- name: Build cppcheck
101124
run: |
102-
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
125+
export PATH="/usr/lib/ccache/bin:/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
103126
make -j$(nproc) HAVE_RULES=yes CXXOPTS="-Werror"
104127
105128
- name: Build test
106129
run: |
107-
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
130+
export PATH="/usr/lib/ccache/bin:/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
108131
make -j$(nproc) HAVE_RULES=yes CXXOPTS="-Werror" testrunner
109132
110133
- name: Run test

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ include(cmake/compilerCheck.cmake)
1717
include(cmake/versions.cmake)
1818
include(cmake/findDependencies.cmake)
1919
include(cmake/compileroptions.cmake)
20+
include(cmake/includechecks.cmake)
2021
include(cmake/compilerDefinitions.cmake)
2122
include(cmake/buildFiles.cmake)
2223
if(BUILD_GUI)

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ else ifneq ($(HAVE_RULES),)
155155
$(error invalid HAVE_RULES value '$(HAVE_RULES)')
156156
endif
157157

158+
HAVE_EXECINFO_H=$(shell echo "\#include <execinfo.h>" | $(CXX) -c -xc - 2> /dev/null && echo "1" || echo "0")
159+
override CPPFLAGS += -DHAVE_EXECINFO_H=$(HAVE_EXECINFO_H)
160+
158161
override CXXFLAGS += $(CXXOPTS)
159162
override CPPFLAGS += $(CPPOPTS)
160163
override LDFLAGS += $(LDOPTS)

cli/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
file(GLOB hdrs "*.h")
32
file(GLOB srcs "*.cpp")
43
file(GLOB mainfile "main.cpp")

cmake/compilerDefinitions.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ if(NO_WINDOWS_SEH)
6666
add_definitions(-DNO_WINDOWS_SEH)
6767
endif()
6868

69+
if(NOT MSVC)
70+
add_definitions(-DHAVE_EXECINFO_H=${HAVE_EXECINFO_H})
71+
endif()
72+
6973
if(FILESDIR_DEF)
7074
file(TO_CMAKE_PATH "${FILESDIR_DEF}" _filesdir)
7175
add_definitions(-DFILESDIR="${_filesdir}")

cmake/includechecks.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
include(CheckIncludeFileCXX)
2+
3+
if(NOT MSVC)
4+
check_include_file_cxx(execinfo.h HAVE_EXECINFO_H)
5+
if(NOT HAVE_EXECINFO_H)
6+
set(HAVE_EXECINFO_H 0)
7+
endif()
8+
endif()

cmake/printInfo.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ message(STATUS "C++ flags (RelWithDebInfo) = ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
1515
message(STATUS "C++ flags (Debug) = ${CMAKE_CXX_FLAGS_DEBUG}")
1616
message(STATUS "CMAKE_EXE_LINKER_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}")
1717
message(STATUS "CPPCHK_GLIBCXX_DEBUG = ${CPPCHK_GLIBCXX_DEBUG}")
18+
if(DEFINED HAVE_EXECINFO_H)
19+
message(STATUS "HAVE_EXECINFO_H = ${HAVE_EXECINFO_H}")
20+
endif()
1821
get_directory_property(DirCompileDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS)
1922
message(STATUS "COMPILE_DEFINITIONS (global) = ${DirCompileDefs}")
2023
get_directory_property(DirCompileOptions DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_OPTIONS)

lib/config.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,15 @@
206206
#define USE_WINDOWS_SEH
207207
#endif
208208

209-
#if !defined(NO_UNIX_BACKTRACE_SUPPORT) && defined(__GNUC__) && !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__SVR4) && !defined(__QNX__) && !defined(_AIX)
209+
#if !defined(NO_UNIX_BACKTRACE_SUPPORT)
210+
#if defined(HAVE_EXECINFO_H)
211+
#if HAVE_EXECINFO_H
210212
#define USE_UNIX_BACKTRACE_SUPPORT
211213
#endif
214+
#elif defined(__GNUC__) && !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__SVR4) && !defined(__QNX__) && !defined(_AIX)
215+
#define USE_UNIX_BACKTRACE_SUPPORT
216+
#endif
217+
#endif
212218

213219
#if !defined(NO_UNIX_SIGNAL_HANDLING) && defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OS2__)
214220
#define USE_UNIX_SIGNAL_HANDLING

tools/dmake/dmake.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,10 @@ int main(int argc, char **argv)
771771
<< " $(error invalid HAVE_RULES value '$(HAVE_RULES)')\n"
772772
<< "endif\n\n";
773773

774+
// the # needs to be escaped on older make versions
775+
fout << "HAVE_EXECINFO_H=$(shell echo \"\\#include <execinfo.h>\" | $(CXX) -c -xc - 2> /dev/null && echo \"1\" || echo \"0\")\n"
776+
<< "override CPPFLAGS += -DHAVE_EXECINFO_H=$(HAVE_EXECINFO_H)\n\n";
777+
774778
fout << "override CXXFLAGS += $(CXXOPTS)\n";
775779
fout << "override CPPFLAGS += $(CPPOPTS)\n";
776780
fout << "override LDFLAGS += $(LDOPTS)\n\n";

0 commit comments

Comments
 (0)