Skip to content

Commit

Permalink
Improve CMake messages
Browse files Browse the repository at this point in the history
* Use Boost config file in accordance with CMake policy CMP0167
* Use find_package_handle_standard_args() to print found messages for
  packages that don't print their own
* Move some CMake includes to the top-level file
  • Loading branch information
leonlynch committed Sep 12, 2024
1 parent 01a09e8 commit 6bbe0c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ 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)

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
9 changes: 5 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ find_package(json-c CONFIG)
if(json-c_FOUND)
# The json-c CMake config doesn't print a find_package() message but it is
# always good to know where it was found
message(STATUS "Found json-c: ${json-c_CONFIG}")
find_package_handle_standard_args(json-c CONFIG_MODE)
else()
# Try custom Findjson-c.cmake module
find_package(json-c REQUIRED)
Expand All @@ -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 Expand Up @@ -198,7 +196,10 @@ target_include_directories(iso8859 INTERFACE
$<INSTALL_INTERFACE:include/iso8859>
)
if(ISO8859_IMPL STREQUAL "boost")
find_package(Boost REQUIRED COMPONENTS locale)
find_package(Boost REQUIRED COMPONENTS locale CONFIG) # See policy CMP0167
# The Boost CMake config does not print a find_package() message but it is
# always good to know where it was found and which version was found
find_package_handle_standard_args(Boost CONFIG_MODE)
message(STATUS "Using Boost.Locale for iso8859 implementation")
target_sources(iso8859 PRIVATE iso8859_boost.cpp)
target_link_libraries(iso8859 PRIVATE Boost::locale)
Expand Down

0 comments on commit 6bbe0c8

Please sign in to comment.