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 Sep 12, 2024
1 parent 9745fe0 commit 98a6ba3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ if(EMV_UTILS_IS_TOP_LEVEL)
include(CTest)
endif()

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

add_subdirectory(src)
add_subdirectory(tools)
add_subdirectory(tests)
Expand All @@ -104,7 +107,9 @@ endif()
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_EMV_VIEWER)
message(FATAL_ERROR "Could NOT find Qt Widgets; required to build emv-viewer")
Expand All @@ -124,8 +129,6 @@ if(QT_FOUND)
add_subdirectory(viewer)
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 @@ -71,8 +71,6 @@ endif()
list(APPEND EMV_UTILS_PACKAGE_DEPENDENCIES "json-c")
set(EMV_UTILS_PACKAGE_DEPENDENCIES ${EMV_UTILS_PACKAGE_DEPENDENCIES} PARENT_SCOPE)

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

# Find and use mcc-codes submodule
set(MCC_JSON_SOURCE_FILE mcc_codes.json)
set(MCC_JSON_SOURCE_PATH ${PROJECT_SOURCE_DIR}/mcc-codes/${MCC_JSON_SOURCE_FILE})
Expand Down
2 changes: 0 additions & 2 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ if(NOT HAVE_ARPA_INET_H AND NOT HAVE_WINSOCK_H)
endif()
endif()

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

# Print helpers object library
add_library(print_helpers OBJECT EXCLUDE_FROM_ALL print_helpers.c)
target_include_directories(print_helpers INTERFACE
Expand Down
3 changes: 2 additions & 1 deletion viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,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 @@ -80,7 +81,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)
set(EMV_VIEWER_MOC_HEADERS
emv-viewer-mainwindow.h
emvhighlighter.h
Expand Down

0 comments on commit 98a6ba3

Please sign in to comment.