CMAKE - githeim/windheim_archive GitHub Wiki
Print out all accessible variables
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
execute shell in CMAKE and get the output of it
execute_process(COMMAND sdl2-config --cflags OUTPUT_VARIABLE CFLAGS_OF_SDL)
The output of 'sdl2-config --cflags' is stored in the variable CFLAGS_OF_SDL.
Get the external project's file in the cmake
FetchContent_Declare(imgui
URL https://github.com/ocornut/imgui/archive/refs/tags/v1.89.3.zip
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/imgui
)
FetchContent_Populate(imgui)
Get the external project without build in the cmake
# Get imgui v1.89.3
ExternalProject_Add(imgui
URL https://github.com/ocornut/imgui/archive/refs/tags/v1.89.3.zip
TIMEOUT 600
SOURCE_DIR ${IMGUI_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
The file v1.89.3.zip is extracted in the SOURCE_DIR. But the project is not build. This tip is used in using a imgui, sqlite project that is provided only source/header files.
Print out timestamp & calculate elapse time
string(TIMESTAMP TODAY "%Y%m%d %I %M %S")
MESSAGE("Time stamp [${TODAY}]")
string(TIMESTAMP START_P "%s")
...
... do something
...
string(TIMESTAMP END_P "%s")
MATH(EXPR ELAPSE "${END_P} - ${START_P}")
MESSAGE ( "CHK [${ELAPSE}]")