diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c57df7d..ddf5da33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,25 +106,6 @@ if(METACG_BUILD_CGCOLLECTOR) add_subdirectory(cgcollector) endif() -# Build CGPatch: cgpatch-pass, cgpatch-runtime, wrappers, tests -option( - METACG_BUILD_CGPATCH - "On or off" - OFF -) -if(METACG_BUILD_CGPATCH) - if(NOT METACG_BUILD_GRAPH_TOOLS) - message(FATAL_ERROR "CGPatch requires to build with METACG_BUILD_GRAPH_TOOLS=ON") - endif() - if(${LLVM_PACKAGE_VERSION} - GREATER - 14 - ) - add_subdirectory(tools/cgpatch/) - else() - message(STATUS "Skipping CGPatch: requires LLVM version 15 or higher") - endif() -endif() # PIRA analyzer Should PGIS be built option( METACG_BUILD_PGIS @@ -151,18 +132,6 @@ option( OFF ) -# Enable MPI for CGPatch -option( - CGPATCH_USE_MPI - "On or Off" - ON -) - -if(METACG_BUILD_CGPATCH AND CGPATCH_USE_MPI) - find_package(MPI REQUIRED) - message(STATUS "MPI VERSION: ${MPI_C_VERSION}") -endif() - # Build MetaCG's Python interface option( METACG_BUILD_PYMETACG diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 811b801d..7e2e2868 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,3 +1,20 @@ +# Build CGPatch: cgpatch-pass, cgpatch-runtime, wrappers, tests +option( + METACG_BUILD_CGPATCH + "On or off" + OFF +) +if(METACG_BUILD_CGPATCH) + if(${LLVM_PACKAGE_VERSION} + GREATER + 14 + ) + add_subdirectory(cgpatch) + else() + message(WARNING "Skipping CGPatch: requires LLVM version 15 or higher") + endif() +endif() + add_subdirectory(cgcollector2) add_subdirectory(cgmerge2) add_subdirectory(cgconvert) diff --git a/tools/cgpatch/CMakeLists.txt b/tools/cgpatch/CMakeLists.txt index 36232b49..9b1962b5 100644 --- a/tools/cgpatch/CMakeLists.txt +++ b/tools/cgpatch/CMakeLists.txt @@ -1,7 +1,17 @@ -project(CGPatch) - include(GNUInstallDirs) +# Enable MPI for CGPatch +option( + CGPATCH_USE_MPI + "On or Off" + ON +) + +if(CGPATCH_USE_MPI) + find_package(MPI REQUIRED) + message(STATUS "MPI VERSION: ${MPI_C_VERSION}") +endif() + # LLVM option( USE_FNO_RTTI @@ -33,6 +43,7 @@ foreach(tgt cgpatch-call-analysis cgpatch-inst-pass) endforeach() if(CGPATCH_USE_MPI) + target_include_directories(cgpatch-runtime PRIVATE ${MPI_C_INCLUDE_DIRS}) target_compile_definitions(cgpatch-runtime PRIVATE USE_MPI=1) endif() diff --git a/tools/cgpatch/test/integration/CGPIntegrationRunner.sh.in b/tools/cgpatch/test/integration/CGPIntegrationRunner.sh.in index baa8f6f7..2049fb51 100755 --- a/tools/cgpatch/test/integration/CGPIntegrationRunner.sh.in +++ b/tools/cgpatch/test/integration/CGPIntegrationRunner.sh.in @@ -53,6 +53,13 @@ cgmerge2Exe="$buildDir/tools/cgmerge2/cgmerge2" outputDir=$buildDir/tools/cgpatch/test/integration +if [ "$CGPATCH_USE_MPI" == "ON" ]; then + compiler=mpicxx +else + compiler=clang++ +fi + + if [ ! -d "${logDir}" ]; then mkdir "${logDir}" fi @@ -71,14 +78,14 @@ function build_and_run_mpi_testcase { local testDir="$3" local testExe="$outputDir/${testName}.out" local testPG="$outputDir/${testName}.pg" - local testGT="$test_root/input/mpi/{testName}.gtpg" + local testGT="$test_root/input/mpi/${testName}.gtpg" local testMCG="$outputDir/${testName}.mcg" - local testSCG="$test_root/input/general/${testName}.ipcg" + local testSCG="$test_root/input/mpi/${testName}.ipcg" export CGPATCH_CG_NAME="${testPG}" log "Compiling MPI testcase: $testSources" - $cgpatchExe mpicxx $testSources -o "$testExe" >> "$logFile" + $cgpatchExe $compiler $testSources -o "$testExe" >> "$logFile" if [ $? -ne 0 ]; then echo "Compilation failed for $testName" fails=$((fails + 1)) @@ -109,7 +116,7 @@ function build_and_run_regular_testcase { export CGPATCH_CG_NAME="${testPG}" log "Compiling regular testcase: $testSources" - $cgpatchExe clang++ $testSources -o "$testExe" >> "$logFile" + $cgpatchExe $compiler $testSources -o "$testExe" >> "$logFile" if [ $? -ne 0 ]; then echo "Compilation failed for $testName" fails=$((fails + 1))