~ubuntu-branches/debian/sid/simpleitk/sid

« back to all changes in this revision

Viewing changes to CMake/sitkConfigureFileBuildtime.cmake

  • Committer: Package Import Robot
  • Author(s): Ghislain Antony Vaillant
  • Date: 2017-11-02 08:49:18 UTC
  • Revision ID: package-import@ubuntu.com-20171102084918-7hs09ih668xq87ej
Tags: upstream-1.0.1
ImportĀ upstreamĀ versionĀ 1.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
include(VariableList)
 
3
 
 
4
function( configure_file_buildtime filename out_filename )
 
5
 
 
6
 
 
7
set( regex_1 "^[^@]*(@[^@]+@[^@]*)+[^@]*$")
 
8
 
 
9
file ( STRINGS "${filename}" results REGEX "${regex_1}" )
 
10
set( vars "" )
 
11
 
 
12
foreach( line ${results})
 
13
 
 
14
  set( regex_2 "^[^@]*@([^@]+)@(.*)$" )
 
15
 
 
16
  string( REGEX MATCH "${regex_2}" line_match "${line}" )
 
17
  list( APPEND vars ${CMAKE_MATCH_1} )
 
18
  while( CMAKE_MATCH_1 )
 
19
    string( REGEX MATCH "${regex_2}" line_match  "${CMAKE_MATCH_2}" )
 
20
    list( APPEND vars ${CMAKE_MATCH_1} )
 
21
  endwhile()
 
22
    
 
23
  list( SORT vars )
 
24
  list( REMOVE_DUPLICATES vars )
 
25
 
 
26
 
 
27
 
 
28
  
 
29
endforeach()
 
30
 
 
31
set( CONFIGUREBUILDTIME_filename ${filename} )
 
32
set( CONFIGUREBUILDTIME_out_filename ${out_filename} )
 
33
 
 
34
list( APPEND vars CONFIGUREBUILDTIME_filename CONFIGUREBUILDTIME_out_filename )
 
35
 
 
36
VariableListToArgs( vars configure_vars )
 
37
 
 
38
file( WRITE "${CMAKE_BINARY_DIR}/CMake/configure_file_buildtime.cmake"
 
39
  "configure_file( \"\${CONFIGUREBUILDTIME_filename}\" \"\${CONFIGUREBUILDTIME_out_filename}\" )" )
 
40
 
 
41
set( cmd ${CMAKE_COMMAND} "${configure_vars}"  -P "${CMAKE_BINARY_DIR}/CMake/configure_file_buildtime.cmake")
 
42
 
 
43
if( TARGET ConfigureFileBuildtime )
 
44
  add_custom_command( TARGET ConfigureFileBuildtime
 
45
    PRE_BUILD
 
46
    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
 
47
    COMMENT "BuildTime Configuration of ${filename} to ${out_filename}"
 
48
    COMMAND  ${cmd}
 
49
    )
 
50
else()
 
51
  add_custom_command(
 
52
    OUTPUT "${out_filename}"
 
53
    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
 
54
    DEPENDS "${filename}"
 
55
    COMMENT "BuildTime Configuration of ${filename} to ${out_filename}"
 
56
    COMMAND  ${cmd}
 
57
    )
 
58
  add_custom_target(ConfigureFileBuildtime ALL DEPENDS "${out_filename}" )
 
59
endif()
 
60
 
 
61
endfunction()