2019-06-12 01:53:17 +00:00
|
|
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|
|
|
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17
|
|
|
|
project(nod VERSION 0.1)
|
2020-04-11 04:55:45 +00:00
|
|
|
if (NOT MSVC)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
2019-06-12 01:53:17 +00:00
|
|
|
endif()
|
|
|
|
|
2019-05-23 04:07:58 +00:00
|
|
|
include (CMakePackageConfigHelpers)
|
|
|
|
|
2019-07-20 04:21:39 +00:00
|
|
|
add_subdirectory(fmt)
|
|
|
|
|
2016-03-04 20:11:37 +00:00
|
|
|
add_library(logvisor
|
|
|
|
lib/logvisor.cpp
|
|
|
|
include/logvisor/logvisor.hpp)
|
2015-11-14 07:27:36 +00:00
|
|
|
|
2020-12-16 12:31:39 +00:00
|
|
|
if(APPLE OR UNIX)
|
|
|
|
include(ExternalProject)
|
|
|
|
find_package(Git REQUIRED)
|
|
|
|
find_program(MAKE_EXE NAMES gmake make)
|
|
|
|
ExternalProject_Add(
|
|
|
|
project_libbacktrace
|
|
|
|
PREFIX ${PROJECT_BINARY_DIR}/libbacktrace
|
|
|
|
GIT_REPOSITORY https://github.com/status-im/libbacktrace.git
|
|
|
|
GIT_TAG 2e878a38dd7144c84b665019b1085ea38ebe56d1
|
|
|
|
CONFIGURE_COMMAND ${PROJECT_BINARY_DIR}/libbacktrace/src/project_libbacktrace/configure --enable-host-shared --prefix=${PROJECT_BINARY_DIR}/libbacktrace/install --enable-shared=no --enable-static=yes
|
|
|
|
BUILD_COMMAND ${MAKE_EXE}
|
|
|
|
INSTALL_COMMAND ${MAKE_EXE} install
|
|
|
|
BUILD_IN_SOURCE 1
|
|
|
|
)
|
|
|
|
add_library(libbacktrace STATIC IMPORTED GLOBAL)
|
|
|
|
set_target_properties(libbacktrace PROPERTIES IMPORTED_LOCATION "${PROJECT_BINARY_DIR}/libbacktrace/install/lib/libbacktrace.a")
|
|
|
|
set_target_properties(libbacktrace PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PROJECT_BINARY_DIR}/libbacktrace/install/include")
|
|
|
|
# Hack for INTERFACE_INCLUDE_DIRECTORIES propagation
|
|
|
|
# https://gitlab.kitware.com/cmake/cmake/-/issues/15052
|
|
|
|
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/libbacktrace/install/include")
|
|
|
|
add_dependencies(libbacktrace project_libbacktrace)
|
|
|
|
set(BACKTRACE_LIBS libbacktrace)
|
|
|
|
else()
|
|
|
|
set(BACKTRACE_LIBS "")
|
|
|
|
endif()
|
|
|
|
|
2020-10-21 04:35:07 +00:00
|
|
|
target_link_libraries(logvisor PUBLIC fmt)
|
|
|
|
if(NX)
|
2020-12-16 12:31:39 +00:00
|
|
|
target_link_libraries(logvisor PUBLIC debug nxd optimized nx)
|
2020-10-21 04:35:07 +00:00
|
|
|
else()
|
2020-12-16 12:31:39 +00:00
|
|
|
target_link_libraries(logvisor PRIVATE ${CMAKE_DL_LIBS} ${BACKTRACE_LIBS})
|
2020-05-04 06:09:21 +00:00
|
|
|
endif()
|
2019-06-12 01:53:17 +00:00
|
|
|
target_include_directories(logvisor PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
2015-11-14 07:27:36 +00:00
|
|
|
|
2020-10-21 04:35:07 +00:00
|
|
|
install(DIRECTORY include/logvisor DESTINATION include)
|
2019-07-20 04:21:39 +00:00
|
|
|
install(DIRECTORY fmt/include/fmt DESTINATION include)
|
2019-05-23 04:07:58 +00:00
|
|
|
|
|
|
|
set(version_config_file "${PROJECT_BINARY_DIR}/logvisorConfigVersion.cmake")
|
|
|
|
set(config_file "${PROJECT_BINARY_DIR}/logvisorConfig.cmake")
|
|
|
|
set(config_install_dir "lib/cmake/logvisor")
|
|
|
|
|
|
|
|
# Associate target with export
|
|
|
|
install(
|
2019-07-20 04:21:39 +00:00
|
|
|
TARGETS logvisor fmt
|
2019-05-23 04:07:58 +00:00
|
|
|
EXPORT logvisorTargets
|
|
|
|
ARCHIVE DESTINATION "lib"
|
|
|
|
INCLUDES DESTINATION include # This sets the INTERFACE_INCLUDE_DIRECTORIES property of the target.
|
|
|
|
)
|
|
|
|
|
|
|
|
# Install the target config files
|
|
|
|
install(
|
|
|
|
EXPORT logvisorTargets
|
|
|
|
NAMESPACE "logvisor::"
|
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Generate version config file
|
|
|
|
write_basic_package_version_file(
|
|
|
|
"${version_config_file}"
|
|
|
|
COMPATIBILITY SameMajorVersion
|
|
|
|
)
|
|
|
|
|
|
|
|
# Generate config file
|
|
|
|
configure_package_config_file(
|
|
|
|
"Config.cmake.in"
|
|
|
|
"${config_file}"
|
|
|
|
INSTALL_DESTINATION "lib/cmake/logvisor"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Install the config files
|
|
|
|
install(
|
|
|
|
FILES "${config_file}" "${version_config_file}"
|
|
|
|
DESTINATION ${config_install_dir}
|
|
|
|
)
|