Skip to content

Commit

Permalink
Streamlined and developed options for CMake messaging.
Browse files Browse the repository at this point in the history
  • Loading branch information
gsrohde committed Apr 7, 2024
1 parent 99d2f3f commit 8ed4125
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 30 deletions.
15 changes: 7 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
cmake_minimum_required(VERSION 3.25.0)
cmake_minimum_required(VERSION 3.23.0)
list(APPEND CMAKE_MESSAGE_CONTEXT DAWN)
option(LOG_WITH_INDENTATION "Indent a level when moving to processing a subdirectory" ON)
option(CMAKE_MESSAGE_CONTEXT_SHOW "Show the context of each log message" OFF)

message(VERBOSE "Processing top level CMakeLists.txt")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

cmake_language(GET_MESSAGE_LOG_LEVEL MESSAGE_LOG_LEVEL) # needs CMake >= 3.25
set(LOG_LEVELS_FOR_INDENTATION VERBOSE;DEBUG;TRACE)
if(MESSAGE_LOG_LEVEL IN_LIST LOG_LEVELS_FOR_INDENTATION)
list(APPEND CMAKE_MESSAGE_INDENT " ")
endif()
include(context)
show_context("top level CMakeLists.txt")

project(DAWN VERSION 0.1
LANGUAGES CXX)

enable_testing()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")


## Set the language standard flexibly, as outlined in Craig Scott's
Expand Down
13 changes: 6 additions & 7 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
message(VERBOSE "Processing app/CMakeLists.txt")
if(MESSAGE_LOG_LEVEL IN_LIST LOG_LEVELS_FOR_INDENTATION)
list(APPEND CMAKE_MESSAGE_INDENT " ")
endif()
list(APPEND CMAKE_MESSAGE_CONTEXT app)
include(context)
show_context("app/CMakeLists.txt")


set(XercesC_ROOT CACHE FILEPATH "Set for non-standard XercesC installations")
find_package(XercesC 3.2)
if (XercesC_FOUND)
message("XercesC version " ${XercesC_VERSION} " was found.")
message("The library file is located at " ${XercesC_LIBRARY})
message(STATUS "XercesC version " ${XercesC_VERSION} " was found.")
message(VERBOSE "The library file is located at " ${XercesC_LIBRARY})
else()
message(FATAL_ERROR "XercesC was not found.")
endif()
Expand Down Expand Up @@ -72,7 +71,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(EXECUTABLE_PATH "@loader_path")
else() # e.g. Windows
message("To set a non-standard installation prefix, use\n"
message(STATUS "To set a non-standard installation prefix, use\n"
"'cmake -B <build tree> -S <source tree> --install-prefix <non-standard installation prefix>'\n"
"when running the configuration stage.")
endif()
Expand Down
2 changes: 1 addition & 1 deletion biocro-lib
Submodule biocro-lib updated 1 files
+4 −5 CMakeLists.txt
4 changes: 2 additions & 2 deletions cmake/Doxygen.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
find_package(Doxygen)

if(DOXYGEN_FOUND)
message("Using version ${DOXYGEN_VERSION} of Doxygen")
message("Path to Doxygen executable is ${DOXYGEN_EXECUTABLE}")
message(STATUS "Using version ${DOXYGEN_VERSION} of Doxygen")
message(VERBOSE "Path to Doxygen executable is ${DOXYGEN_EXECUTABLE}")
else()
message(WARNING
"Doxygen not found. You will need to having it installed and "
Expand Down
7 changes: 7 additions & 0 deletions cmake/context.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
macro(show_context context)
message(STATUS "*** Processing ${context} ***")
if(LOG_WITH_INDENTATION)
list(APPEND CMAKE_MESSAGE_INDENT " ")
endif()
endmacro()

10 changes: 3 additions & 7 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# Add this here in case we are not building from the top level:
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")

message(VERBOSE "Processing doc/CMakeLists.txt")
if(MESSAGE_LOG_LEVEL IN_LIST LOG_LEVELS_FOR_INDENTATION)
list(APPEND CMAKE_MESSAGE_INDENT " ")
endif()
list(APPEND CMAKE_MESSAGE_CONTEXT doc)

include(context)
show_context("doc/CMakeLists.txt")

include(CMakeDependentOption)
cmake_dependent_option(
Expand Down
8 changes: 3 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
message(VERBOSE "Processing tests/CMakeLists.txt")
if(MESSAGE_LOG_LEVEL IN_LIST LOG_LEVELS_FOR_INDENTATION)
list(APPEND CMAKE_MESSAGE_INDENT " ")
endif()

list(APPEND CMAKE_MESSAGE_CONTEXT tests)
include(context)
show_context("tests/CMakeLists.txt")

# May not be needed. Linking a target with gtest_main or gmock seems
# to force C++14 to be used regardless.
Expand Down

0 comments on commit 8ed4125

Please sign in to comment.