PySysC-SC/CMakeLists.txt

122 lines
4.1 KiB
CMake
Raw Normal View History

2024-11-22 16:03:28 +01:00
cmake_minimum_required(VERSION 3.12)
2021-03-14 09:29:38 +01:00
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/scc/cmake)
2018-11-30 11:08:08 +01:00
2021-03-13 14:57:31 +01:00
project(pysysc-sc)
2023-03-16 16:14:41 +01:00
option(INSTALL_DEPENDENCIES "Should dependencies be installed when installing SCC" OFF)
2019-01-01 12:19:44 +01:00
include(GNUInstallDirs)
include(BuildType)
2021-03-14 09:29:38 +01:00
include(clang-format)
2018-11-30 11:08:08 +01:00
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
2019-01-01 12:19:44 +01:00
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 17)
2019-01-01 12:19:44 +01:00
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
elseif(NOT(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(warnings "-Wall -Wextra -Werror")
set(CMAKE_CXX_FLAG_RELEASE "-O3 -DNDEBUG")
set(CMAKE_C_FLAG_RELEASE "-O3 -DNDEBUG")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(warnings "/W4 /WX /EHsc")
endif()
2023-03-16 16:14:41 +01:00
include(GNUInstallDirs)
include(ConanInline)
conan_check()
2023-03-16 16:14:41 +01:00
if(EXISTS /etc/redhat-release)
# Boost on CentOS quirks: the b2 of conan-center is build against a newer libstdc++ and therefore does not run
# with the oooooold libs on CentOS 7. Therefore we build our own version of b2 if it is not there
set(B2_VERSION 4.9.2)
set(B2_META $ENV{HOME}/.conan/data/b2/${B2_VERSION}/_/_/metadata.json)
if(DEFINED ENV{CONAN_USER_HOME})
set(B2_META $ENV{CONAN_USER_HOME}/.conan/data/b2/${B2_VERSION}/_/_/metadata.json)
endif()
if(NOT EXISTS ${B2_META})
conan_configure(REQUIRES b2/${B2_VERSION})
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE . BUILD b2 SETTINGS ${settings})
endif()
# Boost on CentOS quirks end
endif()
2023-03-21 11:24:53 +01:00
set(BOOST_OPTIONS
boost:fPIC=True
boost:shared=True
boost:header_only=False
boost:without_context=True
boost:without_contract=True
boost:without_coroutine=True
boost:without_fiber=True
boost:without_graph=True
boost:without_graph_parallel=True
boost:without_iostreams=True
boost:without_json=True
boost:without_locale=True
boost:without_log=True
boost:without_math=True
boost:without_mpi=True
boost:without_nowide=True
boost:without_python=True
boost:without_random=True
boost:without_regex=True
boost:without_serialization=True
boost:without_stacktrace=True
boost:without_test=True
boost:without_timer=True
boost:without_type_erasure=True
boost:without_wave=True
)
2023-03-21 11:24:53 +01:00
set(CONAN_PACKAGE_LIST fmt/8.0.1 spdlog/1.9.2 zlib/1.2.11 boost/1.75.0 yaml-cpp/0.7.0 jsoncpp/1.9.5 lz4/1.9.3)
2023-03-16 16:14:41 +01:00
if(BUILD_SCC_DOCUMENTATION)
list(APPEND CONAN_PACKAGE_LIST doxygen/1.9.2)
endif()
2023-03-21 11:24:53 +01:00
set(CONAN_PACKAGE_OPTIONS fmt:header_only=True spdlog:header_only=True ${BOOST_OPTIONS})
2023-03-16 16:14:41 +01:00
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.4)
set(CONAN_PACKAGE_OPTIONS ${CONAN_PACKAGE_OPTIONS} systemc:shared=True)
2023-03-16 16:14:41 +01:00
endif()
conan_configure(REQUIRES ${CONAN_PACKAGE_LIST} GENERATORS cmake_find_package OPTIONS ${CONAN_PACKAGE_OPTIONS})
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
conan_install(BUILD_TYPE Release)
else()
conan_install()
endif()
2023-03-16 16:14:41 +01:00
set(CONAN_CMAKE_SILENT_OUTPUT ON)
set(Boost_NO_BOOST_CMAKE ON) # Don't do a find_package in config mode before searching for a regular boost install.
2019-01-01 12:19:44 +01:00
# This line finds the boost lib and headers.
2021-03-13 14:57:31 +01:00
set(Boost_NO_BOOST_CMAKE ON) # Don't do a find_package in config mode before searching for a regular boost install.
find_package(Boost COMPONENTS program_options system thread REQUIRED)
2023-03-16 16:14:41 +01:00
find_package(spdlog REQUIRED)
find_package(lz4 REQUIRED)
find_package(fmt REQUIRED)
find_package(yaml-cpp REQUIRED)
include(SystemCPackage)
2019-01-01 12:19:44 +01:00
2021-03-14 09:29:38 +01:00
add_subdirectory(scc)
2021-05-18 16:33:29 +02:00
add_subdirectory(vp_components)
#add_subdirectory(top)
2018-11-30 11:08:08 +01:00
# CTest is a testing tool that can be used to test your project.
# enable_testing()
# add_test(NAME example
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
# COMMAND example)