CMakeLists.txt.orig 4.5KB

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