Skip to content

Commit

Permalink
Updated for removing temporary cmake files with "make clean-cmake-files"
Browse files Browse the repository at this point in the history
  • Loading branch information
Kjell Hedstrom authored and Kjell Hedstrom committed Jul 16, 2015
1 parent 78103cb commit 94db9bb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ nbproject/*
build_clang
build_travis
gtest-1.7.0
definitions.hpp
generated_definitions.hpp
*~
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions CleanAll.cmake
Original file line number Diff line number Diff line change
@@ -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)
36 changes: 20 additions & 16 deletions GenerateMacroDefinitionsFile.cmake
Original file line number Diff line number Diff line change
@@ -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 *************************")

0 comments on commit 94db9bb

Please sign in to comment.