Hide the use of FetchContent behind a flag
FetchContent is now disabled by default, when the project is included as an subproject by another top-level project. Also, every usage of FetchContent is behind a separate flag to enable and disable the usage with granular control.
This commit is contained in:
@@ -47,9 +47,14 @@ if(POLICY CMP0135)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||||
include(FetchContent)
|
|
||||||
include(enable_extensions)
|
include(enable_extensions)
|
||||||
|
|
||||||
|
if (PROJECT_IS_TOP_LEVEL)
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(DRAMSYS_ENABLE_COVERAGE)
|
if(DRAMSYS_ENABLE_COVERAGE)
|
||||||
include(coverage)
|
include(coverage)
|
||||||
endif()
|
endif()
|
||||||
@@ -57,9 +62,18 @@ endif()
|
|||||||
### Project settings ###
|
### Project settings ###
|
||||||
option(DRAMSYS_BUILD_TESTS "Build DRAMSys unit tests" OFF)
|
option(DRAMSYS_BUILD_TESTS "Build DRAMSys unit tests" OFF)
|
||||||
option(DRAMSYS_BUILD_BENCHMARKS "Build DRAMSys benchmarks" OFF)
|
option(DRAMSYS_BUILD_BENCHMARKS "Build DRAMSys benchmarks" OFF)
|
||||||
option(DRAMSYS_BUILD_CLI "Build DRAMSys Command Line Tool" ON)
|
option(DRAMSYS_BUILD_CLI "Build DRAMSys Command Line Tool" ${PROJECT_IS_TOP_LEVEL})
|
||||||
option(DRAMSYS_BUILD_TRACE_ANALYZER "Build DRAMSys Trace Analyzer" OFF)
|
option(DRAMSYS_BUILD_TRACE_ANALYZER "Build DRAMSys Trace Analyzer" OFF)
|
||||||
option(DRAMSYS_WITH_DRAMPOWER "Build with DRAMPower support enabled." ON)
|
option(DRAMSYS_WITH_DRAMPOWER "Build with DRAMPower support enabled." OFF)
|
||||||
|
|
||||||
|
# Use sane defaults for FetchContent:
|
||||||
|
# In case we are the top-level project, get everything by default
|
||||||
|
# In case we are included in another project, the user might want to provide their own system dependencies
|
||||||
|
option(DRAMSYS_USE_FETCH_CONTENT "Enable the FetchContent module" ${PROJECT_IS_TOP_LEVEL})
|
||||||
|
option(DRAMSYS_USE_FETCH_CONTENT_INTERNAL "Enable FetchContent to provide internal dependencies" ${DRAMSYS_USE_FETCH_CONTENT})
|
||||||
|
option(DRAMSYS_USE_FETCH_CONTENT_SYSTEMC "Enable FetchContent to provide SystemC" ${DRAMSYS_USE_FETCH_CONTENT})
|
||||||
|
option(DRAMSYS_USE_FETCH_CONTENT_SQLITE3 "Enable FetchContent to provide SQLite3" ${DRAMSYS_USE_FETCH_CONTENT})
|
||||||
|
option(DRAMSYS_USE_FETCH_CONTENT_NLOHMANN_JSON "Enable FetchContent to provide nlohmann_json" ${DRAMSYS_USE_FETCH_CONTENT})
|
||||||
|
|
||||||
# TODO: Remove as soon as DRAMPower is updated
|
# TODO: Remove as soon as DRAMPower is updated
|
||||||
set(DRAMSYS_SHARED_LIBS OFF)
|
set(DRAMSYS_SHARED_LIBS OFF)
|
||||||
@@ -68,12 +82,6 @@ if(DEFINED DRAMSYS_SHARED_LIBS)
|
|||||||
set(BUILD_SHARED_LIBS ${DRAMSYS_SHARED_LIBS})
|
set(BUILD_SHARED_LIBS ${DRAMSYS_SHARED_LIBS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (PROJECT_IS_TOP_LEVEL)
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
### DRAMSys directories ###
|
### DRAMSys directories ###
|
||||||
set(DRAMSYS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
set(DRAMSYS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||||
set(DRAMSYS_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
set(DRAMSYS_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
||||||
@@ -85,42 +93,52 @@ set(DRAMSYS_EXTENSIONS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extensions")
|
|||||||
### Library Settings ###
|
### Library Settings ###
|
||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
### nlohmann_json ###
|
if (DRAMSYS_USE_FETCH_CONTENT)
|
||||||
add_subdirectory(${DRAMSYS_LIBRARY_DIR})
|
include(FetchContent)
|
||||||
|
|
||||||
|
if (DRAMSYS_USE_FETCH_CONTENT_NLOHMANN_JSON)
|
||||||
|
FetchContent_Declare(nlohmann_json
|
||||||
|
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
|
||||||
|
OVERRIDE_FIND_PACKAGE
|
||||||
|
)
|
||||||
|
|
||||||
if (NOT TARGET nlohmann_json::nlohmann_json)
|
|
||||||
FetchContent_Declare(nlohmann_json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
|
|
||||||
FetchContent_MakeAvailable(nlohmann_json)
|
FetchContent_MakeAvailable(nlohmann_json)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
### SystemC ###
|
if (DRAMSYS_USE_FETCH_CONTENT_SQLITE3)
|
||||||
if (NOT TARGET SystemC::systemc) # TODO ist das wirklich so korrekt?
|
add_subdirectory(${DRAMSYS_LIBRARY_DIR}/sqlite3)
|
||||||
set(DISABLE_COPYRIGHT_MESSAGE True)
|
endif()
|
||||||
|
|
||||||
|
if (DRAMSYS_USE_FETCH_CONTENT_SYSTEMC)
|
||||||
|
set(DISABLE_COPYRIGHT_MESSAGE TRUE)
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
systemc
|
SystemCLanguage
|
||||||
GIT_REPOSITORY https://github.com/accellera-official/systemc.git
|
GIT_REPOSITORY https://github.com/accellera-official/systemc.git
|
||||||
GIT_TAG 2.3.4)
|
GIT_TAG 2.3.4
|
||||||
|
OVERRIDE_FIND_PACKAGE
|
||||||
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(systemc)
|
FetchContent_MakeAvailable(SystemCLanguage)
|
||||||
|
|
||||||
# Set include directories to SYSTEM to suppress warnings
|
# Set include directories to SYSTEM to suppress warnings
|
||||||
set_target_properties(systemc PROPERTIES SYSTEM TRUE)
|
set_target_properties(systemc PROPERTIES SYSTEM TRUE)
|
||||||
else()
|
|
||||||
find_package(systemc NAMES SystemCLanguage)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (DRAMSYS_WITH_DRAMPOWER AND DRAMSYS_USE_FETCH_CONTENT_INTERNAL)
|
||||||
### DRAMPower ###
|
|
||||||
if (DRAMSYS_WITH_DRAMPOWER)
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
DRAMPower
|
DRAMPower
|
||||||
GIT_REPOSITORY https://github.com/tukl-msd/DRAMPower
|
GIT_REPOSITORY https://github.com/tukl-msd/DRAMPower
|
||||||
GIT_TAG 9e64a1b)
|
GIT_TAG 9e64a1b
|
||||||
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(DRAMPower)
|
FetchContent_MakeAvailable(DRAMPower)
|
||||||
set_target_properties(DRAMPower PROPERTIES FOLDER lib)
|
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(SystemCLanguage REQUIRED)
|
||||||
|
find_package(SQLite3 REQUIRED)
|
||||||
|
find_package(nlohmann_json REQUIRED)
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
### Source Directory ###
|
### Source Directory ###
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
"inherits": "cmake-pedantic",
|
"inherits": "cmake-pedantic",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"DRAMSYS_BUILD_TESTS": "ON",
|
"DRAMSYS_BUILD_TESTS": "ON",
|
||||||
"DRAMSYS_WITH_DRAMPOWER": "ON",
|
"DRAMSYS_BUILD_TRACE_ANALYZER": "ON",
|
||||||
"DRAMSYS_BUILD_TRACE_ANALYZER": "ON"
|
"DRAMSYS_WITH_DRAMPOWER": "ON"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
add_subdirectory(sqlite3)
|
|
||||||
@@ -2,8 +2,12 @@
|
|||||||
### sqlite3 ###
|
### sqlite3 ###
|
||||||
########################################
|
########################################
|
||||||
|
|
||||||
FetchContent_Declare(sqlite3 URL "https://www.sqlite.org/2022/sqlite-amalgamation-3400100.zip")
|
FetchContent_Declare(SQLite3
|
||||||
FetchContent_MakeAvailable(sqlite3)
|
URL "https://www.sqlite.org/2022/sqlite-amalgamation-3400100.zip"
|
||||||
|
OVERRIDE_FIND_PACKAGE
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(SQLite3)
|
||||||
|
|
||||||
add_library(sqlite3)
|
add_library(sqlite3)
|
||||||
target_sources(sqlite3 PRIVATE
|
target_sources(sqlite3 PRIVATE
|
||||||
@@ -14,11 +18,8 @@ target_sources(sqlite3 PRIVATE
|
|||||||
|
|
||||||
target_include_directories(sqlite3 PUBLIC ${sqlite3_SOURCE_DIR})
|
target_include_directories(sqlite3 PUBLIC ${sqlite3_SOURCE_DIR})
|
||||||
|
|
||||||
set_target_properties(sqlite3 PROPERTIES FOLDER lib)
|
|
||||||
|
|
||||||
### Compile options ###
|
### Compile options ###
|
||||||
# refer to https://www.sqlite.org/compile.html
|
# refer to https://www.sqlite.org/compile.html
|
||||||
|
|
||||||
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_RTREE SQLITE_OMIT_LOAD_EXTENSION)
|
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_RTREE SQLITE_OMIT_LOAD_EXTENSION)
|
||||||
|
|
||||||
# Use the same name as the FindSQLite3 script of CMake uses
|
# Use the same name as the FindSQLite3 script of CMake uses
|
||||||
|
|||||||
@@ -38,29 +38,35 @@
|
|||||||
### TraceAnalyzer ###
|
### TraceAnalyzer ###
|
||||||
########################################
|
########################################
|
||||||
|
|
||||||
# Add Python3 Dependency:
|
option(DRAMSYS_USE_FETCH_CONTENT_PYBIND "Enable FetchContent to provide pybind11" ${DRAMSYS_USE_FETCH_CONTENT})
|
||||||
find_package(Python3 COMPONENTS Development Interpreter)
|
|
||||||
|
|
||||||
|
if (DRAMSYS_USE_FETCH_CONTENT)
|
||||||
|
if (DRAMSYS_USE_FETCH_CONTENT_PYBIND)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
pybind11
|
pybind11
|
||||||
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.13.1.zip
|
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.13.1.zip
|
||||||
|
OVERRIDE_FIND_PACKAGE
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(pybind11)
|
FetchContent_MakeAvailable(pybind11)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Add QT Library:
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
set(Qt5_DIR "/opt/homebrew/opt/qt@5/lib/cmake/Qt5")
|
set(Qt5_DIR "/opt/homebrew/opt/qt@5/lib/cmake/Qt5")
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
|
||||||
find_package(Qt5 COMPONENTS Core Gui Widgets Sql REQUIRED)
|
find_package(Qt5 COMPONENTS Core Gui Widgets Sql REQUIRED)
|
||||||
|
find_package(Qwt REQUIRED)
|
||||||
|
|
||||||
|
find_package(Python3 COMPONENTS Development Interpreter REQUIRED)
|
||||||
|
find_package(pybind11 REQUIRED)
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
# Add QWT Dependency:
|
|
||||||
find_package(Qwt REQUIRED)
|
|
||||||
|
|
||||||
add_executable(TraceAnalyzer
|
add_executable(TraceAnalyzer
|
||||||
businessObjects/commentmodel.cpp
|
businessObjects/commentmodel.cpp
|
||||||
businessObjects/configmodels.cpp
|
businessObjects/configmodels.cpp
|
||||||
|
|||||||
@@ -2,12 +2,22 @@ include(GoogleTest)
|
|||||||
|
|
||||||
set(DRAMSYS_TEST_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
|
set(DRAMSYS_TEST_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
|
||||||
|
|
||||||
FetchContent_Declare(
|
option(DRAMSYS_USE_FETCH_CONTENT_GTEST "Enable FetchContent to provide gtest" ${DRAMSYS_USE_FETCH_CONTENT})
|
||||||
googletest
|
|
||||||
GIT_REPOSITORY https://github.com/google/googletest
|
|
||||||
GIT_TAG release-1.12.1)
|
|
||||||
|
|
||||||
FetchContent_MakeAvailable(googletest)
|
if (DRAMSYS_USE_FETCH_CONTENT)
|
||||||
|
if (DRAMSYS_USE_FETCH_CONTENT_GTEST)
|
||||||
|
FetchContent_Declare(
|
||||||
|
GTest
|
||||||
|
GIT_REPOSITORY https://github.com/google/googletest
|
||||||
|
GIT_TAG release-1.12.1
|
||||||
|
OVERRIDE_FIND_PACKAGE
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(GTest)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(GTest REQUIRED)
|
||||||
|
|
||||||
add_subdirectory(tests_configuration)
|
add_subdirectory(tests_configuration)
|
||||||
add_subdirectory(tests_dramsys)
|
add_subdirectory(tests_dramsys)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ set_target_properties(tests_configuration PROPERTIES FOLDER tests/configuration)
|
|||||||
|
|
||||||
target_link_libraries(tests_configuration PRIVATE
|
target_link_libraries(tests_configuration PRIVATE
|
||||||
DRAMSys::config
|
DRAMSys::config
|
||||||
|
gtest
|
||||||
gtest_main
|
gtest_main
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ target_include_directories(tests_dramsys PUBLIC ${PROJECT_SOURCE_DIR})
|
|||||||
set_target_properties(tests_dramsys PROPERTIES FOLDER tests)
|
set_target_properties(tests_dramsys PROPERTIES FOLDER tests)
|
||||||
target_link_libraries(tests_dramsys
|
target_link_libraries(tests_dramsys
|
||||||
DRAMSys::libdramsys
|
DRAMSys::libdramsys
|
||||||
|
gtest
|
||||||
gtest_main
|
gtest_main
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ set_target_properties(tests_simulator PROPERTIES FOLDER tests/simulator)
|
|||||||
|
|
||||||
target_link_libraries(tests_simulator PRIVATE
|
target_link_libraries(tests_simulator PRIVATE
|
||||||
simulator
|
simulator
|
||||||
|
gtest
|
||||||
gtest_main
|
gtest_main
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user