CMakeLists.txt 2.64 KB
Newer Older
Anirudh Kaushik's avatar
Anirudh Kaushik committed
1
cmake_minimum_required(VERSION 2.6)
rmrf's avatar
rmrf committed
2 3 4 5 6 7
project(systemc-clang)
# Use C++ standard version to c++17
set(CMAKE_CXX_STANDARD 17)
# Always keep it on
set(CMAKE_CXX_STANDARD_REQUIRED ON)

8
# Required packages
9 10
# TODO: Add the code to find library and/or the specific in-source file.
# find_package(nlohmann_json 3.2.0 REQUIRED)
11 12


rmrf's avatar
rmrf committed
13 14 15
option (USE_SAUTO
  "Use suspension-automata library." OFF
  )
16 17 18 19 20

option (USE_SILENT_BUILD
  "Silent as many warnings as possible." OFF
  )

rmrf's avatar
rmrf committed
21 22 23
set (ROOT_CPP
  driver-tooling.cpp
  )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
24

rmrf's avatar
rmrf committed
25 26 27
set (LLVM_BUILD_DIR
  $ENV{LLVM_BUILD_DIR}
  )
28

rmrf's avatar
rmrf committed
29
set (CMAKE_CXX_FLAGS
30
  "$ENV{LLVM_CXX_FLAGS} $ENV{CMAKE_CXX_FLAGS} -DUSE_SAUTO=off "
rmrf's avatar
rmrf committed
31
  )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
32 33 34

if (USE_SAUTO)
  set (CMAKE_CXX_FLAGS
rmrf's avatar
rmrf committed
35 36
    "-DUSE_SAUTO=on ${CMAKE_CXX_FLAGS}"
    )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
37 38
endif(USE_SAUTO)

39 40 41 42 43 44
if (USE_SILENT_BUILD)
  set (CMAKE_CXX_FLAGS
    "-DUSE_SILENT_BUILD=on ${CMAKE_CXX_FLAGS} -Wcovered-switch-default"
    )
endif(USE_SILENT_BUILD)

Anirudh Kaushik's avatar
Anirudh Kaushik committed
45

rmrf's avatar
rmrf committed
46 47 48
set (LLVM_LD_FLAGS
  "$ENV{LLVM_LD_FLAGS} -lpthread"
  )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
49

rmrf's avatar
rmrf committed
50 51 52
set (LLVM_LIBS
  $ENV{LLVM_LIBS}
  )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
53 54 55 56 57

#set (LLVM_LD_LIBS LLVMCppBackendCodeGen LLVMCppBackendInfo LLVMTarget LLVMCore LLVMMC LLVMObject LLVMSupport)

#LLVMJIT LLVMX86CodeGen LLVMX86AsmParser LLVMX86Disassembler LLVMExecutionEngine LLVMAsmPrinter LLVMSelectionDAG LLVMX86AsmPrinter LLVMX86Info LLVMMCParser LLVMCodeGen LLVMX86Utils LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMTarget LLVMCore LLVMMC LLVMSupport

rmrf's avatar
rmrf committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
set (CLANG_LIBS
  clangTooling
  clangFrontendTool
  clangFrontend
  clangDriver
  clangSerialization
  clangCodeGen
  clangParse
  clangSema
  clangStaticAnalyzerFrontend
  clangStaticAnalyzerCheckers
  clangStaticAnalyzerCore
  clangAnalysis
  clangARCMigrate
  clangRewriteFrontend
  clangRewrite
  clangEdit
  clangAST
  clangLex
  clangBasic
  clangASTMatchers
  )


set (CMAKE_MODULE_LINKER_FLAGS
  $ENV{LLVM_LD_FLAGS}
  )

set (TARGET
  "systemc-clang"
  )


include_directories(
  "${LLVM_BUILD_DIR}/include"
  src
  if (USE_SAUTO)
    sauto
  endif (USE_SAUTO)

  )


link_directories(
  ${LLVM_BUILD_DIR}/lib
  )

add_subdirectory(src)
add_subdirectory(tests)
Anirudh Kaushik's avatar
Anirudh Kaushik committed
107 108 109 110 111 112

if (USE_SAUTO)
  add_subdirectory(sauto)
endif (USE_SAUTO)


rmrf's avatar
rmrf committed
113
set( SRC_LIB libsystemc-clang )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
114 115 116
if (USE_SAUTO)
  set( SAUTO_LIB libsauto )
endif (USE_SAUTO)
rmrf's avatar
rmrf committed
117 118 119
add_executable(
  ${TARGET}
  ${ROOT_CPP} )
rmrf's avatar
rmrf committed
120

121 122
target_link_libraries(${TARGET} ${SRC_LIB}) #nlohmann_json::nlohmann_json)
target_link_libraries(${TARGET} ${SAUTO_LIB}) # nlohmann_json::nlohmann_json)
Anirudh Kaushik's avatar
Anirudh Kaushik committed
123

rmrf's avatar
rmrf committed
124 125 126
foreach (clang_lib ${CLANG_LIBS})
  target_link_libraries( ${TARGET} ${clang_lib} )
endforeach()
Anirudh Kaushik's avatar
Anirudh Kaushik committed
127

rmrf's avatar
rmrf committed
128 129 130
foreach (ld_flag ${LLVM_LD_FLAGS})
  target_link_libraries( ${TARGET} ${ld_flag} )
endforeach()
Anirudh Kaushik's avatar
Anirudh Kaushik committed
131

rmrf's avatar
rmrf committed
132 133 134
foreach (llvm_lib ${LLVM_LIBS})
  target_link_libraries( ${TARGET} ${llvm_lib} )
endforeach()