BURTON Mark
Builds for 1 pipeline passed in 3 minutes 4 seconds

Merge branch 'fix-systemc-detection' into 'master'

cmake: fixed SystemC detection



See merge request !10
... ... @@ -9,12 +9,12 @@
# SystemC_VERSION = The full version string of the package found
#
# For these components the following variables are set:
#
#
# SystemC_INCLUDE_DIRS - Full paths to all include dirs
# SystemC_LIBRARY_DIRS - Link directories for SystemC libraries
# SystemC::SystemC - Full path to SystemC library
# SystemC::SystemC_STATIC - Full path to SystemC static library
#
#
# Example Usages:
# find_package(SystemC)
... ... @@ -69,7 +69,7 @@ set(_SYSTEMC_PATHS
/usr/include
/usr/systemc
/usr/systemc/include)
find_file(_SYSTEMC_VERSION_FILE
NAMES sc_ver.h
HINTS ${_SYSTEMC_HINTS}
... ... @@ -78,43 +78,43 @@ find_file(_SYSTEMC_VERSION_FILE
if(EXISTS ${_SYSTEMC_VERSION_FILE})
file (READ ${_SYSTEMC_VERSION_FILE} _SYSTEMC_VERSION_FILE_CONTENTS)
string (REGEX MATCH
"SC_API_VERSION_STRING[ \t]+sc_api_version_([0-9]+)_([0-9]+)_([0-9]+)"
string (REGEX MATCH
"SC_API_VERSION_STRING[ \t]+sc_api_version_([0-9]+)_([0-9]+)_([0-9]+)"
SC_API_VERSION_STRING ${_SYSTEMC_VERSION_FILE_CONTENTS})
if(NOT "${SC_API_VERSION_STRING}" MATCHES "")
# SystemC < 2.3.1
string (REGEX MATCHALL "([0-9]+)" _SystemC_VERSION
if(NOT "${SC_API_VERSION_STRING}" STREQUAL "")
# SystemC < 2.3.1
string (REGEX MATCHALL "([0-9]+)" _SystemC_VERSION
${SC_API_VERSION_STRING})
list(GET _SystemC_VERSION 0 SystemC_VERSION_MAJOR)
list(GET _SystemC_VERSION 1 SystemC_VERSION_MINOR)
list(GET _SystemC_VERSION 2 SystemC_VERSION_PATCH)
list(GET _SystemC_VERSION 0 SystemC_VERSION_MAJOR)
list(GET _SystemC_VERSION 1 SystemC_VERSION_MINOR)
list(GET _SystemC_VERSION 2 SystemC_VERSION_PATCH)
else()
# SystemC >= 2.3.1
string (REGEX MATCH "SC_VERSION_MAJOR[ \t]+([0-9]+)"
# SystemC >= 2.3.1
string (REGEX MATCH "SC_VERSION_MAJOR[ \t]+([0-9]+)"
SystemC_VERSION_MAJOR ${_SYSTEMC_VERSION_FILE_CONTENTS})
string (REGEX MATCH "([0-9]+)" SystemC_VERSION_MAJOR
string (REGEX MATCH "([0-9]+)" SystemC_VERSION_MAJOR
${SystemC_VERSION_MAJOR})
string (REGEX MATCH "SC_VERSION_MINOR[ \t]+([0-9]+)"
string (REGEX MATCH "SC_VERSION_MINOR[ \t]+([0-9]+)"
SystemC_VERSION_MINOR ${_SYSTEMC_VERSION_FILE_CONTENTS})
string (REGEX MATCH "([0-9]+)" SystemC_VERSION_MINOR
string (REGEX MATCH "([0-9]+)" SystemC_VERSION_MINOR
${SystemC_VERSION_MINOR})
string (REGEX MATCH "SC_VERSION_PATCH[ \t]+([0-9]+)"
string (REGEX MATCH "SC_VERSION_PATCH[ \t]+([0-9]+)"
SystemC_VERSION_PATCH ${_SYSTEMC_VERSION_FILE_CONTENTS})
string (REGEX MATCH "([0-9]+)" SystemC_VERSION_PATCH
string (REGEX MATCH "([0-9]+)" SystemC_VERSION_PATCH
${SystemC_VERSION_PATCH})
endif()
set(SystemC_VERSION "${SystemC_VERSION_MAJOR}.${SystemC_VERSION_MINOR}.${SystemC_VERSION_PATCH}")
# Compatibility variable
set(SystemC_VERSION_STRING ${SystemC_VERSION})
find_path(SystemC_INCLUDE_DIRS
NAMES systemc systemc.h
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS})
# Static
set(_SystemC_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(WIN32)
... ... @@ -122,51 +122,58 @@ if(EXISTS ${_SYSTEMC_VERSION_FILE})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()
find_library(SystemC_LIBRARIES_STATIC
NAMES systemc SystemC
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS})
# Restore original CMAKE_FIND_LIBRARY_SUFFIXES
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_SystemC_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
# If SystemC_USE_STATIC_LIBS set to ON, force the use of the static libraries
if(SystemC_USE_STATIC_LIBS)
set(SystemC_LIBRARIES SystemC_LIBRARIES_STATIC)
set(SystemC_LIBRARIES ${SystemC_LIBRARIES_STATIC})
else()
find_library(SystemC_LIBRARIES
NAMES systemc SystemC
HINTS ${_SYSTEMC_HINTS}
PATHS ${_SYSTEMC_PATHS})
endif()
# Default
if(NOT TARGET SystemC::SystemC)
add_library(SystemC::SystemC UNKNOWN IMPORTED)
set_target_properties(SystemC::SystemC PROPERTIES
IMPORTED_LOCATION "${SystemC_LIBRARIES}")
endif()
endif()
# Static
if(NOT TARGET SystemC::SystemC_STATIC)
add_library(SystemC::SystemC_STATIC STATIC IMPORTED)
set_target_properties(SystemC::SystemC_STATIC PROPERTIES
IMPORTED_LOCATION "${SystemC_LIBRARIES_STATIC}")
endif()
IMPORTED_LOCATION "${SystemC_LIBRARIES_STATIC}")
endif()
if("${CMAKE_VERSION}" VERSION_GREATER 2.8.12)
get_filename_component(SystemC_LIBRARY_DIRS ${SystemC_LIBRARIES}
get_filename_component(SystemC_LIBRARY_DIRS ${SystemC_LIBRARIES}
DIRECTORY)
else("${CMAKE_VERSION}" VERSION_GREATER 2.8.12)
get_filename_component(SystemC_LIBRARY_DIRS ${SystemC_LIBRARIES}
else("${CMAKE_VERSION}" VERSION_GREATER 2.8.12)
get_filename_component(SystemC_LIBRARY_DIRS ${SystemC_LIBRARIES}
PATH)
endif()
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SystemC
FOUND_VAR SystemC_FOUND
REQUIRED_VARS SystemC_LIBRARIES SystemC_LIBRARY_DIRS SystemC_INCLUDE_DIRS
VERSION_VAR SystemC_VERSION)
mark_as_advanced(SystemC_LIBRARIES SystemC_LIBRARY_DIRS SystemC_INCLUDE_DIRS)
if("${CMAKE_VERSION}" VERSION_GREATER 2.8.10)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SystemC
FOUND_VAR SystemC_FOUND
REQUIRED_VARS SystemC_LIBRARIES SystemC_LIBRARY_DIRS SystemC_INCLUDE_DIRS
VERSION_VAR SystemC_VERSION)
else()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SystemC
REQUIRED_VARS SystemC_LIBRARIES SystemC_LIBRARY_DIRS SystemC_INCLUDE_DIRS
VERSION_VAR SystemC_VERSION)
set(SystemC_FOUND ${SYSTEMC_FOUND})
endif()
mark_as_advanced(SystemC_LIBRARIES SystemC_LIBRARY_DIRS SystemC_INCLUDE_DIRS)
... ...
... ... @@ -46,21 +46,21 @@ find_file(_TLM_VERSION_FILE
if(EXISTS ${_TLM_VERSION_FILE})
file (READ ${_TLM_VERSION_FILE} _TLM_VERSION_FILE_CONTENTS)
string (REGEX MATCH "TLM_VERSION_MAJOR[ \t]+([0-9]+)"
TLM_VERSION_MAJOR ${_TLM_VERSION_FILE_CONTENTS})
string (REGEX MATCH "([0-9]+)" TLM_VERSION_MAJOR
${TLM_VERSION_MAJOR})
string (REGEX MATCH "TLM_VERSION_MINOR[ \t]+([0-9]+)"
string (REGEX MATCH "TLM_VERSION_MAJOR[ \t]+([0-9]+)"
TLM_VERSION_MAJOR ${_TLM_VERSION_FILE_CONTENTS})
string (REGEX MATCH "([0-9]+)" TLM_VERSION_MAJOR
${TLM_VERSION_MAJOR})
string (REGEX MATCH "TLM_VERSION_MINOR[ \t]+([0-9]+)"
TLM_VERSION_MINOR ${_TLM_VERSION_FILE_CONTENTS})
string (REGEX MATCH "([0-9]+)" TLM_VERSION_MINOR
string (REGEX MATCH "([0-9]+)" TLM_VERSION_MINOR
${TLM_VERSION_MINOR})
string (REGEX MATCH "TLM_VERSION_PATCH[ \t]+([0-9]+)"
string (REGEX MATCH "TLM_VERSION_PATCH[ \t]+([0-9]+)"
TLM_VERSION_PATCH ${_TLM_VERSION_FILE_CONTENTS})
string (REGEX MATCH "([0-9]+)" TLM_VERSION_PATCH
string (REGEX MATCH "([0-9]+)" TLM_VERSION_PATCH
${TLM_VERSION_PATCH})
set(TLM_VERSION "${TLM_VERSION_MAJOR}.${TLM_VERSION_MINOR}.${TLM_VERSION_PATCH}")
find_path(TLM_INCLUDE_DIRS
NAMES tlm tlm.h
HINTS ${_TLM_HINTS}
... ... @@ -72,4 +72,4 @@ endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TLM
REQUIRED_VARS TLM_INCLUDE_DIRS
VERSION_VAR TLM_VERSION)
\ No newline at end of file
VERSION_VAR TLM_VERSION)
... ...