2019-06-30 14:14:43 +02:00
|
|
|
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
|
2018-07-31 11:33:35 +02:00
|
|
|
|
2019-04-21 14:36:56 +02:00
|
|
|
# Use ';' to specify multiple e.g. ZIP;TGZ;DEB
|
|
|
|
set(CPACK_GENERATOR "" CACHE STRING "Set packages CPack should build e.g. ZIP;TGZ;DEB")
|
|
|
|
|
2018-07-31 11:33:35 +02:00
|
|
|
# BUILD_SHARED_LIBS can controll build type!
|
|
|
|
project(EventBus
|
2019-09-14 15:59:25 +02:00
|
|
|
VERSION 3.0.0
|
2019-06-29 11:27:38 +02:00
|
|
|
LANGUAGES CXX
|
|
|
|
)
|
2018-07-31 11:33:35 +02:00
|
|
|
|
|
|
|
# Dependencies
|
|
|
|
# No dependencies for EventBus yay!
|
|
|
|
|
|
|
|
# Introduce variables:
|
|
|
|
# * CMAKE_INSTALL_LIBDIR
|
|
|
|
# * CMAKE_INSTALL_BINDIR
|
|
|
|
# * CMAKE_INSTALL_INCLUDEDIR
|
|
|
|
include(GNUInstallDirs)
|
2019-09-14 15:10:08 +02:00
|
|
|
include(cmake/InstallHelp.cmake)
|
|
|
|
|
2018-07-31 11:33:35 +02:00
|
|
|
|
|
|
|
# Layout. This works for all platforms:
|
|
|
|
# * <prefix>/lib*/cmake/<PROJECT-NAME>
|
|
|
|
# * <prefix>/lib*/
|
|
|
|
# * <prefix>/include/
|
|
|
|
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
|
|
|
|
2019-12-27 11:21:43 +01:00
|
|
|
set(EventBus_PUBLIC_HEADERS
|
2019-09-14 16:05:21 +02:00
|
|
|
src/dexode/EventBus.hpp
|
2019-12-27 11:21:43 +01:00
|
|
|
src/dexode/eventbus/Bus.hpp
|
|
|
|
src/dexode/eventbus/internal/event_id.hpp
|
|
|
|
src/dexode/eventbus/internal/listener_traits.hpp
|
2019-10-30 17:28:59 +01:00
|
|
|
src/dexode/eventbus/internal/ListenerAttorney.hpp
|
2019-09-14 16:05:21 +02:00
|
|
|
src/dexode/eventbus/Listener.hpp
|
2019-12-27 11:21:43 +01:00
|
|
|
src/dexode/eventbus/perk/PassPerk.hpp
|
|
|
|
src/dexode/eventbus/perk/Perk.hpp
|
|
|
|
src/dexode/eventbus/perk/PerkEventBus.hpp
|
|
|
|
src/dexode/eventbus/perk/TagPerk.hpp
|
|
|
|
src/dexode/eventbus/perk/WaitPerk.hpp
|
|
|
|
src/dexode/eventbus/permission/PostponeBus.hpp
|
|
|
|
src/dexode/eventbus/stream/EventStream.hpp
|
|
|
|
src/dexode/eventbus/stream/ProtectedEventStream.hpp
|
|
|
|
)
|
|
|
|
|
|
|
|
# Library definition
|
|
|
|
add_library(EventBus
|
|
|
|
${EventBus_PUBLIC_HEADERS}
|
|
|
|
src/dexode/EventBus.cpp
|
|
|
|
src/dexode/eventbus/perk/PassPerk.cpp
|
|
|
|
src/dexode/eventbus/perk/Perk.cpp
|
|
|
|
src/dexode/eventbus/perk/PerkEventBus.cpp
|
|
|
|
src/dexode/eventbus/perk/TagPerk.cpp
|
|
|
|
src/dexode/eventbus/perk/WaitPerk.cpp
|
2018-09-08 19:31:05 +02:00
|
|
|
)
|
2018-07-31 11:33:35 +02:00
|
|
|
add_library(Dexode::EventBus ALIAS EventBus)
|
|
|
|
|
2019-12-29 15:00:20 +01:00
|
|
|
# Why C++ 17 needed:
|
|
|
|
# - std::shared_mutex used
|
|
|
|
# - nested namespaces e.g. my::name::space
|
|
|
|
|
|
|
|
set_target_properties(EventBus PROPERTIES
|
|
|
|
CXX_STANDARD 17
|
|
|
|
CXX_STANDARD_REQUIRED YES
|
|
|
|
CXX_EXTENSIONS NO # -std=c++17 rather than -std=gnu++17
|
|
|
|
)
|
|
|
|
|
2019-09-14 15:51:47 +02:00
|
|
|
target_compile_features(EventBus PUBLIC cxx_std_17)
|
2018-07-31 11:33:35 +02:00
|
|
|
|
|
|
|
target_include_directories(EventBus PUBLIC
|
2019-09-14 16:05:21 +02:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/>
|
2019-06-29 11:27:38 +02:00
|
|
|
$<INSTALL_INTERFACE:include/>
|
|
|
|
)
|
2018-07-31 11:33:35 +02:00
|
|
|
|
|
|
|
# Add definitions for targets
|
|
|
|
# Values:
|
|
|
|
# * Debug: -DEVENTBUS_DEBUG=1
|
|
|
|
# * Release: -DEVENTBUS_DEBUG=0
|
|
|
|
# * other: -DEVENTBUS_DEBUG=0
|
|
|
|
target_compile_definitions(EventBus PUBLIC "EVENTBUS_DEBUG=$<CONFIG:Debug>")
|
|
|
|
|
|
|
|
|
|
|
|
# Configuration
|
|
|
|
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
|
|
|
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
|
|
|
|
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
|
|
|
|
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
|
|
|
|
set(namespace "Dexode::")
|
|
|
|
|
|
|
|
# Targets:
|
|
|
|
# * <prefix>/lib/libEventBus.a
|
|
|
|
# * header location after install: <prefix>/include/eventbus/EventBus.h
|
|
|
|
# * headers can be included by C++ code `#include <eventbus/EventBus.h>`
|
|
|
|
install(TARGETS EventBus
|
2019-06-29 11:27:38 +02:00
|
|
|
EXPORT "${TARGETS_EXPORT_NAME}"
|
|
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
|
|
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
|
|
)
|
2018-07-31 11:33:35 +02:00
|
|
|
|
|
|
|
# Include module with fuction 'write_basic_package_version_file'
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
|
|
|
# Configure '<PROJECT-NAME>ConfigVersion.cmake'
|
|
|
|
# Use:
|
|
|
|
# * PROJECT_VERSION
|
|
|
|
write_basic_package_version_file(
|
2019-06-29 11:27:38 +02:00
|
|
|
"${version_config}" COMPATIBILITY SameMajorVersion
|
2018-07-31 11:33:35 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# Configure '<PROJECT-NAME>Config.cmake'
|
|
|
|
# Use variables:
|
|
|
|
# * TARGETS_EXPORT_NAME
|
|
|
|
# * PROJECT_NAME
|
|
|
|
configure_package_config_file(
|
2019-06-29 11:27:38 +02:00
|
|
|
"cmake/Config.cmake.in"
|
|
|
|
"${project_config}"
|
|
|
|
INSTALL_DESTINATION "${config_install_dir}"
|
2018-07-31 11:33:35 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# Config
|
|
|
|
# * <prefix>/lib/cmake/EventBusventBusConfig.cmake
|
|
|
|
# * <prefix>/lib/cmake/EventBus/EventBusConfigVersion.cmake
|
|
|
|
install(
|
2019-06-29 11:27:38 +02:00
|
|
|
FILES "${project_config}" "${version_config}"
|
|
|
|
DESTINATION "${config_install_dir}"
|
2019-12-29 13:13:34 +01:00
|
|
|
# We don't want someone by accident modify his installed files
|
|
|
|
PERMISSIONS OWNER_EXECUTE OWNER_READ
|
2018-07-31 11:33:35 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# Config
|
|
|
|
# * <prefix>/lib/cmake/EventBus/EventBusTargets.cmake
|
|
|
|
install(EXPORT "${TARGETS_EXPORT_NAME}"
|
2019-06-29 11:27:38 +02:00
|
|
|
DESTINATION "${config_install_dir}"
|
|
|
|
NAMESPACE "${namespace}"
|
2019-12-29 13:13:34 +01:00
|
|
|
# We don't want someone by accident modify his installed files
|
|
|
|
PERMISSIONS OWNER_EXECUTE OWNER_READ
|
2019-06-29 11:27:38 +02:00
|
|
|
)
|
2019-04-12 13:13:56 +02:00
|
|
|
|
2019-09-14 23:23:10 +02:00
|
|
|
# Export headers (Install public headers)
|
|
|
|
install_public_headers_with_directory(EventBus_PUBLIC_HEADERS "src/")
|
2019-09-14 15:10:08 +02:00
|
|
|
|
2019-04-12 13:13:56 +02:00
|
|
|
# Cpack configuration
|
2019-04-21 14:36:56 +02:00
|
|
|
if(NOT CPACK_GENERATOR STREQUAL "")
|
2019-09-14 15:10:08 +02:00
|
|
|
include(cmake/EventBus_CPack.cmake)
|
2019-04-21 14:36:56 +02:00
|
|
|
enable_cpack(${CPACK_GENERATOR})
|
2019-04-12 13:13:56 +02:00
|
|
|
endif()
|