Skip to content

Commit

Permalink
Improve CMake messages for Qt
Browse files Browse the repository at this point in the history
* Use find_package_handle_standard_args() to print found messages for Qt
* Move some CMake includes to the top-level file
  • Loading branch information
leonlynch committed Oct 7, 2024
1 parent 3d3978c commit 726b118
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ elseif (NOT TARGET pinblock)
message(FATAL_ERROR "Parent project must provide pinblock library for static builds")
endif()

include(FindPackageHandleStandardArgs) # Provides find_package() messages
include(GNUInstallDirs) # Provides CMAKE_INSTALL_* variables and good defaults for install()

# Set minimum tr31 version before adding subdirectories
set(TR31_MIN_VERSION 0.6.0 CACHE INTERNAL "Minimum tr31 version")
add_subdirectory(src)
Expand All @@ -125,7 +128,9 @@ if(Qt_NAMES)

find_package(QT 5.12 NAMES ${Qt_NAMES} COMPONENTS Widgets)
if(QT_FOUND)
message(STATUS "Found Qt${QT_VERSION_MAJOR} Widgets: ${QT_CONFIG} (found suitable version \"${QT_VERSION}\")")
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets PATHS ${QT_DIR})
find_package_handle_standard_args(Qt${QT_VERSION_MAJOR} CONFIG_MODE)
find_package_handle_standard_args(Qt${QT_VERSION_MAJOR}Widgets CONFIG_MODE)
else()
if(BUILD_DUKPT_UI)
message(FATAL_ERROR "Could NOT find Qt Widgets; required to build dukpt-ui")
Expand Down Expand Up @@ -153,8 +158,6 @@ if(QT_FOUND AND tr31_FOUND)
add_subdirectory(ui)
endif()

include(GNUInstallDirs) # Provides CMAKE_INSTALL_* variables and good defaults for install()

# Install README and LICENSE files to runtime component
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/README.md"
Expand Down
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ if(BUILD_DUKPT_TOOL AND NOT HAVE_TIME_H)
message(FATAL_ERROR "Could NOT find time.h. This is required to build dukpt-tool")
endif()

include(GNUInstallDirs) # Provides CMAKE_INSTALL_* variables and good defaults for install()

# Generate config file for internal use only
# This file should NOT be installed or used by an installed header
configure_file(
Expand Down
3 changes: 2 additions & 1 deletion ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ else()
endif()
endif()

include(FindPackageHandleStandardArgs) # Provides find_package() messages
include(GNUInstallDirs) # Provides CMAKE_INSTALL_* variables and good defaults for install()

# Generate config file for internal use only
Expand Down Expand Up @@ -84,7 +85,7 @@ endif()

find_package(QT 5.12 NAMES ${Qt_NAMES} REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets PATHS ${QT_DIR})
message(STATUS "Found Qt${QT_VERSION_MAJOR} Widgets: ${QT_CONFIG} (found suitable version \"${QT_VERSION}\")")
find_package_handle_standard_args(Qt${QT_VERSION_MAJOR}Widgets CONFIG_MODE)
if(QT_VERSION VERSION_LESS 5.15)
# Qt-5.12 provides these versioned commands
qt5_wrap_ui(UI_SRCS mainwindow.ui)
Expand Down

0 comments on commit 726b118

Please sign in to comment.