Added git functions and updated cmake functions

This commit is contained in:
Eyck Jentzsch 2017-10-04 15:58:28 +02:00
parent ccc3f5d47d
commit d59dfa93f6
4 changed files with 32 additions and 97 deletions

View File

@ -1,14 +1,18 @@
cmake_minimum_required(VERSION 2.8.12)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/sc-components/cmake)
include(cmake/GitFunctions.cmake)
get_branch_from_git()
### set the directory names of the submodules
set(GIT_SUBMODULES elfio libGIS sc-components)
set(GIT_SUBMODULES elfio libGIS sc-components dbt-core)
set(GIT_SUBMODULE_DIR_sc-components .)
set(GIT_SUBMODULE_DIR_dbt-core .)
### set each submodules's commit or tag that is to be checked out
### (leave empty if you want master)
#set(GIT_SUBMODULE_VERSION_sc-comp 3af6b9836589b082c19d9131c5d0b7afa8ddd7cd)
set(GIT_SUBMODULE_BRANCH_sc-components "develop")
set(GIT_SUBMODULE_BRANCH_sc-components ${GIT_BRANCH})
set(GIT_SUBMODULE_BRANCH_dbt-core ${GIT_BRANCH})
include(GNUInstallDirs)
include(cmake/Submodules.cmake)
@ -25,8 +29,8 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(warnings "/W4 /WX /EHsc")
endif()
FIND_PACKAGE(Threads)
FIND_PACKAGE(Tcmalloc)
find_package(Threads)
find_package(Tcmalloc)
set(PROJECT_3PARTY_DIRS external sr_report sr_signal)
include(sc-components/cmake/clang-format.cmake)

View File

@ -1,91 +0,0 @@
SET(_SYSTEMC_HINTS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\SystemC\\2.2;SystemcHome]/include"
${SYSTEMC_PREFIX}/include
${SYSTEMC_PREFIX}/lib
${SYSTEMC_PREFIX}/lib-linux
${SYSTEMC_PREFIX}/lib-linux64
${SYSTEMC_PREFIX}/lib-macos
$ENV{SYSTEMC_PREFIX}/include
$ENV{SYSTEMC_PREFIX}/lib
$ENV{SYSTEMC_PREFIX}/lib-linux
$ENV{SYSTEMC_PREFIX}/lib-linux64
$ENV{SYSTEMC_PREFIX}/lib-macos
$ENV{SYSTEMC_HOME}/include
$ENV{SYSTEMC_HOME}/lib
$ENV{SYSTEMC_HOME}/lib-linux
$ENV{SYSTEMC_HOME}/lib-linux64
$ENV{SYSTEMC_HOME}/lib-macos
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib-linux
${CMAKE_INSTALL_PREFIX}/lib-linux64
${CMAKE_INSTALL_PREFIX}/lib-macos
)
SET(_SYSTEMC_PATHS
/usr/include/systemc
/usr/lib
/usr/lib-linux
/usr/lib-linux64
/usr/lib-macos
/usr/local/include/sysc
/usr/local/lib
/usr/local/lib-linux
/usr/local/lib-linux64
/usr/local/lib-macos
)
FIND_FILE(_SYSTEMC_HEADER_FILE
NAMES systemc
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS}
PATH_SUFFIXES sysc/kernel
)
FIND_FILE(_SCV_HEADER_FILE
NAMES scv.h
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS}
PATH_SUFFIXES sysc/kernel
)
if(NOT _SYSTEMC_HEADER_FILE STREQUAL _SYSTEMC_HEADER_FILE-NOTFOUND)
set(SystemC_FOUND TRUE)
endif(NOT _SYSTEMC_HEADER_FILE STREQUAL _SYSTEMC_HEADER_FILE-NOTFOUND)
if(NOT _SCV_HEADER_FILE STREQUAL _SCV_HEADER_FILE-NOTFOUND)
set(SCV_FOUND TRUE)
endif(NOT _SCV_HEADER_FILE STREQUAL _SCV_HEADER_FILE-NOTFOUND)
FIND_PATH(SystemC_INCLUDE_DIRS
NAMES systemc.h
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS}
)
FIND_PATH(SystemC_LIBRARY_DIR
NAMES libsystemc.a
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS}
)
FIND_PATH(SCV_INCLUDE_DIRS
NAMES scv.h
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS}
)
FIND_PATH(SCV_LIBRARY_DIRS
NAMES libscv.a
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS}
)
if(SystemC_FOUND)
set(SystemC_LIBRARIES systemc)
message(STATUS "SystemC header files are taken from ${SystemC_INCLUDE_DIRS}")
message(STATUS "SystemC library is taken from ${SystemC_LIBRARY_DIR}")
if(SCV_FOUND)
set(SCV_LIBRARIES scv)
message(STATUS "SCV header files are taken from ${SCV_INCLUDE_DIRS}")
message(STATUS "SCV library is taken from ${SCV_LIBRARY_DIRS}")
endif(SCV_FOUND)
endif(SystemC_FOUND)

22
cmake/GitFunctions.cmake Normal file
View File

@ -0,0 +1,22 @@
if(__git_functions)
return()
endif()
set(__git_functions YES)
function( get_branch_from_git )
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_branch
ERROR_VARIABLE git_error
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
if( NOT git_result EQUAL 0 )
message( FATAL_ERROR "Failed to execute Git: ${git_error}" )
endif()
set( GIT_BRANCH ${git_branch} PARENT_SCOPE )
endfunction( get_branch_from_git )

@ -1 +1 @@
Subproject commit aefc5681f12cdbbaa5f48d4a043697002b996eec
Subproject commit 3eee1aa0e36f4adb52a712cfa791971adf1bf4ec