From 94db9bb4db9327264cbc41e9a26dc9c233f79a5a Mon Sep 17 00:00:00 2001 From: Kjell Hedstrom Date: Thu, 16 Jul 2015 00:27:17 -0600 Subject: [PATCH] Updated for removing temporary cmake files with "make clean-cmake-files" --- .gitignore | 2 +- CMakeLists.txt | 6 +++++ CleanAll.cmake | 13 +++++++++++ GenerateMacroDefinitionsFile.cmake | 36 +++++++++++++++++------------- 4 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 CleanAll.cmake diff --git a/.gitignore b/.gitignore index 642b0fa..e600b12 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,5 @@ nbproject/* build_clang build_travis gtest-1.7.0 -definitions.hpp +generated_definitions.hpp *~ diff --git a/CMakeLists.txt b/CMakeLists.txt index 2110975..99414a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,12 @@ set(CMAKE_BUILD_TYPE Release) project (g3log) +MESSAGE("Run 'make clean-cmake-files' to purge your build directory of CMake generated cache files") +add_custom_target(clean-cmake-files + COMMAND ${CMAKE_COMMAND} -P ${g3log_SOURCE_DIR}/CleanAll.cmake +) + + # Detect 64 or 32 bit diff --git a/CleanAll.cmake b/CleanAll.cmake new file mode 100644 index 0000000..defc372 --- /dev/null +++ b/CleanAll.cmake @@ -0,0 +1,13 @@ + +set(cmake_generated ${CMAKE_BINARY_DIR}/CMakeCache.txt + ${CMAKE_BINARY_DIR}/cmake_install.cmake + ${CMAKE_BINARY_DIR}/Makefile + ${CMAKE_BINARY_DIR}/CMakeFiles +) + +foreach(file ${cmake_generated}) + if (EXISTS ${file}) + MESSAGE("Removing: ${file}") + file(REMOVE_RECURSE ${file}) + endif() +endforeach(file) \ No newline at end of file diff --git a/GenerateMacroDefinitionsFile.cmake b/GenerateMacroDefinitionsFile.cmake index db5a0a3..d29b5ba 100644 --- a/GenerateMacroDefinitionsFile.cmake +++ b/GenerateMacroDefinitionsFile.cmake @@ -1,28 +1,32 @@ # Prerequisite : Options.cmake should run first SET(HEADER "/** ========================================================================== - * Original code made by Robert Engeln. Given as a PUBLIC DOMAIN dedication for - * the benefit of g3log. It was originally published at: - * http://code-freeze.blogspot.com/2012/01/generating-stack-traces-from-c.html - - * 2014-2015: adapted for g3log by Kjell Hedstrom (KjellKod). - * - * This is PUBLIC DOMAIN to use at your own risk and comes - * with no warranties. This code is yours to share, use and modify with no - * strings attached and no restrictions or obligations. - * - * For more information see g3log/LICENSE or refer refer to http://unlicense.org - * ============================================================================*/") +* 2015 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes +* with no warranties. This code is yours to share, use and modify with no +* strings attached and no restrictions or obligations. +* +* For more information see g3log/LICENSE or refer refer to http://unlicense.org +* ============================================================================*/") MESSAGE("COMPILE_DEFINITIONS: ${G3_DEFINITIONS}") MESSAGE("End of COMPILE_DEFINITIONS") -FILE(WRITE g3log/definitions.hpp "// AUTO GENERATED MACRO DEFINITIONS FOR G3LOG\n\n") -FILE(APPEND g3log/definitions.hpp ${HEADER}"\n") -FILE(APPEND g3log/definitions.hpp "#pragma once\n\n") +SET(GENERATED_G3_DEFINITIONS src/g3log/generated_definitions.hpp) +file(REMOVE ${GENERATED_G3_DEFINITIONS} ) +FILE(WRITE ${GENERATED_G3_DEFINITIONS} "// AUTO GENERATED MACRO DEFINITIONS FOR G3LOG\n\n") +FILE(APPEND ${GENERATED_G3_DEFINITIONS} ${HEADER}"\n") +FILE(APPEND ${GENERATED_G3_DEFINITIONS} "#pragma once\n\n") +FILE(APPEND ${GENERATED_G3_DEFINITIONS} "// CMake induced definitions below. See g3log/Options.cmake for details.\n\n") FOREACH(definition ${G3_DEFINITIONS} ) - FILE(APPEND g3log/definitions.hpp "#define ${definition}\n") + FILE(APPEND ${GENERATED_G3_DEFINITIONS} "#define ${definition}\n") ENDFOREACH(definition) + +MESSAGE("Generated ${GENERATED_G3_DEFINITIONS}") +file(READ ${GENERATED_G3_DEFINITIONS} generated_content) + +MESSAGE("******************** START *************************") +MESSAGE(${generated_content}) +MESSAGE("******************** END *************************")