Skip to content

Commit 2322b10

Browse files
author
Andrew Rabert
authored
Merge pull request #1029 from andrewrabert/compiler-stuff
Compiler stuff
2 parents e8e97f1 + bfdf05f commit 2322b10

24 files changed

Lines changed: 101 additions & 121 deletions

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717
- name: Install build dependencies from debian/control
1818
run: |
1919
sudo apt-get update
20-
sudo apt-get install --yes devscripts equivs
20+
sudo apt-get install --yes devscripts equivs ninja-build
2121
sudo mk-build-deps -i -r -t "apt-get --yes" debian/control
2222
2323
- name: Configure
24-
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug
24+
run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
2525

2626
- name: Build
2727
run: cmake --build build

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.10...3.31 FATAL_ERROR)
22

33
# use a toolchain file if any for Embedded
44
if (EXISTS "${CMAKE_SOURCE_DIR}/toolchain.cmake")

CMakeModules/CompilerFlags.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# MSVC goes totally bananas if we pass it -Wall
22
if(NOT MSVC)
33
enable_if_supported(COMPILER_FLAGS "-Wall")
4+
enable_if_supported(COMPILER_FLAGS "-Wextra")
5+
enable_if_supported(COMPILER_FLAGS "-Wformat")
6+
enable_if_supported(COMPILER_FLAGS "-Werror=format-security")
7+
enable_if_supported(COMPILER_FLAGS "-Wshadow")
8+
enable_if_supported(COMPILER_FLAGS "-Wundef")
9+
enable_if_supported(COMPILER_FLAGS "-Wcast-align")
10+
enable_if_supported(COMPILER_FLAGS "-Wmissing-include-dirs")
11+
enable_if_supported(COMPILER_FLAGS "-Woverloaded-virtual")
12+
enable_if_supported(COMPILER_FLAGS "-Wold-style-cast")
413
endif()
514

615
enable_if_supported(COMPILER_FLAGS "-Wshorten-64-to-32")
@@ -15,7 +24,6 @@ enable_if_supported(COMPILER_FLAGS_THIRD_PARTY "/wd4244")
1524
enable_if_supported(COMPILER_FLAGS_THIRD_PARTY "/wd4267")
1625

1726
enable_if_links(LINK_FLAGS_RELEASE "-flto")
18-
enable_if_links(LINK_FLAGS "-fuse-ld=gold")
1927

2028
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS}")
2129
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS}")

CMakeModules/LinuxConfiguration.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include(GNUInstallDirs)
22

33
find_package(X11)
44
if(X11_FOUND AND X11_Xrandr_FOUND)
5-
include_directories(X11_X11_INCLUDE_PATH X11_Xrandr_INCLUDE_PATH)
5+
include_directories(${X11_X11_INCLUDE_PATH} ${X11_Xrandr_INCLUDE_PATH})
66
set(X11XRANDR_FOUND 1)
77
add_definitions(-DUSE_X11XRANDR)
88
else()

CMakeModules/QtConfiguration.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ message(STATUS "Qt root directory: ${QTROOT}")
1717

1818
list(APPEND CMAKE_FIND_ROOT_PATH ${QTROOT})
1919
list(APPEND CMAKE_PREFIX_PATH ${QTROOT})
20-
include_directories(${QTROOT}/include)
20+
if(IS_DIRECTORY "${QTROOT}/include")
21+
include_directories(${QTROOT}/include)
22+
endif()
2123

2224
set(REQUIRED_QT_VERSION "6.0.0")
2325

src/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ get_property(ALL_SRCS GLOBAL PROPERTY SRCS_LIST)
2828
set(MAIN_SRCS main.cpp)
2929

3030
source_group("Source Files" FILES ${MAIN_SRCS})
31-
set(SOURCES ${MAIN_SRCS} ${ALL_SRCS})
3231

3332
# Set some Objective-C flags.
3433
# We need to force the Language to C instead of C++
3534
# and also make sure that we use ARC
3635
#
37-
foreach(S ${SOURCES})
36+
foreach(S ${ALL_SRCS})
3837
string(REGEX MATCH ".*\\.m$" MATCH_OBJC ${S})
3938
if(MATCH_OBJC)
4039
set_property(SOURCE ${S} PROPERTY COMPILE_FLAGS "-fobjc-arc")
@@ -51,6 +50,9 @@ foreach(sfile in ${ALL_SRCS})
5150
source_group("Source Files\\\\${GNAME}" FILES ${sfile})
5251
endforeach(sfile in ${ALL_SRCS})
5352

53+
# Build core sources as static library for reuse by tests
54+
add_library(jmp_core STATIC ${ALL_SRCS})
55+
5456
file(GLOB_RECURSE RESOURCE_FILES ${CMAKE_SOURCE_DIR}/resources/*)
5557
file(GLOB_RECURSE NATIVE_FILES ${CMAKE_SOURCE_DIR}/native/*)
5658

@@ -125,7 +127,7 @@ if(XCODE)
125127
endif()
126128

127129
get_property(BUNDLED_FILES GLOBAL PROPERTY CONFIG_BUNDLED_FILES)
128-
add_executable(${MAIN_TARGET} WIN32 MACOSX_BUNDLE ${SOURCES} ${BUNDLED_FILES} ${RESOURCE_FILES} ${XCODE_RESOURCES})
130+
add_executable(${MAIN_TARGET} WIN32 MACOSX_BUNDLE ${MAIN_SRCS} ${BUNDLED_FILES} ${RESOURCE_FILES} ${XCODE_RESOURCES})
129131
std_target_properties(${MAIN_TARGET})
130132
set_target_properties(${MAIN_TARGET} PROPERTIES
131133
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/bundle/osx/Info.plist.in
@@ -167,7 +169,8 @@ else()
167169
set(MPVQT_TARGET MpvQt::MpvQt)
168170
endif()
169171

170-
target_link_libraries(${MAIN_TARGET}
172+
# Link core library with all dependencies
173+
target_link_libraries(jmp_core
171174
shared
172175
${MPV_LIBRARY}
173176
${OPENGL_LIBS}
@@ -191,6 +194,8 @@ target_link_libraries(${MAIN_TARGET}
191194
Qt6::DBus
192195
${MPVQT_TARGET}
193196
)
197+
198+
target_link_libraries(${MAIN_TARGET} jmp_core)
194199
install(TARGETS ${MAIN_TARGET} DESTINATION ${INSTALL_BIN_DIR})
195200

196201
set(EXE "${MAIN_NAME}.app")

src/core/ComponentManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "ui/WindowManager.h"
1616
#include "mpris/MprisComponent.h"
1717

18-
#if KONVERGO_OPENELEC
18+
#ifdef KONVERGO_OPENELEC
1919
#include "system/openelec/OESystemComponent.h"
2020
#endif
2121

@@ -63,7 +63,7 @@ void ComponentManager::initialize()
6363
registerComponent(&WindowManager::Get());
6464
registerComponent(&MprisComponent::Get());
6565

66-
#if KONVERGO_OPENELEC
66+
#ifdef KONVERGO_OPENELEC
6767
registerComponent(&OESystemComponent::Get());
6868
#endif
6969

src/display/DisplayComponent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool DisplayComponent::componentInitialize()
6565

6666
if (initializeDisplayManager())
6767
{
68-
QGuiApplication* app = (QGuiApplication*)QGuiApplication::instance();
68+
auto* app = qobject_cast<QGuiApplication*>(QGuiApplication::instance());
6969

7070
connect(app, SIGNAL(screenAdded(QScreen*)), this, SLOT(monitorChange()));
7171
connect(app, SIGNAL(screenRemoved(QScreen*)), this, SLOT(monitorChange()));

src/display/x11/DisplayManagerX11.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ int DisplayManagerX11::getDisplayFromPoint(int x, int y)
192192
goto done;
193193

194194
matches = x >= crtc->x && y >= crtc->y &&
195-
x < crtc->x + (int)crtc->width &&
196-
y < crtc->y + (int)crtc->height;
195+
x < crtc->x + static_cast<int>(crtc->width) &&
196+
y < crtc->y + static_cast<int>(crtc->height);
197197

198198
done:
199199
if (crtc)

src/input/InputCEC.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ bool InputCECWorker::init()
9595
m_configuration.bAutodetectAddress = CEC_DEFAULT_SETTING_AUTODETECT_ADDRESS;
9696
m_configuration.iPhysicalAddress = CEC_PHYSICAL_ADDRESS_TV;
9797
m_configuration.baseDevice = CECDEVICE_AUDIOSYSTEM;
98-
m_configuration.bActivateSource = (uint8_t)SettingsComponent::Get().value(SETTINGS_SECTION_CEC, "activatesource").toBool();
99-
m_configuration.iHDMIPort = (quint8)SettingsComponent::Get().value(SETTINGS_SECTION_CEC, "hdmiport").toInt();
98+
m_configuration.bActivateSource = static_cast<uint8_t>(SettingsComponent::Get().value(SETTINGS_SECTION_CEC, "activatesource").toBool());
99+
m_configuration.iHDMIPort = static_cast<quint8>(SettingsComponent::Get().value(SETTINGS_SECTION_CEC, "hdmiport").toInt());
100100

101101
// open libcec
102-
m_adapter = (ICECAdapter*)CECInitialise(&m_configuration);
102+
m_adapter = static_cast<ICECAdapter*>(CECInitialise(&m_configuration));
103103
if (!m_adapter)
104104
{
105105
qCritical() << "Unable to initialize libCEC.";
@@ -343,7 +343,7 @@ void InputCECWorker::CecCommand(void *cbParam, const cec_command *command)
343343
}
344344
}
345345

346-
cmdString = cec->getCommandString((cec_user_control_code)command->parameters[0]);
346+
cmdString = cec->getCommandString(static_cast<cec_user_control_code>(command->parameters[0]));
347347

348348
if (!cmdString.isEmpty())
349349
{
@@ -382,6 +382,7 @@ void InputCECWorker::CecCommand(void *cbParam, const cec_command *command)
382382
///////////////////////////////////////////////////////////////////////////////////////////////////
383383
void InputCECWorker::CecAlert(void *cbParam, const libcec_alert type, const libcec_parameter param)
384384
{
385+
(void)param;
385386
bool reopen = false;
386387

387388
switch (type)

0 commit comments

Comments
 (0)