Skip to content

Commit 92f0a09

Browse files
Fix build without llvm support (#2)
* Fixes to build taco without LLVM support * Add ENABLE_TESTS cmake command
1 parent d51ba6b commit 92f0a09

File tree

7 files changed

+32
-12
lines changed

7 files changed

+32
-12
lines changed

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ project(taco)
33
option(CUDA "Build for NVIDIA GPU (CUDA must be preinstalled)" OFF)
44
option(PYTHON "Build TACO for python environment" OFF)
55
option(OPENMP "Build with OpenMP execution support" OFF)
6-
option(LLVM "Build with LLVM backend support")
6+
option(LLVM "Build with LLVM backend support" OFF)
7+
option(ENABLE_TESTS "Enable tests" ON)
78

89

910
if(CUDA)
@@ -30,6 +31,7 @@ if (LLVM)
3031
llvm_map_components_to_libnames(llvm_libs support core irreader)
3132
add_definitions(-DUSE_LLVM)
3233
add_definitions(-DENABLE_TOSTRING_LLVM)
34+
add_definitions(-DHAVE_LLVM)
3335
endif(LLVM)
3436

3537
SET(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
@@ -101,15 +103,19 @@ set(TACO_TEST_DIR ${TACO_PROJECT_DIR}/test)
101103
set(TACO_TOOLS_DIR ${TACO_PROJECT_DIR}/tools)
102104
set(TACO_INCLUDE_DIR "${TACO_INCLUDE_DIR};${TACO_PROJECT_DIR}/include")
103105

104-
enable_testing()
105106
include_directories(${TACO_INCLUDE_DIR})
106107

107108
set(TACO_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
108109

109110
install(DIRECTORY ${TACO_INCLUDE_DIR}/ DESTINATION include)
110111

111112
add_subdirectory(src)
112-
add_subdirectory(test)
113+
114+
if (${ENABLE_TESTS})
115+
enable_testing()
116+
add_subdirectory(test)
117+
endif()
118+
113119
add_subdirectory(tools)
114120
add_subdirectory(apps)
115121
string(REPLACE " -Wmissing-declarations" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

src/codegen/codegen.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
#include "taco/llvm.h"
44
#include "codegen_cuda.h"
55
#include "codegen_c.h"
6+
7+
#ifdef HAVE_LLVM
68
#include "codegen_llvm.h"
9+
#endif
10+
711
#include <algorithm>
812
#include <unordered_set>
913

@@ -28,9 +32,11 @@ shared_ptr<CodeGen> CodeGen::init_default(std::ostream &dest, OutputKind outputK
2832
if (should_use_CUDA_codegen()) {
2933
return make_shared<CodeGen_CUDA>(dest, outputKind);
3034
}
31-
if (should_use_LLVM_codegen()){
35+
#ifdef HAVE_LLVM
36+
else if (should_use_LLVM_codegen()){
3237
return make_shared<CodeGen_LLVM>(dest, outputKind);
3338
}
39+
#endif
3440
else {
3541
return make_shared<CodeGen_C>(dest, outputKind);
3642
}

src/codegen/codegen_llvm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifdef HAVE_LLVM
12
#include "llvm/IR/Module.h"
23
#include "llvm/IR/Verifier.h"
34

@@ -673,4 +674,5 @@ void CodeGen_LLVM::visit(const GetProperty *op) {
673674
}
674675

675676
} // namespace ir
676-
} // namespace taco
677+
} // namespace taco
678+
#endif // HAVE_LLVM

src/codegen/codegen_llvm.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifdef HAVE_LLVM
12
#ifndef TACO_BACKEND_LLVM_H
23
#define TACO_BACKEND_LLVM_H
34

@@ -137,4 +138,5 @@ namespace taco
137138
} // namespace ir
138139
} // namespace taco
139140

140-
#endif
141+
#endif // TACO_BACKEND_LLVM_H
142+
#endif // HAVE_LLVM

src/codegen/module.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
#include "taco/util/env.h"
1515
#include "codegen/codegen_c.h"
1616
#include "codegen/codegen_cuda.h"
17-
#include "codegen/codegen_llvm.h"
1817
#include "taco/cuda.h"
1918

19+
#ifdef HAVE_LLVM
20+
#include "codegen/codegen_llvm.h"
21+
#endif
22+
2023
using namespace std;
2124

2225
namespace taco {

src/llvm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace taco{
44

55
static bool LLVM_codegen_enabled = USE_LLVM;
66
bool should_use_LLVM_codegen(){
7-
return LLVM_codegen_enabled;
7+
return LLVM_codegen_enabled;
88
}
99

1010
void set_LLVM_codegen_enabled(bool enabled) {

tools/taco.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "taco/codegen/module.h"
2020
#include "codegen/codegen_c.h"
2121
#include "codegen/codegen_cuda.h"
22-
#include "codegen/codegen_llvm.h"
2322
#include "codegen/codegen.h"
2423
#include "taco/util/strings.h"
2524
#include "taco/util/files.h"
@@ -29,11 +28,14 @@
2928
#include "taco/util/collections.h"
3029
#include "taco/cuda.h"
3130
#include "taco/llvm.h"
32-
#include "taco/llvm.h"
3331
#include "taco/index_notation/transformations.h"
3432
#include "taco/index_notation/index_notation_visitor.h"
3533
#include "taco/index_notation/index_notation_nodes.h"
3634

35+
#ifdef HAVE_LLVM
36+
#include "codegen/codegen_llvm.h"
37+
#endif
38+
3739
using namespace std;
3840
using namespace taco;
3941

@@ -966,8 +968,7 @@ int main(int argc, char* argv[]) {
966968
}
967969
set_LLVM_codegen_enabled(true);
968970
}
969-
else
970-
{
971+
else {
971972
set_LLVM_codegen_enabled(false);
972973
}
973974

0 commit comments

Comments
 (0)