Skip to content

Commit

Permalink
Compile as lib for UTBot
Browse files Browse the repository at this point in the history
  • Loading branch information
ladisgin committed Oct 16, 2023
1 parent ca88a99 commit 106db2f
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 47 deletions.
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,11 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(KLEE_UTILS_DIR ${CMAKE_SOURCE_DIR}/utils)

################################################################################
# Set install destination paths for targets
################################################################################
set(RUN_KLEE_MAIN_LIB_DEST "lib/run_klee")
set(RUN_KLEE_LIB_DEST "${RUN_KLEE_MAIN_LIB_DEST}/${CMAKE_BUILD_TYPE}")

################################################################################
# Report the value of various variables to aid debugging
Expand Down Expand Up @@ -773,7 +778,20 @@ endif()
################################################################################
# Miscellaneous install
################################################################################
install(FILES include/klee/klee.h DESTINATION include/klee)
install(FILES include/klee/klee.h include/klee/ADT/KTest.h DESTINATION include/klee)
INSTALL(FILES lib/Core/Executor.h DESTINATION include/klee/Core)
INSTALL(DIRECTORY include/klee/Expr DESTINATION include/klee)
INSTALL(DIRECTORY include/klee/Module DESTINATION include/klee)
INSTALL(DIRECTORY include/klee/Statistics DESTINATION include/klee)
INSTALL(DIRECTORY include/klee/Support DESTINATION include/klee)

install(EXPORT run_klee
DESTINATION "${RUN_KLEE_LIB_DEST}"
)

install(FILES cmake/run_klee-config.cmake
DESTINATION "${RUN_KLEE_MAIN_LIB_DEST}"
)

################################################################################
# Uninstall rule
Expand Down
6 changes: 6 additions & 0 deletions include/klee/Runner/run_klee.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef KLEE_RUN_KLEE_H
#define KLEE_RUN_KLEE_H

int run_klee(int argc, char **argv, char **envp);

#endif // KLEE_RUN_KLEE_H
5 changes: 5 additions & 0 deletions lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ target_compile_options(kleeBasic PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
target_compile_definitions(kleeBasic PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})

target_include_directories(kleeBasic PRIVATE ${KLEE_INCLUDE_DIRS})

install(TARGETS kleeBasic
EXPORT run_klee
DESTINATION "${RUN_KLEE_LIB_DEST}"
)
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ add_subdirectory(Expr)
add_subdirectory(Solver)
add_subdirectory(Module)
add_subdirectory(Core)
add_subdirectory(Runner)
6 changes: 6 additions & 0 deletions lib/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ target_link_libraries(kleeCore PRIVATE ${SQLite3_LIBRARIES})
target_include_directories(kleeCore PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${SQLite3_INCLUDE_DIRS})
target_compile_options(kleeCore PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
target_compile_definitions(kleeCore PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})

install(TARGETS kleeCore
EXPORT run_klee
DESTINATION "${RUN_KLEE_LIB_DEST}"
)

5 changes: 5 additions & 0 deletions lib/Expr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ llvm_config(kleaverExpr "${USE_LLVM_SHARED}" support)
target_include_directories(kleaverExpr PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
target_compile_options(kleaverExpr PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
target_compile_definitions(kleaverExpr PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})

install(TARGETS kleaverExpr
EXPORT run_klee
DESTINATION "${RUN_KLEE_LIB_DEST}"
)
5 changes: 5 additions & 0 deletions lib/Module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ target_link_libraries(kleeModule PRIVATE
target_include_directories(kleeModule PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
target_compile_options(kleeModule PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
target_compile_definitions(kleeModule PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})

install(TARGETS kleeModule
EXPORT run_klee
DESTINATION "${RUN_KLEE_LIB_DEST}"
)
27 changes: 27 additions & 0 deletions lib/Runner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
add_library(kleeRunner
run_klee.cpp
)

set(KLEE_LIBS
kleeCore
)

set(RUN_KLEE_INCLUDE_DEST "include/run_klee")

target_link_libraries(kleeRunner ${KLEE_LIBS})
target_include_directories(kleeRunner PUBLIC ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
target_compile_options(kleeRunner PUBLIC ${KLEE_COMPONENT_CXX_FLAGS})
target_compile_definitions(kleeRunner PUBLIC ${KLEE_COMPONENT_CXX_DEFINES})
set(run_klee_header_path ${PROJECT_SOURCE_DIR}/include/klee/Runner)
set(run_klee_headers ${run_klee_header_path}/run_klee.h)

set_target_properties(kleeRunner PROPERTIES PUBLIC_HEADER "${run_klee_headers}")

install(TARGETS kleeRunner
EXPORT run_klee DESTINATION "${RUN_KLEE_LIB_DEST}"
PUBLIC_HEADER DESTINATION "${RUN_KLEE_INCLUDE_DEST}"
)


# The KLEE depends on the runtimes
add_dependencies(kleeRunner BuildKLEERuntimes)
2 changes: 1 addition & 1 deletion tools/klee/main.cpp → lib/Runner/run_klee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ void wait_until_any_child_dies(
}
}

int main(int argc, char **argv, char **envp) {
int run_klee(int argc, char **argv, char **envp) {
if (theInterpreter) {
theInterpreter = nullptr;
}
Expand Down
5 changes: 5 additions & 0 deletions lib/Support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ target_link_libraries(kleeSupport PRIVATE ${ZLIB_LIBRARIES} ${TCMALLOC_LIBRARIES
target_include_directories(kleeSupport PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${TCMALLOC_INCLUDE_DIR})
target_compile_options(kleeSupport PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
target_compile_definitions(kleeSupport PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})

install(TARGETS kleeSupport
EXPORT run_klee
DESTINATION "${RUN_KLEE_LIB_DEST}"
)
12 changes: 2 additions & 10 deletions tools/klee/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,10 @@
#
#===------------------------------------------------------------------------===#
add_executable(klee
main.cpp
klee.cpp
)

set(KLEE_LIBS
kleeCore
)

target_link_libraries(klee ${KLEE_LIBS})
target_include_directories(klee PRIVATE ${KLEE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
target_compile_options(klee PRIVATE ${KLEE_COMPONENT_CXX_FLAGS})
target_compile_definitions(klee PRIVATE ${KLEE_COMPONENT_CXX_DEFINES})

target_link_libraries(klee PUBLIC kleeRunner)

install(TARGETS klee RUNTIME DESTINATION bin)

Expand Down
5 changes: 5 additions & 0 deletions tools/klee/klee.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <klee/Runner/run_klee.h>

int main(int argc, char **argv, char **envp) {
return run_klee(argc, argv, envp);
}
35 changes: 0 additions & 35 deletions utbot-build.sh

This file was deleted.

0 comments on commit 106db2f

Please sign in to comment.