Skip to content

Commit 2cee3b1

Browse files
author
Enrico Steffinlongo
committed
Aggregating all library dependencies into one
CBMC is compiled as a collection of static libraries, one per sub-module. This commits add a merging of most submodules into a final libcprover.<version>.a, so that it can be installed and used alone (without requiring its sub-module dependencies).
1 parent b469c26 commit 2cee3b1

File tree

3 files changed

+83
-21
lines changed

3 files changed

+83
-21
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ add_subdirectory(jsil)
110110
add_subdirectory(json)
111111
add_subdirectory(json-symtab-language)
112112
add_subdirectory(langapi)
113-
add_subdirectory(libcprover-cpp)
114113
add_subdirectory(linking)
115114
add_subdirectory(pointer-analysis)
116115
add_subdirectory(solvers)
@@ -127,6 +126,7 @@ add_subdirectory(goto-diff)
127126
add_subdirectory(goto-harness)
128127
add_subdirectory(goto-synthesizer)
129128
add_subdirectory(symtab2gb)
129+
add_subdirectory(libcprover-cpp)
130130

131131
if(UNIX OR WITH_MEMORY_ANALYZER)
132132
add_subdirectory(memory-analyzer)

src/libcprover-cpp/CMakeLists.txt

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,70 @@
1-
file(GLOB_RECURSE sources "*.cpp" "*.h")
1+
file(GLOB_RECURSE sources "*.cpp")
2+
file(GLOB_RECURSE headers "*.h")
23

3-
# This step builds the API in the form of a statically linked library (libcprover-api-cpp.a)
4+
# This step builds the API in the form of a statically linked library
45
add_library(cprover-api-cpp ${sources})
6+
7+
# Being a library we should include them privately, but for now fair enough
58
generic_includes(cprover-api-cpp)
6-
target_link_libraries(cprover-api-cpp
7-
goto-checker
8-
goto-programs
9-
util
10-
langapi
11-
ansi-c
12-
json-symtab-language
13-
solvers
14-
xml
15-
cpp
16-
cbmc-lib
17-
analyses
18-
statement-list
19-
linking
20-
pointer-analysis
21-
goto-instrument-lib
22-
goto-analyzer-lib
23-
goto-cc-lib)
9+
10+
target_include_directories(cprover-api-cpp PUBLIC
11+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
12+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
13+
"$<INSTALL_INTERFACE:include>")
14+
15+
get_target_property(LIBRARY_DEPENDENCIES solvers LINK_LIBRARIES)
16+
17+
list(APPEND
18+
LIBRARY_DEPENDENCIES
19+
"goto-programs"
20+
"util"
21+
"langapi"
22+
"ansi-c"
23+
"analyses"
24+
"goto-instrument-lib"
25+
"big-int"
26+
"linking"
27+
"goto-checker"
28+
"solvers"
29+
"assembler"
30+
"xml"
31+
"json"
32+
"json-symtab-language"
33+
"jsil"
34+
"statement-list"
35+
"goto-symex"
36+
"pointer-analysis"
37+
"cbmc-lib")
38+
39+
list(REMOVE_DUPLICATES LIBRARY_DEPENDENCIES)
40+
41+
target_link_libraries(cprover-api-cpp
42+
PRIVATE
43+
${LIBRARY_DEPENDENCIES})
44+
45+
set(DEPENDENCY_TARGETS "")
46+
foreach(dep ${LIBRARY_DEPENDENCIES})
47+
list(APPEND DEPENDENCY_TARGETS "$<TARGET_FILE:${dep}>")
48+
endforeach(dep LIBRARY_DEPENDENCIES)
49+
50+
string(REPLACE ";" " " DEPENDENCY_TARGETS "${DEPENDENCY_TARGETS}")
51+
52+
add_custom_command(TARGET cprover-api-cpp POST_BUILD
53+
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/add_dependencies.sh" "${CMAKE_AR}" "$<TARGET_FILE:cprover-api-cpp>" "${DEPENDENCY_TARGETS}"
54+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
55+
56+
set_target_properties(cprover-api-cpp
57+
PROPERTIES
58+
OUTPUT_NAME "cprover.${CMAKE_PROJECT_VERSION}" # libcprover.<version>.a
59+
SOVERSION "${CMAKE_PROJECT_VERSION}"
60+
PUBLIC_HEADER "${headers}"
61+
)
62+
63+
install(TARGETS cprover-api-cpp
64+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
65+
COMPONENT lib
66+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
67+
COMPONENT lib
68+
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/cprover"
69+
COMPONENT lib
70+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
AR_COMMAND=$1
6+
shift
7+
DESTINATION=$1
8+
shift
9+
LIB_LIST=$@
10+
11+
for lib in ${LIB_LIST}; do
12+
${AR_COMMAND} -x ${lib}
13+
done
14+
15+
${AR_COMMAND} -rcs ${DESTINATION} *.o

0 commit comments

Comments
 (0)