Skip to content

Commit

Permalink
fix CMakelist
Browse files Browse the repository at this point in the history
  • Loading branch information
bjjwwang committed Feb 12, 2024
1 parent d7f65f3 commit c7ffd7e
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 8 deletions.
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ message(STATUS "Using CMake build configuration:
CMake current source directory: ${CMAKE_CURRENT_SOURCE_DIR}
CMake current binary directory: ${CMAKE_CURRENT_BINARY_DIR}")

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/svf)
# Create config.h based on config.in
configure_file(${SVF_SOURCE_DIR}/.config.in ${SVF_BINARY_DIR}/include/Util/config.h)
configure_file(${SVF_SOURCE_DIR}/.config.in ${SVF_BINARY_DIR}/include/svf/Util/config.h)

# Include the directory where the configuration header is exported for all targets
include_directories(${SVF_BINARY_DIR}/include)
include_directories(${SVF_BINARY_DIR}/include/svf)

# Install generated configuration header (see `configure_file()`) to top-level include dir of SVF
install(
Expand Down Expand Up @@ -149,7 +150,7 @@ include(CMakePackageConfigHelpers)
# Generate SVFConfig.cmake
configure_package_config_file(
.config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SVFConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/SVF/SVFConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SVF
PATH_VARS
SVF_INSTALL_ROOT
Expand All @@ -162,16 +163,16 @@ configure_package_config_file(

# Generate SVFConfigVersion.cmake
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/SVFConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/SVF/SVFConfigVersion.cmake"
VERSION "${SVF_VERSION_MAJOR}.${SVF_VERSION_MINOR}"
COMPATIBILITY AnyNewerVersion
)

# Install above CMake files as part of installation
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/SVFConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/SVFConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/SVF/SVFConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/SVF/SVFConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SVF
)

Expand All @@ -183,4 +184,4 @@ install(
)

# Export targets added to SVFTargets (set by install() command)
export(EXPORT SVFTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/SVFTargets.cmake")
export(EXPORT SVFTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/SVF/SVFTargets.cmake")
7 changes: 7 additions & 0 deletions svf-llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ target_sources(SvfLLVM PRIVATE ${SVF_LLVM_SOURCES})

# Get all of the public header files (i.e. all *.h/*.hpp files) for SVF's subprojects and add them
file(GLOB_RECURSE SVF_LLVM_HEADERS include/*.h include/*.hpp)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_BINARY_DIR}/include/svf)

target_sources(SvfLLVM
PUBLIC
FILE_SET HEADERS
Expand Down Expand Up @@ -129,6 +131,11 @@ add_custom_command(
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/lib/extapi.c
)

add_custom_target(copy_extapi_bc ALL
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/extapi.bc ${CMAKE_BINARY_DIR}/include/svf/SVF-LLVM/extapi.bc
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/extapi.bc
)

# Add a custom target for generating the LLVM bytecode file (and add it to the default build targets)
add_custom_target(gen_extapi_ir ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/extapi.bc)

Expand Down
6 changes: 5 additions & 1 deletion svf-llvm/tools/AE/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
add_llvm_executable(ae ae.cpp)
target_link_libraries(ae PUBLIC ${llvm_libs} SvfLLVM)

set_target_properties(ae PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
5 changes: 5 additions & 0 deletions svf-llvm/tools/CFL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
add_llvm_executable(cfl cfl.cpp)
target_link_libraries(cfl PUBLIC ${llvm_libs} SvfLLVM)
set_target_properties(cfl PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
5 changes: 5 additions & 0 deletions svf-llvm/tools/DDA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
add_llvm_executable(dvf dda.cpp)
target_link_libraries(dvf PUBLIC ${llvm_libs} SvfLLVM)
set_target_properties(dvf PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
5 changes: 5 additions & 0 deletions svf-llvm/tools/Example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
add_llvm_executable(svf-ex svf-ex.cpp)
target_link_libraries(svf-ex PUBLIC ${llvm_libs} SvfLLVM)
set_target_properties(svf-ex PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
5 changes: 5 additions & 0 deletions svf-llvm/tools/LLVM2SVF/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
add_llvm_executable(llvm2svf llvm2svf.cpp)
target_link_libraries(llvm2svf PUBLIC ${llvm_libs} SvfLLVM)
set_target_properties(llvm2svf PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
5 changes: 5 additions & 0 deletions svf-llvm/tools/MTA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
add_llvm_executable(mta mta.cpp LockResultValidator.cpp MTAResultValidator.cpp MTAAnnotator.cpp)
target_link_libraries(mta PUBLIC ${llvm_libs} SvfLLVM)
set_target_properties(mta PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
5 changes: 5 additions & 0 deletions svf-llvm/tools/SABER/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
add_llvm_executable(saber saber.cpp)
target_link_libraries(saber PUBLIC ${llvm_libs} SvfLLVM)
set_target_properties(saber PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
5 changes: 5 additions & 0 deletions svf-llvm/tools/WPA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ find_package(Threads REQUIRED)

add_llvm_executable(wpa wpa.cpp)
target_link_libraries(wpa PUBLIC ${llvm_libs} SvfLLVM Threads::Threads)
set_target_properties(wpa PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
2 changes: 2 additions & 0 deletions svf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ target_sources(SvfCore PRIVATE ${SVF_CORE_SOURCES})

# Get all of the public header files (i.e. all *.h/*.hpp files) for SVF's subprojects and add them
file(GLOB_RECURSE SVF_CORE_HEADERS include/*.h include/*.hpp)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_BINARY_DIR}/include/svf)

target_sources(SvfCore
PUBLIC
FILE_SET HEADERS
Expand Down

0 comments on commit c7ffd7e

Please sign in to comment.