CMakeLists.txt 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. cmake_minimum_required(VERSION 3.3)
  2. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/sc-components/cmake)
  3. set(ENABLE_SCV TRUE CACHE BOOL "Enable use of SCV")
  4. include(GitFunctions)
  5. get_branch_from_git()
  6. # if we are not on master or develop set the submodules to develop
  7. IF(NOT ${GIT_BRANCH} MATCHES "master")
  8. IF(NOT ${GIT_BRANCH} MATCHES "develop")
  9. message(STATUS "main branch is '${GIT_BRANCH}', setting submodules to 'develop'")
  10. set(GIT_BRANCH develop)
  11. endif()
  12. endif()
  13. ### set the directory names of the submodules
  14. set(GIT_SUBMODULES elfio libGIS sc-components dbt-core)
  15. set(GIT_SUBMODULE_DIR_sc-components .)
  16. set(GIT_SUBMODULE_DIR_dbt-core .)
  17. ### set each submodules's commit or tag that is to be checked out
  18. ### (leave empty if you want master)
  19. #set(GIT_SUBMODULE_VERSION_sc-comp 3af6b9836589b082c19d9131c5d0b7afa8ddd7cd)
  20. set(GIT_SUBMODULE_BRANCH_sc-components ${GIT_BRANCH})
  21. set(GIT_SUBMODULE_BRANCH_dbt-core ${GIT_BRANCH})
  22. include(GNUInstallDirs)
  23. include(Submodules)
  24. include(Conan)
  25. #enable_testing()
  26. set(CMAKE_CXX_STANDARD 14)
  27. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  28. set(CMAKE_CXX_EXTENSIONS OFF)
  29. include(CheckCXXCompilerFlag)
  30. CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
  31. if(COMPILER_SUPPORTS_MARCH_NATIVE)
  32. if("${CMAKE_BUILD_TYPE}" STREQUAL "")
  33. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
  34. elseif(NOT(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo"))
  35. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
  36. endif()
  37. endif()
  38. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  39. set(warnings "-Wall -Wextra -Werror")
  40. #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
  41. set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
  42. set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
  43. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
  44. set(warnings "/W4 /WX /EHsc")
  45. endif()
  46. setup_conan()
  47. # This line finds the boost lib and headers.
  48. set(Boost_NO_BOOST_CMAKE ON) # Don't do a find_package in config mode before searching for a regular boost install.
  49. find_package(Boost COMPONENTS program_options system thread filesystem REQUIRED)
  50. if(DEFINED ENV{LLVM_HOME})
  51. find_path (LLVM_DIR LLVM-Config.cmake $ENV{LLVM_HOME}/lib/cmake/llvm)
  52. endif(DEFINED ENV{LLVM_HOME})
  53. find_package(LLVM REQUIRED CONFIG)
  54. message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
  55. message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
  56. llvm_map_components_to_libnames(llvm_libs support core mcjit x86codegen x86asmparser)
  57. find_package(Threads)
  58. find_package(Tcmalloc)
  59. find_package(ZLIB)
  60. find_package(SystemC)
  61. if(SystemC_FOUND)
  62. message(STATUS "SystemC headers at ${SystemC_INCLUDE_DIRS}")
  63. message(STATUS "SystemC library at ${SystemC_LIBRARY_DIRS}")
  64. if(SCV_FOUND)
  65. message(STATUS "SCV headers at ${SCV_INCLUDE_DIRS}")
  66. message(STATUS "SCV library at ${SCV_LIBRARY_DIRS}")
  67. endif(SCV_FOUND)
  68. if(CCI_FOUND)
  69. message(STATUS "CCI headers at ${CCI_INCLUDE_DIRS}")
  70. message(STATUS "CCI library at ${CCI_LIBRARY_DIRS}")
  71. endif()
  72. endif(SystemC_FOUND)
  73. set(PROJECT_3PARTY_DIRS external)
  74. include(clang-format)
  75. set(ENABLE_CLANG_TIDY OFF CACHE BOOL "Add clang-tidy automatically to builds")
  76. if (ENABLE_CLANG_TIDY)
  77. find_program (CLANG_TIDY_EXE NAMES "clang-tidy" PATHS /usr/local/opt/llvm/bin )
  78. if (CLANG_TIDY_EXE)
  79. message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
  80. set(CLANG_TIDY_CHECKS "-*,modernize-*")
  81. set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-checks=${CLANG_TIDY_CHECKS};-header-filter='${CMAKE_SOURCE_DIR}/*';-fix"
  82. CACHE STRING "" FORCE)
  83. else()
  84. message(AUTHOR_WARNING "clang-tidy not found!")
  85. set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it
  86. endif()
  87. endif()
  88. # Set the version number of your project here (format is MAJOR.MINOR.PATCHLEVEL - e.g. 1.0.0)
  89. set(VERSION_MAJOR "1")
  90. set(VERSION_MINOR "0")
  91. set(VERSION_PATCH "0")
  92. set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
  93. add_subdirectory(external)
  94. add_subdirectory(dbt-core)
  95. add_subdirectory(sc-components)
  96. add_subdirectory(softfloat)
  97. GET_DIRECTORY_PROPERTY(SOFTFLOAT_INCLUDE_DIRS DIRECTORY softfloat DEFINITION SOFTFLOAT_INCLUDE_DIRS)
  98. add_subdirectory(riscv)
  99. add_subdirectory(platform)
  100. message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")