cmake_minimum_required(VERSION 3.12) project("tgfs" VERSION 1.0.0) include(GNUInstallDirs) conan_basic_setup() find_package(Boost COMPONENTS program_options system thread filesystem REQUIRED) if(WITH_LLVM) if(DEFINED ENV{LLVM_HOME}) find_path (LLVM_DIR LLVM-Config.cmake $ENV{LLVM_HOME}/lib/cmake/llvm) endif(DEFINED ENV{LLVM_HOME}) find_package(LLVM REQUIRED CONFIG) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") llvm_map_components_to_libnames(llvm_libs support core mcjit x86codegen x86asmparser) endif() #Mac needed variables (adapt for your needs - http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH) #set(CMAKE_MACOSX_RPATH ON) #set(CMAKE_SKIP_BUILD_RPATH FALSE) #set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) #set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") #set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) add_subdirectory(softfloat) # library files FILE(GLOB RiscVSCHeaders ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/*.h ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/*/*.h) set(LIB_HEADERS tgfscVSCHeaders} ) set(LIB_SOURCES src/iss/tgf_b.cpp src/iss/tgf_c.cpp src/vm/fp_functions.cpp src/vm/tcc/vm_tgf_b.cpp src/vm/tcc/vm_tgf_c.cpp src/vm/interp/vm_tgf_b.cpp src/vm/interp/vm_tgf_c.cpp src/plugin/instruction_count.cpp src/plugin/cycle_estimate.cpp ) if(WITH_LLVM) set(LIB_SOURCES ${LIB_SOURCES} src/vm/llvm/fp_impl.cpp src/vm/llvm/vm_tgf_b.cpp src/vm/llvm/vm_tgf_c.cpp ) endif() # Define the library add_library(tgfs SHARED ${LIB_SOURCES}) # list code gen dependencies add_dependencies(tgfs TGF_C_src) target_compile_options(tgfs PRIVATE -Wno-shift-count-overflow) target_include_directories(tgfs PUBLIC incl) target_link_libraries(tgfs PUBLIC softfloat scc-util) target_link_libraries(tgfs PUBLIC -Wl,--whole-archive dbt-core -Wl,--no-whole-archive) set_target_properties(tgfs PROPERTIES VERSION ${PROJECT_VERSION} FRAMEWORK FALSE PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers ) if(SystemC_FOUND) add_library(tgfs_sc src/sysc/core_complex.cpp) target_compile_definitions(tgfs_sc PUBLIC WITH_SYSTEMC) target_include_directories(tgfs_sc PUBLIC ../incl ${SystemC_INCLUDE_DIRS} ${CCI_INCLUDE_DIRS}) if(SCV_FOUND) target_compile_definitions(tgfs_sc PUBLIC WITH_SCV) target_include_directories(tgfs_sc PUBLIC ${SCV_INCLUDE_DIRS}) endif() target_link_libraries(tgfs_sc PUBLIC tgfs scc ) if(WITH_LLVM) target_link_libraries(tgfs_sc PUBLIC ${llvm_libs}) endif() target_link_libraries(tgfs_sc PUBLIC ${Boost_LIBRARIES} ) set_target_properties(tgfs_sc PROPERTIES VERSION ${PROJECT_VERSION} FRAMEWORK FALSE PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers ) endif() project("tgfs-sim") add_executable(tgfs-sim src/main.cpp) # This sets the include directory for the reference project. This is the -I flag in gcc. if(WITH_LLVM) target_compile_definitions(tgfs-sim PRIVATE WITH_LLVM) target_link_libraries(tgfs-sim PUBLIC ${llvm_libs}) endif() # Links the target exe against the libraries target_link_libraries(tgfs-sim tgfs) target_link_libraries(tgfs-sim jsoncpp) target_link_libraries(tgfs-sim ${Boost_LIBRARIES} ) if (Tcmalloc_FOUND) target_link_libraries(tgfs-sim ${Tcmalloc_LIBRARIES}) endif(Tcmalloc_FOUND) install(TARGETS tgfs tgfs-sim EXPORT ${PROJECT_NAME}Targets # for downstream dependencies ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # for mac PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} COMPONENT devel # headers for mac (note the different component -> different package) INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers ) # # SYSTEM PACKAGING (RPM, TGZ, ...) # _____________________________________________________________________________ #include(CPackConfig) # # CMAKE PACKAGING (for other CMake projects to use this one easily) # _____________________________________________________________________________ #include(PackageConfigurator)