diff --git a/CMakeLists.txt b/CMakeLists.txt index 026d55746..7da599c37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( @@ -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 @@ -162,7 +163,7 @@ 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 ) @@ -170,8 +171,8 @@ write_basic_package_version_file( # 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 ) @@ -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") diff --git a/svf-llvm/CMakeLists.txt b/svf-llvm/CMakeLists.txt index 80624dc35..23a1efa0b 100644 --- a/svf-llvm/CMakeLists.txt +++ b/svf-llvm/CMakeLists.txt @@ -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 @@ -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) diff --git a/svf-llvm/tools/AE/CMakeLists.txt b/svf-llvm/tools/AE/CMakeLists.txt index 938e10875..9c8096910 100644 --- a/svf-llvm/tools/AE/CMakeLists.txt +++ b/svf-llvm/tools/AE/CMakeLists.txt @@ -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 +) diff --git a/svf-llvm/tools/CFL/CMakeLists.txt b/svf-llvm/tools/CFL/CMakeLists.txt index 4bde7bce6..cc9ef778b 100644 --- a/svf-llvm/tools/CFL/CMakeLists.txt +++ b/svf-llvm/tools/CFL/CMakeLists.txt @@ -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 +) diff --git a/svf-llvm/tools/DDA/CMakeLists.txt b/svf-llvm/tools/DDA/CMakeLists.txt index c54858043..0178cdebd 100644 --- a/svf-llvm/tools/DDA/CMakeLists.txt +++ b/svf-llvm/tools/DDA/CMakeLists.txt @@ -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 +) diff --git a/svf-llvm/tools/Example/CMakeLists.txt b/svf-llvm/tools/Example/CMakeLists.txt index 996491f40..d2d13d957 100644 --- a/svf-llvm/tools/Example/CMakeLists.txt +++ b/svf-llvm/tools/Example/CMakeLists.txt @@ -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 +) diff --git a/svf-llvm/tools/LLVM2SVF/CMakeLists.txt b/svf-llvm/tools/LLVM2SVF/CMakeLists.txt index e838dc05f..cccccf80e 100644 --- a/svf-llvm/tools/LLVM2SVF/CMakeLists.txt +++ b/svf-llvm/tools/LLVM2SVF/CMakeLists.txt @@ -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 +) diff --git a/svf-llvm/tools/MTA/CMakeLists.txt b/svf-llvm/tools/MTA/CMakeLists.txt index 0508d95cf..60e6ad5b0 100644 --- a/svf-llvm/tools/MTA/CMakeLists.txt +++ b/svf-llvm/tools/MTA/CMakeLists.txt @@ -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 +) diff --git a/svf-llvm/tools/SABER/CMakeLists.txt b/svf-llvm/tools/SABER/CMakeLists.txt index 2ebc80e33..ff6c04448 100644 --- a/svf-llvm/tools/SABER/CMakeLists.txt +++ b/svf-llvm/tools/SABER/CMakeLists.txt @@ -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 +) diff --git a/svf-llvm/tools/WPA/CMakeLists.txt b/svf-llvm/tools/WPA/CMakeLists.txt index 4a99b53a3..684a876d9 100644 --- a/svf-llvm/tools/WPA/CMakeLists.txt +++ b/svf-llvm/tools/WPA/CMakeLists.txt @@ -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 +) diff --git a/svf/CMakeLists.txt b/svf/CMakeLists.txt index bc2d518a3..744f0ae34 100644 --- a/svf/CMakeLists.txt +++ b/svf/CMakeLists.txt @@ -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