diff --git a/CMakeLists.txt b/CMakeLists.txt index cfe681a09..ce61e6696 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,8 @@ project(taco) option(CUDA "Build for NVIDIA GPU (CUDA must be preinstalled)" OFF) option(PYTHON "Build TACO for python environment" OFF) option(OPENMP "Build with OpenMP execution support" OFF) -option(LLVM "Build with LLVM backend support") +option(LLVM "Build with LLVM backend support" OFF) +option(ENABLE_TESTS "Enable tests" ON) if(CUDA) @@ -30,6 +31,7 @@ if (LLVM) llvm_map_components_to_libnames(llvm_libs support core irreader) add_definitions(-DUSE_LLVM) add_definitions(-DENABLE_TOSTRING_LLVM) + add_definitions(-DHAVE_LLVM) endif(LLVM) SET(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo") @@ -101,7 +103,6 @@ set(TACO_TEST_DIR ${TACO_PROJECT_DIR}/test) set(TACO_TOOLS_DIR ${TACO_PROJECT_DIR}/tools) set(TACO_INCLUDE_DIR "${TACO_INCLUDE_DIR};${TACO_PROJECT_DIR}/include") -enable_testing() include_directories(${TACO_INCLUDE_DIR}) set(TACO_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) @@ -109,7 +110,12 @@ set(TACO_LIBRARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) install(DIRECTORY ${TACO_INCLUDE_DIR}/ DESTINATION include) add_subdirectory(src) -add_subdirectory(test) + +if (${ENABLE_TESTS}) + enable_testing() + add_subdirectory(test) +endif() + add_subdirectory(tools) add_subdirectory(apps) string(REPLACE " -Wmissing-declarations" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") diff --git a/src/codegen/codegen.cpp b/src/codegen/codegen.cpp index 7d0610373..87978f297 100644 --- a/src/codegen/codegen.cpp +++ b/src/codegen/codegen.cpp @@ -3,7 +3,11 @@ #include "taco/llvm.h" #include "codegen_cuda.h" #include "codegen_c.h" + +#ifdef HAVE_LLVM #include "codegen_llvm.h" +#endif + #include #include @@ -28,9 +32,11 @@ shared_ptr CodeGen::init_default(std::ostream &dest, OutputKind outputK if (should_use_CUDA_codegen()) { return make_shared(dest, outputKind); } - if (should_use_LLVM_codegen()){ + #ifdef HAVE_LLVM + else if (should_use_LLVM_codegen()){ return make_shared(dest, outputKind); } + #endif else { return make_shared(dest, outputKind); } diff --git a/src/codegen/codegen_llvm.cpp b/src/codegen/codegen_llvm.cpp index 401b5df1d..0ecd96c6e 100644 --- a/src/codegen/codegen_llvm.cpp +++ b/src/codegen/codegen_llvm.cpp @@ -1,3 +1,4 @@ +#ifdef HAVE_LLVM #include "llvm/IR/Module.h" #include "llvm/IR/Verifier.h" @@ -673,4 +674,5 @@ void CodeGen_LLVM::visit(const GetProperty *op) { } } // namespace ir -} // namespace taco \ No newline at end of file +} // namespace taco +#endif // HAVE_LLVM \ No newline at end of file diff --git a/src/codegen/codegen_llvm.h b/src/codegen/codegen_llvm.h index db4682477..0a4e6f832 100644 --- a/src/codegen/codegen_llvm.h +++ b/src/codegen/codegen_llvm.h @@ -1,3 +1,4 @@ +#ifdef HAVE_LLVM #ifndef TACO_BACKEND_LLVM_H #define TACO_BACKEND_LLVM_H @@ -137,4 +138,5 @@ namespace taco } // namespace ir } // namespace taco -#endif \ No newline at end of file +#endif // TACO_BACKEND_LLVM_H +#endif // HAVE_LLVM \ No newline at end of file diff --git a/src/codegen/module.cpp b/src/codegen/module.cpp index 70ac6666e..2fd3efc98 100644 --- a/src/codegen/module.cpp +++ b/src/codegen/module.cpp @@ -14,9 +14,12 @@ #include "taco/util/env.h" #include "codegen/codegen_c.h" #include "codegen/codegen_cuda.h" -#include "codegen/codegen_llvm.h" #include "taco/cuda.h" +#ifdef HAVE_LLVM +#include "codegen/codegen_llvm.h" +#endif + using namespace std; namespace taco { diff --git a/src/llvm.cpp b/src/llvm.cpp index 56b90adc9..27d9c86b4 100644 --- a/src/llvm.cpp +++ b/src/llvm.cpp @@ -4,7 +4,7 @@ namespace taco{ static bool LLVM_codegen_enabled = USE_LLVM; bool should_use_LLVM_codegen(){ - return LLVM_codegen_enabled; + return LLVM_codegen_enabled; } void set_LLVM_codegen_enabled(bool enabled) { diff --git a/tools/taco.cpp b/tools/taco.cpp index dfb47feb4..153892d03 100644 --- a/tools/taco.cpp +++ b/tools/taco.cpp @@ -19,7 +19,6 @@ #include "taco/codegen/module.h" #include "codegen/codegen_c.h" #include "codegen/codegen_cuda.h" -#include "codegen/codegen_llvm.h" #include "codegen/codegen.h" #include "taco/util/strings.h" #include "taco/util/files.h" @@ -29,11 +28,14 @@ #include "taco/util/collections.h" #include "taco/cuda.h" #include "taco/llvm.h" -#include "taco/llvm.h" #include "taco/index_notation/transformations.h" #include "taco/index_notation/index_notation_visitor.h" #include "taco/index_notation/index_notation_nodes.h" +#ifdef HAVE_LLVM +#include "codegen/codegen_llvm.h" +#endif + using namespace std; using namespace taco; @@ -966,8 +968,7 @@ int main(int argc, char* argv[]) { } set_LLVM_codegen_enabled(true); } - else - { + else { set_LLVM_codegen_enabled(false); }