Skip to content

Commit

Permalink
fixes build system for non-conan build
Browse files Browse the repository at this point in the history
  • Loading branch information
eyck committed Dec 11, 2022
1 parent b51a433 commit 87eb1a1
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 36 deletions.
51 changes: 28 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ option(USE_CWR_SYSTEMC "Use Synopsys Virtualizer SystemC" OFF)

option(USE_NCSC_SYSTEMC "Cadence Xcelium SystemC" OFF)

option(ENABLE_CONAN "Enable the use of conan in standalone build" ON)

#Note: this needs to match the SystemC kernel build options
option(SC_WITH_PHASE_CALLBACKS "Whether SystemC is built with simulation phase callbacks" OFF)

Expand All @@ -20,24 +22,26 @@ include(Common)
if(CMAKE_PROJECT_NAME STREQUAL "scc")
message(STATUS "Building SCC in standalone mode")
include(GNUInstallDirs)
include(ConanInline)
conan_check()
set(CONAN_PACKAGE_LIST fmt/8.0.1 zlib/1.2.11 boost/1.75.0 gsl-lite/0.37.0 yaml-cpp/0.7.0)
set(CONAN_PACKAGE_OPTIONS fmt:header_only=True boost:without_stacktrace=True boost:shared=False boost:header_only=False)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
list(APPEND CONAN_PACKAGE_OPTIONS boost:fPIC=True)
endif()
if(NOT USE_CWR_SYSTEMC AND NOT USE_NCSC_SYSTEMC AND NOT DEFINED ENV{SYSTEMC_HOME})
set(CONAN_PACKAGE_LIST ${CONAN_PACKAGE_LIST} systemc/2.3.3 systemc-cci/1.0.0)
set(CONAN_PACKAGE_OPTIONS ${CONAN_PACKAGE_OPTIONS} systemc-cci:shared=False)
endif()
conan_configure(REQUIRES ${CONAN_PACKAGE_LIST} GENERATORS cmake cmake_find_package OPTIONS ${CONAN_PACKAGE_OPTIONS})
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
conan_install(BUILD_TYPE Release)
else()
conan_install()
endif()
conan_setup(TARGETS)
if(ENABLE_CONAN)
include(ConanInline)
conan_check()
set(CONAN_PACKAGE_LIST fmt/8.0.1 zlib/1.2.11 boost/1.75.0 gsl-lite/0.37.0 yaml-cpp/0.7.0)
set(CONAN_PACKAGE_OPTIONS fmt:header_only=True boost:without_stacktrace=True boost:shared=False boost:header_only=False)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
list(APPEND CONAN_PACKAGE_OPTIONS boost:fPIC=True)
endif()
if(NOT USE_CWR_SYSTEMC AND NOT USE_NCSC_SYSTEMC AND NOT DEFINED ENV{SYSTEMC_HOME})
set(CONAN_PACKAGE_LIST ${CONAN_PACKAGE_LIST} systemc/2.3.3 systemc-cci/1.0.0)
set(CONAN_PACKAGE_OPTIONS ${CONAN_PACKAGE_OPTIONS} systemc-cci:shared=False)
endif()
conan_configure(REQUIRES ${CONAN_PACKAGE_LIST} GENERATORS cmake cmake_find_package OPTIONS ${CONAN_PACKAGE_OPTIONS})
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
conan_install(BUILD_TYPE Release)
else()
conan_install()
endif()
conan_setup(TARGETS)
endif()
set(Boost_NO_BOOST_CMAKE ON) # Don't do a find_package in config mode before searching for a regular boost install.
option(ENABLE_CLANG_TIDY "Add clang-tidy automatically to builds" OFF)
option(BUILD_SCC_LIB_ONLY "Build only the library (no examples" OFF)
Expand Down Expand Up @@ -132,11 +136,13 @@ check_symbol_exists(getenv "stdlib.h" HAVE_GETENV)
# check which version of spdlog to use.
if(TARGET spdlog::spdlog)
set(SPDLOG_TARGET spdlog::spdlog)
elseif(TARGET CONAN_PKG::spdlog)
set(SPDLOG_TARGET CONAN_PKG::spdlog)
else()
add_library(spdlog_local INTERFACE IMPORTED)
set_property(TARGET spdlog_local PROPERTY INTERFACE_COMPILE_DEFINITIONS SPDLOG_HEADER_ONLY)
if(TARGET fmt::fmt)
set_property(TARGET spdlog_local PROPERTY INTERFACE_COMPILE_DEFINITIONS SPDLOG_HEADER_ONLY SPDLOG_FMT_EXTERNAL)
else()
set_property(TARGET spdlog_local PROPERTY INTERFACE_COMPILE_DEFINITIONS SPDLOG_HEADER_ONLY)
endif()
set_property(TARGET spdlog_local PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog-1.8)
set(SPDLOG_TARGET spdlog_local)
message(STATUS "${PROJECT_NAME}: using built-in version of spdlog")
Expand All @@ -145,10 +151,9 @@ endif()
# check which version of fmt to use
if(TARGET fmt::fmt)
set(FMT_TARGET fmt::fmt)
elseif(TARGET CONAN_PKG::fmt)
set(FMT_TARGET CONAN_PKG::fmt)
else()
add_library(fmt_local INTERFACE IMPORTED)
set_property(TARGET fmt_local PROPERTY INTERFACE_COMPILE_DEFINITIONS FMT_SPDLOG_INTERNAL)
set_property(TARGET fmt_local PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog-1.8/spdlog)
set(FMT_TARGET fmt_local)
message(STATUS "${PROJECT_NAME}: using built-in version of fmt")
Expand Down
9 changes: 3 additions & 6 deletions examples/simple_system/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.12)
find_package(Boost COMPONENTS program_options REQUIRED)

add_executable (simple_system
plic.cpp
uart.cpp
Expand All @@ -10,9 +11,5 @@ add_executable (simple_system
sc_main.cpp
)
target_link_libraries (simple_system LINK_PUBLIC scc)
if(TARGET Boost::program_options)
target_link_libraries(simple_system PUBLIC Boost::program_options)
else()
target_link_libraries(simple_system PUBLIC ${BOOST_program_options_LIBRARY})
endif()
add_test(NAME simple_system_test COMMAND simple_system)
target_link_libraries(simple_system PUBLIC Boost::program_options)
add_test(NAME simple_system_test COMMAND simple_system)
10 changes: 4 additions & 6 deletions src/sysc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ if(ENABLE_SQLITE)
target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_SQLITE)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/sqlite3)
endif()
if(TARGET Boost::date_time)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::date_time Boost::filesystem)
else()
target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_datetime_LIBRARY} ${Boost_filesystem_LIBRARY})
endif()

target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_datetime_LIBRARIES} ${Boost_datetime_LIBRARIES})

find_package(yaml-cpp QUIET)
if(TARGET CONAN_PKG::yaml-cpp)
target_compile_definitions(${PROJECT_NAME} PUBLIC -DHAS_YAMPCPP)
Expand Down
6 changes: 5 additions & 1 deletion src/sysc/scc/configurer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
#include "rapidjson/document.h"
#include "rapidjson/error/en.h"
#include "report.h"
#ifdef FMT_SPDLOG_INTERNAL
#include <fmt/fmt.h>
#else
#include <fmt/format.h>
#endif
#include <rapidjson/istreamwrapper.h>
#include <rapidjson/ostreamwrapper.h>
#include <rapidjson/prettywriter.h>
Expand Down Expand Up @@ -543,7 +547,7 @@ struct configurer::ConfigHolder: public yaml_config_reader {
};
#else
struct configurer::ConfigHolder: public json_config_reader {
ConfigHolder(configurer::broker_t& broker) : yaml_config_reader(broker) {}
ConfigHolder(configurer::broker_t& broker) : json_config_reader(broker) {}
};
#endif

Expand Down
4 changes: 4 additions & 0 deletions src/sysc/scc/hierarchy_dumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
#include <rapidjson/istreamwrapper.h>
#include <rapidjson/ostreamwrapper.h>
#include <rapidjson/prettywriter.h>
#ifdef FMT_SPDLOG_INTERNAL
#include <fmt/fmt.h>
#else
#include <fmt/format.h>
#endif

#include <string>
#include <typeinfo>
Expand Down
4 changes: 4 additions & 0 deletions src/sysc/scc/scv/scv_tr_lz4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
#ifdef FMT_SPDLOG_INTERNAL
#include <fmt/fmt.h>
#else
#include <fmt/format.h>
#endif
#ifdef WITH_LZ4
#include <util/lz4_streambuf.h>
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/sysc/scc/trace/vcd_trace.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
#endif
#include <util/ities.h>
#include <scc/utilities.h>
#ifdef FMT_SPDLOG_INTERNAL
#include <fmt/fmt.h>
#else
#include <fmt/format.h>
#endif
#include <vector>
#include <unordered_map>

Expand Down

0 comments on commit 87eb1a1

Please sign in to comment.