Warning, /graphics/kst-plot/cmake/modules/MergedFilesBuild.cmake is written in an unsupported language. File is not indexed.
0001 # *************************************************************************** 0002 # * * 0003 # * Copyright : (C) 2010 The University of Toronto * 0004 # * email : netterfield@astro.utoronto.ca * 0005 # * * 0006 # * Copyright : (C) 2010 Peter Kümmel * 0007 # * email : syntheticpp@gmx.net * 0008 # * * 0009 # * This program is free software; you can redistribute it and/or modify * 0010 # * it under the terms of the GNU General Public License as published by * 0011 # * the Free Software Foundation; either version 2 of the License, or * 0012 # * (at your option) any later version. * 0013 # * * 0014 # *************************************************************************** 0015 0016 0017 macro(merged_files_build _allinone_name _list) 0018 set(_file_list ${_allinone_name}_files) 0019 set(_file_const ${CMAKE_CURRENT_BINARY_DIR}/${_allinone_name}_const.cpp) 0020 set(_file_touched ${CMAKE_CURRENT_BINARY_DIR}/${_allinone_name}_touched.cpp) 0021 0022 # don't touch existing or non-empty file, 0023 # so a cmake re-run doesn't touch all created files 0024 set(_rebuild_file_const 0) 0025 if (NOT EXISTS ${_file_const}) 0026 set(_rebuild_file_const 1) 0027 else() 0028 FILE(READ ${_file_const} _file_content) 0029 if (NOT _file_content) 0030 set(_rebuild_file_const 1) 0031 endif() 0032 endif() 0033 0034 set(_rebuild_file_touched 0) 0035 if (NOT EXISTS ${_file_touched}) 0036 set(_rebuild_file_touched 1) 0037 else() 0038 FILE(READ ${_file_touched} _file_content) 0039 if (NOT _file_content) 0040 set(_rebuild_file_touched 1) 0041 endif() 0042 endif() 0043 0044 if (merged_files_rebuild) 0045 set(_rebuild_file_const 1) 0046 set(_rebuild_file_touched 1) 0047 endif() 0048 0049 if (_rebuild_file_const) 0050 file(WRITE ${_file_const} "// autogenerated file \n//\n") 0051 file(APPEND ${_file_const} "// * clear or delete this file to build it again by cmake \n//\n\n") 0052 endif() 0053 0054 if (_rebuild_file_touched) 0055 file(WRITE ${_file_touched} "// autogenerated file \n//\n") 0056 file(APPEND ${_file_touched} "// * clear or delete this file to build it again by cmake \n//\n") 0057 file(APPEND ${_file_touched} "// * don't touch this file \n//\n\n") 0058 file(APPEND ${_file_touched} "#define DONT_INCLUDE_CONST_FILES\n") 0059 file(APPEND ${_file_touched} "#include \"${_file_const}\"\n\n\n") 0060 endif() 0061 0062 set(${_file_list} ${_file_const} ${_file_touched}) 0063 0064 foreach (_current_FILE ${${_list}}) 0065 get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE) 0066 0067 GET_FILENAME_COMPONENT(_file_name ${_abs_FILE} NAME_WE) 0068 STRING(REGEX REPLACE "-" "_" _file_name "${_file_name}") 0069 set(__macro_name ${_file_name}___ASSUME_CONST) 0070 0071 # if (_rebuild_file_const) 0072 # file(APPEND ${_file_const} "#define ${__macro_name}\n") 0073 # file(APPEND ${_file_const} "#if defined(${__macro_name}) && !defined(DONT_INCLUDE_CONST_FILES)\n") 0074 # file(APPEND ${_file_const} "#include \"${_abs_FILE}\"\n") 0075 # file(APPEND ${_file_const} "#endif\n\n") 0076 # endif() 0077 0078 if (_rebuild_file_const) 0079 file(APPEND ${_file_const} "#if (!defined(${__macro_name})) && (!defined(DONT_INCLUDE_CONST_FILES))\n") 0080 file(APPEND ${_file_const} "#include \"${_abs_FILE}\"\n") 0081 file(APPEND ${_file_const} "#endif\n\n") 0082 file(APPEND ${_file_const} "#define ${__macro_name}\n") 0083 endif() 0084 0085 if (_rebuild_file_touched) 0086 file(APPEND ${_file_touched} "#ifndef ${__macro_name}\n") 0087 file(APPEND ${_file_touched} "#define ${__macro_name}\n") 0088 file(APPEND ${_file_touched} "#include \"${_abs_FILE}\"\n") 0089 file(APPEND ${_file_touched} "#endif\n\n") 0090 endif() 0091 endforeach (_current_FILE) 0092 endmacro() 0093 0094 0095 0096 0097 0098