-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
134 changed files
with
1,726 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
*~ | ||
*.pyc | ||
*.orig | ||
*.swp | ||
__pycache__/ | ||
test/build/linux | ||
test/build/mac | ||
test/build/win | ||
.vscode | ||
*.aps | ||
.DS_Store | ||
.idea/ | ||
.vs/ | ||
out/ | ||
cmake-build*/ | ||
source/version.h | ||
Buildinfo.properties | ||
CMakeSettings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
BUILD_NUMBER=@QTCOMMON_BUILD_NUMBER@ | ||
VERSION_NUMBER=@QTCOMMON_MAJOR_VERSION@.@QTCOMMON_MINOR_VERSION@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,53 @@ | ||
cmake_minimum_required(VERSION 3.11) | ||
cmake_minimum_required(VERSION 3.24) | ||
project(QtCommon) | ||
|
||
# Define version information | ||
set(QTCOMMON_MAJOR_VERSION 3) | ||
set(QTCOMMON_MINOR_VERSION 12) | ||
if (NOT QTCOMMON_PATCH_NUMBER) | ||
set(QTCOMMON_PATCH_NUMBER 0) | ||
endif () | ||
if (NOT QTCOMMON_BUILD_NUMBER) | ||
set(QTCOMMON_BUILD_NUMBER 0) | ||
endif () | ||
string(TIMESTAMP DATE "\"%m/%d/%Y\"") | ||
string(TIMESTAMP YEAR "\"%Y\"") | ||
|
||
# Check if top-level project before attempting to query Qt dependencies | ||
# This allows for consuming projects to override the Qt version used such as using | ||
# Qt6 instead of Qt5 | ||
if (PROJECT_IS_TOP_LEVEL) | ||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") | ||
include(dev_tools) | ||
include(devtools_qt_helper) | ||
endif () | ||
|
||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Buildinfo.properties.in" "${CMAKE_CURRENT_SOURCE_DIR}/Buildinfo.properties") | ||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/source/version.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/source/version.h") | ||
|
||
# Custom Widgets | ||
add_subdirectory(custom_widgets) | ||
add_subdirectory(source/qt_common/custom_widgets) | ||
|
||
# Utilities | ||
add_subdirectory(utils) | ||
add_subdirectory(source/qt_common/utils) | ||
|
||
if (BUILD_TESTS) | ||
# Tests | ||
add_subdirectory(test) | ||
endif () | ||
|
||
# Packaging | ||
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) | ||
set(CPACK_COMPONENTS_GROUPING IGNORE) | ||
|
||
if (${CMAKE_BUILD_TYPE} MATCHES "Debug") | ||
set(CPACK_ARCHIVE_GUITEST_FILE_NAME "QtCommon_GuiTest_Debug-${QTCOMMON_MAJOR_VERSION}.${QTCOMMON_MINOR_VERSION}.${QTCOMMON_PATCH_NUMBER}.${QTCOMMON_BUILD_NUMBER}") | ||
else () | ||
set(CPACK_ARCHIVE_GUITEST_FILE_NAME "QtCommon_GuiTest_${QTCOMMON_MAJOR_VERSION}.${QTCOMMON_MINOR_VERSION}.${QTCOMMON_PATCH_NUMBER}.${QTCOMMON_BUILD_NUMBER}") | ||
endif () | ||
|
||
include(CPack) | ||
|
||
cpack_add_component(GuiTest | ||
DISPLAY_NAME "Gui Test" | ||
DESCRIPTION "QtCommon Gui Tests") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
####################################################################################################################### | ||
### Copyright (c) 2019-2023 Advanced Micro Devices, Inc. All rights reserved. | ||
### \author AMD Developer Tools Team | ||
####################################################################################################################### | ||
|
||
cmake_minimum_required(VERSION 3.10) | ||
|
||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
string(REPLACE " /W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
endif () | ||
|
||
# Apply options to a developer tools target. | ||
# These options are hard requirements to build. If they cannot be applied, we | ||
# will need to fix the offending target to ensure it complies. | ||
function(devtools_target_options name) | ||
|
||
set_target_properties(${name} PROPERTIES | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED ON) | ||
|
||
get_target_property(target_type ${name} TYPE) | ||
if (${target_type} STREQUAL "INTERFACE_LIBRARY") | ||
return() | ||
endif () | ||
|
||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") | ||
|
||
target_compile_options(${name} | ||
PRIVATE | ||
-Wall | ||
-Werror | ||
-Wextra | ||
-Wno-unused-variable | ||
-Wno-missing-field-initializers | ||
-Wno-unknown-pragmas | ||
) | ||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
target_compile_options(${name} | ||
PRIVATE | ||
/W4 | ||
/WX | ||
/MP | ||
|
||
# disable warning C4201: nonstandard extension used: nameless struct/union | ||
/wd4201 | ||
|
||
# TODO this warning is caused by the QT header files - use pragma to disable at source | ||
# disable warning C4127: conditional expression is constant | ||
/wd4127 | ||
|
||
# Disable warnings about deprecated features | ||
# See: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=vs-2019 | ||
# This happens when using later versions of Qt than RDP defaults to. | ||
/wd4996 | ||
) | ||
else () | ||
|
||
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} is not supported!") | ||
|
||
endif () | ||
|
||
# GNU specific flags | ||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||
target_compile_options(${name} PRIVATE -Wno-maybe-uninitialized) | ||
endif () | ||
|
||
if (UNIX AND NOT APPLE) | ||
target_compile_definitions(${name} | ||
PRIVATE | ||
_LINUX | ||
|
||
# Use _DEBUG on Unix for Debug Builds (defined automatically on Windows) | ||
$<$<CONFIG:Debug>:_DEBUG> | ||
) | ||
endif () | ||
|
||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
####################################################################################################################### | ||
### Copyright (c) 2019-2021 Advanced Micro Devices, Inc. All rights reserved. | ||
### @author AMD Developer Tools Team | ||
####################################################################################################################### | ||
|
||
cmake_minimum_required(VERSION 3.10) | ||
|
||
# linuxdeployqt | ||
if (UNIX AND NOT APPLE) | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
linuxdeployqt | ||
URL "http://bdcartifactory.amd.com/artifactory/DevToolsBDC/Assets/radeon_developer_panel/linuxdeployqt.zip" | ||
SOURCE_DIR ${PROJECT_SOURCE_DIR}/external/linuxdeployqt | ||
) | ||
FetchContent_MakeAvailable(linuxdeployqt) | ||
|
||
find_program(LINUXDEPLOYQT "linuxdeployqt" HINTS "${PROJECT_SOURCE_DIR}/external/linuxdeployqt") | ||
if (LINUXDEPLOYQT) | ||
message(STATUS "Found linuxdeployqt: ${LINUXDEPLOYQT}") | ||
else () | ||
message(ERROR "linuxdeployqt not found but is required for build") | ||
endif () | ||
endif () | ||
|
||
# Attempt to automatically find Qt on the local machine | ||
if (UNIX AND NOT APPLE) | ||
find_package(Qt6 QUIET COMPONENTS Core Widgets Network Gui Test GuiPrivate) | ||
else () | ||
find_package(Qt6 QUIET COMPONENTS Core Widgets Network Gui Test) | ||
endif () | ||
|
||
if (Qt6_DIR) | ||
message(STATUS "Qt6 cmake package found at ${Qt6_DIR}") | ||
endif () | ||
|
||
if (NOT Qt6_DIR) | ||
# Attempt to query Qt 5 | ||
if (UNIX AND NOT APPLE) | ||
find_package(Qt5 QUIET COMPONENTS Core Widgets Network Gui Test X11Extras) | ||
else () | ||
find_package(Qt5 QUIET COMPONENTS Core Widgets Network Gui Test) | ||
endif () | ||
|
||
if (Qt5_DIR) | ||
message(STATUS "Qt5 cmake package found at ${Qt5_DIR}") | ||
else () | ||
message(WARNING "Qt5 cmake package not found. Please specify Qt5_DIR manually or in the CMAKE_PREFIX_PATH") | ||
endif () | ||
endif () | ||
|
||
|
||
|
||
if (Qt5_DIR OR Qt6_DIR) | ||
####################################################################################################################### | ||
# Setup the INSTALL target to include Qt DLLs | ||
## | ||
# Logic used to find and use Qt's internal deployment tool to copy Qt-based dependencies and DLLs upon building, so | ||
# that we can run the application from an IDE and so that we just have a simple build directory with all dependencies | ||
# already deployed that we can easily distribute | ||
####################################################################################################################### | ||
get_target_property(_qmake_executable Qt::qmake IMPORTED_LOCATION) | ||
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) | ||
if (WIN32) | ||
find_program(DEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}") | ||
elseif (APPLE) | ||
find_program(DEPLOYQT_EXECUTABLE macdeployqt HINTS "${_qt_bin_dir}") | ||
elseif (UNIX) | ||
find_program(QT_QMAKE_EXECUTABLE qmake HINTS "${_qt_bin_dir}") | ||
set(DEPLOYQT_EXECUTABLE ${LINUXDEPLOYQT}) | ||
endif () | ||
|
||
function(deploy_qt_build target include_mac) | ||
if (DEPLOYQT_EXECUTABLE) | ||
if (WIN32) | ||
if (Qt6_DIR) | ||
set(DEPLOYQT_POST_BUILD_COMMAND | ||
${DEPLOYQT_EXECUTABLE} $<TARGET_FILE:${target}> -verbose 0 --release --no-compiler-runtime --no-translations | ||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) | ||
else () | ||
set(DEPLOYQT_POST_BUILD_COMMAND | ||
${DEPLOYQT_EXECUTABLE} $<TARGET_FILE:${target}> -verbose 0 --no-compiler-runtime --no-translations --no-angle --no-system-d3d-compiler --no-opengl-sw | ||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) | ||
endif () | ||
elseif (UNIX AND NOT APPLE) | ||
set(DEPLOYQT_POST_BUILD_COMMAND | ||
${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${EXTERNAL_DIR}/libtraceevent/lib:${EXTERNAL_DIR}/libtracefs/lib | ||
${DEPLOYQT_EXECUTABLE} $<TARGET_FILE:${target}> -qmake=${QT_QMAKE_EXECUTABLE} -verbose=0 -unsupported-allow-new-glibc | ||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) | ||
elseif (include_mac) | ||
set(DEPLOYQT_POST_BUILD_COMMAND | ||
${DEPLOYQT_EXECUTABLE} $<TARGET_FILE_NAME:${target}>.app -verbose=0 -no-strip | ||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) | ||
endif () | ||
|
||
# Deploy Qt to build directory after a successful build | ||
add_custom_command( | ||
TARGET ${target} POST_BUILD | ||
COMMAND ${DEPLOYQT_POST_BUILD_COMMAND} | ||
) | ||
endif () | ||
endfunction() | ||
|
||
function(deploy_qt_install_hook target component) | ||
if (DEPLOYQT_EXECUTABLE) | ||
deploy_qt_build(${target} TRUE) | ||
|
||
set(target_file_dir "$<TARGET_FILE_DIR:${target}>") | ||
|
||
# Handle installation of Qt dependencies | ||
if (WIN32) | ||
# Debug dlls end with a `d.dll` | ||
set(qt_suffix "$<$<CONFIG:Debug>:d>.dll") | ||
|
||
# Due to windows requiring DLLs be shipped adjacent we must be explicit here... | ||
# TODO: Maybe eventually we could look into some sort of manifest file? | ||
install(FILES | ||
${target_file_dir}/Qt5Core${qt_suffix} | ||
${target_file_dir}/Qt5Gui${qt_suffix} | ||
${target_file_dir}/Qt5Svg${qt_suffix} | ||
${target_file_dir}/Qt5Widgets${qt_suffix} | ||
DESTINATION . COMPONENT ${component}) | ||
|
||
install(FILES ${target_file_dir}/Qt5Network${qt_suffix} DESTINATION . COMPONENT ${component} OPTIONAL) | ||
|
||
install(DIRECTORY ${target_file_dir}/iconengines DESTINATION . COMPONENT ${component}) | ||
install(DIRECTORY ${target_file_dir}/imageformats DESTINATION . COMPONENT ${component}) | ||
install(DIRECTORY ${target_file_dir}/platforms DESTINATION . COMPONENT ${component}) | ||
install(DIRECTORY ${target_file_dir}/styles DESTINATION . COMPONENT ${component}) | ||
elseif (UNIX AND NOT APPLE) | ||
# This is only needed for Linux as Apple platforms deploy Qt into the app bundle | ||
install(FILES | ||
${target_file_dir}/qt.conf | ||
DESTINATION . COMPONENT ${component}) | ||
install(DIRECTORY ${target_file_dir}/lib DESTINATION . COMPONENT ${component}) | ||
install(DIRECTORY ${target_file_dir}/plugins DESTINATION . COMPONENT ${component}) | ||
endif () | ||
|
||
else () | ||
message(FATAL_ERROR "Qt deployment executable not found.") | ||
endif () | ||
endfunction() | ||
|
||
# Apply Qt-project specific options | ||
# Currently, this is only used for an issue with Clang on Windows | ||
function(DevDriverApplyQtOptions target) | ||
# WA: On Windows with Clang, we need rtti to compile. - August 2019 | ||
iF (WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES " Clang ") | ||
target_compile_options(${target} PUBLIC -frtti) | ||
endif () | ||
endfunction() | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.