Skip to content

Commit 13a7553

Browse files
committed
Rebuild ansi-c library if non-source dependencies change
1 parent b97a766 commit 13a7553

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

src/ansi-c/CMakeLists.txt

+32-13
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@ generic_flex(ansi_c)
33

44
add_executable(converter library/converter.cpp)
55

6+
file(GLOB ansi_c_library_sources "library/*.c")
7+
68
add_custom_command(OUTPUT converter_input.txt
7-
COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/library/*.c > converter_input.txt
9+
COMMAND cat ${ansi_c_library_sources} > converter_input.txt
10+
DEPENDS ${ansi_c_library_sources}
811
)
912

10-
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cprover_library.inc
11-
COMMAND converter < converter_input.txt > ${CMAKE_CURRENT_BINARY_DIR}/cprover_library.inc
12-
DEPENDS converter_input.txt
13+
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cprover_library.inc"
14+
COMMAND converter < "converter_input.txt" > "${CMAKE_CURRENT_BINARY_DIR}/cprover_library.inc"
15+
DEPENDS "converter_input.txt" converter
1316
)
1417

1518
add_executable(file_converter file_converter.cpp)
1619

1720
function(make_inc name)
18-
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.inc
19-
COMMAND file_converter < ${CMAKE_CURRENT_SOURCE_DIR}/${name}.h > ${CMAKE_CURRENT_BINARY_DIR}/${name}.inc
21+
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.inc"
22+
COMMAND file_converter < "${CMAKE_CURRENT_SOURCE_DIR}/${name}.h" > "${CMAKE_CURRENT_BINARY_DIR}/${name}.inc"
23+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.h" file_converter
2024
)
2125
endfunction(make_inc)
2226

@@ -70,13 +74,7 @@ make_inc(gcc_builtin_headers_power)
7074
make_inc(gcc_builtin_headers_tm)
7175
make_inc(gcc_builtin_headers_ubsan)
7276

73-
file(GLOB_RECURSE sources "*.cpp")
74-
file(GLOB_RECURSE headers "*.h")
75-
add_library(ansi-c
76-
${sources}
77-
${headers}
78-
${BISON_parser_OUTPUTS}
79-
${FLEX_scanner_OUTPUTS}
77+
set(extra_dependencies
8078
${CMAKE_CURRENT_BINARY_DIR}/arm_builtin_headers.inc
8179
${CMAKE_CURRENT_BINARY_DIR}/clang_builtin_headers.inc
8280
${CMAKE_CURRENT_BINARY_DIR}/cprover_library.inc
@@ -98,6 +96,27 @@ add_library(ansi-c
9896
${CMAKE_CURRENT_BINARY_DIR}/library-check.stamp
9997
)
10098

99+
file(GLOB_RECURSE sources "*.cpp")
100+
file(GLOB_RECURSE headers "*.h")
101+
102+
list(REMOVE_ITEM sources
103+
"${CMAKE_CURRENT_SOURCE_DIR}/library/converter.cpp"
104+
"${CMAKE_CURRENT_SOURCE_DIR}/file_converter.cpp"
105+
)
106+
107+
add_library(ansi-c
108+
${sources}
109+
${headers}
110+
${BISON_parser_OUTPUTS}
111+
${FLEX_scanner_OUTPUTS}
112+
)
113+
114+
set_source_files_properties(
115+
${sources}
116+
PROPERTIES
117+
OBJECT_DEPENDS "${extra_dependencies}"
118+
)
119+
101120
generic_includes(ansi-c)
102121

103122
target_link_libraries(ansi-c util linking goto-programs assembler)

0 commit comments

Comments
 (0)