@@ -135,42 +135,32 @@ endfunction(remove_src_unix)
135135# FUNCTION remove_src_dir
136136########################################
137137
138- function (remove_src_dir var )
139- file (GLOB_RECURSE rm ${SDIR} /${var} )
140- if (rm AND src)
138+ function (remove_src_dir var )
139+ file (GLOB_RECURSE rm ${SDIR} /${var} )
140+ if (rm AND src)
141141 list (REMOVE_ITEM src ${rm} )
142142 set (src ${src} PARENT_SCOPE )
143143 endif ()
144144endfunction (remove_src_dir )
145145
146146########################################
147- # FUNCTION project_group
147+ # FUNCTION remove_src_dir_regex
148148########################################
149149
150- function (project_group target name )
151- set_target_properties (${target} PROPERTIES FOLDER ${name} )
152- endfunction (project_group )
150+ function (remove_src_dir_regex var )
151+ if (src)
152+ list (FILTER src EXCLUDE REGEX "${var} " )
153+ set (src ${src} PARENT_SCOPE )
154+ endif ()
155+ endfunction (remove_src_dir_regex )
153156
154157########################################
155- # FUNCTION file_write_once
158+ # FUNCTION project_group
156159########################################
157160
158- function (file_write_once f c )
159- # multiple instances safe
160- set (once ${f} .cppan.once)
161- string (SHA1 h "${c} " )
162- if (NOT EXISTS ${once} )
163- file_write_safe (${f} "${c} " )
164- file_write_safe (${once} "${h} " )
165- return ()
166- endif ()
167- file (READ ${once} h2 )
168- if (NOT "${h} " STREQUAL "${h2} " )
169- file_write_safe (${f} "${c} " )
170- file_write_safe (${once} "${h} " )
171- return ()
172- endif ()
173- endfunction (file_write_once )
161+ function (project_group target name )
162+ set_target_properties (${target} PROPERTIES FOLDER ${name} )
163+ endfunction (project_group )
174164
175165########################################
176166# FUNCTION file_write_safe
@@ -363,6 +353,10 @@ endfunction(get_configuration_with_generator_unhashed)
363353########################################
364354
365355function (get_configuration_exe_unhashed out )
356+ #get_configuration_unhashed(config)
357+ #set(${out} ${config} PARENT_SCOPE)
358+ #return()
359+
366360 prepare_config_part (system "${CMAKE_SYSTEM_NAME} " )
367361 prepare_config_part (processor "${CMAKE_HOST_SYSTEM_PROCESSOR} " )
368362 set (config ${system}${CPPAN_CONFIG_PART_DELIMETER}${processor} )
@@ -665,6 +659,27 @@ function(check_result_variable ret)
665659 message (FATAL_ERROR "Last execute_process() with message '${ARGN} ' failed with error: ${ret} " )
666660endfunction (check_result_variable )
667661
662+ ########################################
663+ # FUNCTION file_write_once
664+ ########################################
665+
666+ function (file_write_once f c )
667+ # multiple instances safe
668+ set (once ${f} .cppan.once)
669+ string (SHA1 h "${c} " )
670+ if (NOT EXISTS ${once} )
671+ file_write_safe (${f} "${c} " )
672+ file_write_safe (${once} "${h} " )
673+ return ()
674+ endif ()
675+ file (READ ${once} h2 )
676+ if (NOT "${h} " STREQUAL "${h2} " )
677+ file_write_safe (${f} "${c} " )
678+ file_write_safe (${once} "${h} " )
679+ return ()
680+ endif ()
681+ endfunction (file_write_once )
682+
668683########################################
669684# FUNCTION replace_in_file_once
670685########################################
@@ -677,9 +692,15 @@ function(replace_in_file_once f from to)
677692 # cannot set this file to bdir because multiple configs use
678693 # different bdirs and will do multiple replacements
679694 set (h ${f} .${h} )
680-
681- if (EXISTS ${h} )
682- return ()
695+ set (ch ${f} .cppan.hash)
696+
697+ if (EXISTS ${h} AND EXISTS ${ch} )
698+ file (READ ${ch} h2 )
699+ file (READ ${f} fc )
700+ string (SHA1 h3 "${fc} " )
701+ if ("${h2} " STREQUAL "${h3} " )
702+ return ()
703+ endif ()
683704 endif ()
684705
685706 set (lock ${f} .lock)
@@ -693,16 +714,23 @@ function(replace_in_file_once f from to)
693714 endif ()
694715
695716 # double check
696- if (EXISTS ${h} )
697- return ()
717+ if (EXISTS ${h} AND EXISTS ${ch} )
718+ file (READ ${ch} h2 )
719+ file (READ ${f} fc )
720+ string (SHA1 h3 "${fc} " )
721+ if ("${h2} " STREQUAL "${h3} " )
722+ return ()
723+ endif ()
698724 endif ()
699725
700726 file (READ ${f} fc )
701727 string (REPLACE "${from} " "${to} " fc "${fc} " )
728+ string (SHA1 h2 "${fc} " )
702729 file (WRITE "${f} " "${fc} " )
703730
704731 # create flag file
705732 file (WRITE ${h} "" )
733+ file (WRITE ${ch} "${h2} " )
706734endfunction (replace_in_file_once )
707735
708736########################################
@@ -719,11 +747,20 @@ endfunction(delete_in_file_once)
719747
720748function (push_front_to_file_once f what )
721749 string (SHA1 h "${f}${what} " )
722- string (SUBSTRING "${h} " 0 5 h)
750+ string (SUBSTRING "${h} " 0 5 h)
751+
752+ # cannot set this file to bdir because multiple configs use
753+ # different bdirs and will do multiple replacements
723754 set (h ${f} .${h} )
724-
725- if (EXISTS ${h} )
726- return ()
755+ set (ch ${f} .cppan.hash)
756+
757+ if (EXISTS ${h} AND EXISTS ${ch} )
758+ file (READ ${ch} h2 )
759+ file (READ ${f} fc )
760+ string (SHA1 h3 "${fc} " )
761+ if ("${h2} " STREQUAL "${h3} " )
762+ return ()
763+ endif ()
727764 endif ()
728765
729766 set (lock ${f} .lock)
@@ -737,15 +774,22 @@ function(push_front_to_file_once f what)
737774 endif ()
738775
739776 # double check
740- if (EXISTS ${h} )
741- return ()
777+ if (EXISTS ${h} AND EXISTS ${ch} )
778+ file (READ ${ch} h2 )
779+ file (READ ${f} fc )
780+ string (SHA1 h3 "${fc} " )
781+ if ("${h2} " STREQUAL "${h3} " )
782+ return ()
783+ endif ()
742784 endif ()
743785
744786 file (READ ${f} fc )
787+ string (SHA1 h2 "${what} \n\n ${fc} " )
745788 file (WRITE "${f} " "${what} \n\n ${fc} " )
746789
747790 # create flag file
748791 file (WRITE ${h} "" )
792+ file (WRITE ${ch} "${h2} " )
749793endfunction (push_front_to_file_once )
750794
751795########################################
@@ -754,11 +798,20 @@ endfunction(push_front_to_file_once)
754798
755799function (push_back_to_file_once f what )
756800 string (SHA1 h "${f}${what} " )
757- string (SUBSTRING "${h} " 0 5 h)
801+ string (SUBSTRING "${h} " 0 5 h)
802+
803+ # cannot set this file to bdir because multiple configs use
804+ # different bdirs and will do multiple replacements
758805 set (h ${f} .${h} )
759-
760- if (EXISTS ${h} )
761- return ()
806+ set (ch ${f} .cppan.hash)
807+
808+ if (EXISTS ${h} AND EXISTS ${ch} )
809+ file (READ ${ch} h2 )
810+ file (READ ${f} fc )
811+ string (SHA1 h3 "${fc} " )
812+ if ("${h2} " STREQUAL "${h3} " )
813+ return ()
814+ endif ()
762815 endif ()
763816
764817 set (lock ${f} .lock)
@@ -772,17 +825,35 @@ function(push_back_to_file_once f what)
772825 endif ()
773826
774827 # double check
775- if (EXISTS ${h} )
776- return ()
828+ if (EXISTS ${h} AND EXISTS ${ch} )
829+ file (READ ${ch} h2 )
830+ file (READ ${f} fc )
831+ string (SHA1 h3 "${fc} " )
832+ if ("${h2} " STREQUAL "${h3} " )
833+ return ()
834+ endif ()
777835 endif ()
778836
779837 file (READ ${f} fc )
838+ string (SHA1 h2 "${fc} \n\n ${what} " )
780839 file (WRITE "${f} " "${fc} \n\n ${what} " )
781840
782841 # create flag file
783842 file (WRITE ${h} "" )
843+ file (WRITE ${ch} "${h2} " )
784844endfunction (push_back_to_file_once )
785845
846+ ########################################
847+ # FUNCTION copy_file_once
848+ ########################################
849+
850+ # this functions prevents changing variables in current scope
851+ function (copy_file_once from to )
852+ if (NOT EXISTS ${to} )
853+ execute_process (COMMAND ${CMAKE_COMMAND} -E copy_if_different ${from} ${to} )
854+ endif ()
855+ endfunction (copy_file_once )
856+
786857########################################
787858# FUNCTION cppan_include
788859########################################
@@ -837,17 +908,6 @@ function(check_type_alignment TYPE LANG NAME)
837908 set (${NAME} ${${NAME} } CACHE STRING "Alignment of type: ${TYPE} " FORCE )
838909endfunction (check_type_alignment )
839910
840- ########################################
841- # FUNCTION copy_file_once
842- ########################################
843-
844- # this functions prevents changing variables in current scope
845- function (copy_file_once from to )
846- if (NOT EXISTS ${to} )
847- execute_process (COMMAND ${CMAKE_COMMAND} -E copy_if_different ${from} ${to} )
848- endif ()
849- endfunction (copy_file_once )
850-
851911########################################
852912# FUNCTION find_moc_targets
853913########################################
@@ -1038,6 +1098,12 @@ endfunction()
10381098########################################
10391099
10401100function (cppan_qt5_wrap_cpp outfiles )
1101+ if (CPPAN_LOCAL_PROJECT)
1102+ qt5_wrap_cpp (x ${ARGN} )
1103+ set (${outfiles} ${x} PARENT_SCOPE )
1104+ return ()
1105+ endif ()
1106+
10411107 # get include dirs
10421108 qt5_get_moc_flags (moc_flags )
10431109
@@ -1092,9 +1158,9 @@ endmacro()
10921158# MACRO cppan_re2c
10931159########################################
10941160
1095- macro (cppan_re2c f )
1161+ macro (cppan_re2c f ext )
10961162 set (i ${SDIR} /${f} )
1097- set (o ${BDIR_PRIVATE} /${f} .cpp )
1163+ set (o ${BDIR_PRIVATE} /${f} .${ext} )
10981164 add_custom_command (OUTPUT ${o}
10991165 COMMAND pvt.cppan.demo.re2c.re2c -o ${o} ${i}
11001166 DEPENDS ${i}
0 commit comments