Skip to content

Commit

Permalink
🔨 Print cmake configuration at the end of CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierLDff committed Apr 12, 2021
1 parent b3bea0f commit b046060
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

set(QOLM_MAIN_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(QOLM_MAIN_PROJECT ON)
endif()

# ───── OPTIONS ─────

# General
Expand All @@ -26,8 +31,8 @@ set(QOLM_EXAMPLES_PREFIX ${QOLM_PROJECT} CACHE STRING "Prefix for all QOlm tests
# ───── VERSION ─────

set(QOLM_VERSION_MAJOR 3)
set(QOLM_VERSION_MINOR 0)
set(QOLM_VERSION_PATCH 1)
set(QOLM_VERSION_MINOR 1)
set(QOLM_VERSION_PATCH 0)
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
EXECUTE_PROCESS(
COMMAND git rev-parse --short HEAD
Expand Down Expand Up @@ -117,3 +122,7 @@ endif()
if(QOLM_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()

if(QOLM_MAIN_PROJECT)
include(cmake/PrintConfiguration.cmake)
endif()
41 changes: 41 additions & 0 deletions cmake/PrintConfiguration.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
include(ProcessorCount)
ProcessorCount(N)
if(N EQUAL 0)
set(PARALLEL_LEVEL "")
else()
set(PARALLEL_LEVEL "-j${N}")
endif()

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

if(Qt5_VERSION)
set(QT_VERSION ${Qt5_VERSION})
else()
set(QT_VERSION ${Qt6_VERSION})
endif()

message(STATUS " ")
message(STATUS "Versions:")
message(STATUS " QOlm : ${QOLM_VERSION} ${QOLM_TAG}")
message(STATUS " Qt : ${QT_VERSION}")

message(STATUS " ")
message(STATUS "Targets:")
message(STATUS " QOlm : cmake --build . --target ${QOLM_TARGET} --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")

if(TARGET "${QOLM_TARGET}_Example")
message(STATUS " ")
message(STATUS "Example:")
message(STATUS " QOlmExample : cmake --build . --target ${QOLM_TARGET}_Example --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")
message(STATUS " QOlmExampleQml : cmake --build . --target ${QOLM_TARGET}_ExampleQml --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")
endif()

if(TARGET "${QOLM_TARGET}_Tests")
message(STATUS " ")
message(STATUS "Tests:")
message(STATUS " QOlmTests : cmake --build . --target ${QOLM_TARGET}_Tests --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")
message(STATUS " QOlmTestsQml : cmake --build . --target ${QOLM_TARGET}_TestsQml --config ${CMAKE_BUILD_TYPE} ${PARALLEL_LEVEL}")
message(STATUS " Run Tests : ctest -C ${CMAKE_BUILD_TYPE} . --verbose --progress")
endif()

0 comments on commit b046060

Please sign in to comment.