feat add event_bus #1
@ -7,21 +7,21 @@
|
|||||||
# copies of the Software, and to permit persons to whom the Software is
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
# furnished to do so, subject to the following conditions:
|
# furnished to do so, subject to the following conditions:
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
# all copies or substantial portions of the Software.
|
# copies or substantial portions of the Software.
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# THE SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.1)
|
||||||
project(Async++ C CXX)
|
project(Async++ C CXX)
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build Async++ as a shared library" ON)
|
option(BUILD_SHARED_LIBS "Build Async++ as a shared library" OFF)
|
||||||
option(USE_CXX_EXCEPTIONS "Enable C++ exception support" ON)
|
option(USE_CXX_EXCEPTIONS "Enable C++ exception support" ON)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
option(BUILD_FRAMEWORK "Build a Mac OS X framework instead of a library" OFF)
|
option(BUILD_FRAMEWORK "Build a Mac OS X framework instead of a library" OFF)
|
||||||
@ -48,8 +48,7 @@ set(ASYNCXX_INCLUDE
|
|||||||
${PROJECT_SOURCE_DIR}/include/async++/task.h
|
${PROJECT_SOURCE_DIR}/include/async++/task.h
|
||||||
${PROJECT_SOURCE_DIR}/include/async++/task_base.h
|
${PROJECT_SOURCE_DIR}/include/async++/task_base.h
|
||||||
${PROJECT_SOURCE_DIR}/include/async++/traits.h
|
${PROJECT_SOURCE_DIR}/include/async++/traits.h
|
||||||
${PROJECT_SOURCE_DIR}/include/async++/when_all_any.h
|
${PROJECT_SOURCE_DIR}/include/async++/when_all_any.h)
|
||||||
)
|
|
||||||
set(ASYNCXX_SRC
|
set(ASYNCXX_SRC
|
||||||
${PROJECT_SOURCE_DIR}/src/internal.h
|
${PROJECT_SOURCE_DIR}/src/internal.h
|
||||||
${PROJECT_SOURCE_DIR}/src/fifo_queue.h
|
${PROJECT_SOURCE_DIR}/src/fifo_queue.h
|
||||||
@ -57,11 +56,12 @@ set(ASYNCXX_SRC
|
|||||||
${PROJECT_SOURCE_DIR}/src/singleton.h
|
${PROJECT_SOURCE_DIR}/src/singleton.h
|
||||||
${PROJECT_SOURCE_DIR}/src/task_wait_event.h
|
${PROJECT_SOURCE_DIR}/src/task_wait_event.h
|
||||||
${PROJECT_SOURCE_DIR}/src/threadpool_scheduler.cpp
|
${PROJECT_SOURCE_DIR}/src/threadpool_scheduler.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/work_steal_queue.h
|
${PROJECT_SOURCE_DIR}/src/work_steal_queue.h)
|
||||||
)
|
source_group(include FILES ${PROJECT_SOURCE_DIR}/include/async++.h
|
||||||
source_group(include FILES ${PROJECT_SOURCE_DIR}/include/async++.h ${ASYNCXX_INCLUDE})
|
${ASYNCXX_INCLUDE})
|
||||||
source_group(src FILES ${ASYNCXX_SRC})
|
source_group(src FILES ${ASYNCXX_SRC})
|
||||||
add_library(Async++ ${PROJECT_SOURCE_DIR}/include/async++.h ${ASYNCXX_INCLUDE} ${ASYNCXX_SRC})
|
add_library(Async++ ${PROJECT_SOURCE_DIR}/include/async++.h ${ASYNCXX_INCLUDE}
|
||||||
|
${ASYNCXX_SRC})
|
||||||
|
|
||||||
# Async++ only depends on the C++11 standard libraries, but some implementations
|
# Async++ only depends on the C++11 standard libraries, but some implementations
|
||||||
# require the -pthread compiler flag to enable threading functionality.
|
# require the -pthread compiler flag to enable threading functionality.
|
||||||
@ -82,7 +82,8 @@ target_include_directories(Async++ PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
|||||||
set_target_properties(Async++ PROPERTIES DEFINE_SYMBOL LIBASYNC_BUILD)
|
set_target_properties(Async++ PROPERTIES DEFINE_SYMBOL LIBASYNC_BUILD)
|
||||||
if(BUILD_SHARED_LIBS)
|
if(BUILD_SHARED_LIBS)
|
||||||
# Minimize the set of symbols exported by libraries
|
# Minimize the set of symbols exported by libraries
|
||||||
set_target_properties(Async++ PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON)
|
set_target_properties(Async++ PROPERTIES CXX_VISIBILITY_PRESET hidden
|
||||||
|
VISIBILITY_INLINES_HIDDEN ON)
|
||||||
else()
|
else()
|
||||||
target_compile_definitions(Async++ PUBLIC LIBASYNC_STATIC)
|
target_compile_definitions(Async++ PUBLIC LIBASYNC_STATIC)
|
||||||
endif()
|
endif()
|
||||||
@ -92,10 +93,10 @@ if (NOT MSVC)
|
|||||||
target_compile_options(Async++ PRIVATE -Wall -Wextra -pedantic)
|
target_compile_options(Async++ PRIVATE -Wall -Wextra -pedantic)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Async++ doesn't make use of RTTI information, so don't generate it.
|
# Async++ doesn't make use of RTTI information, so don't generate it. There are
|
||||||
# There are issues on Apple platforms with exceptions and -fno-rtti, so keep it
|
# issues on Apple platforms with exceptions and -fno-rtti, so keep it enabled
|
||||||
# enabled there.
|
# there. See
|
||||||
# See https://stackoverflow.com/questions/21737201/problems-throwing-and-catching-exceptions-on-os-x-with-fno-rtti
|
# https://stackoverflow.com/questions/21737201/problems-throwing-and-catching-exceptions-on-os-x-with-fno-rtti
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_options(Async++ PRIVATE /GR-)
|
target_compile_options(Async++ PRIVATE /GR-)
|
||||||
elseif(NOT APPLE)
|
elseif(NOT APPLE)
|
||||||
@ -104,7 +105,8 @@ endif()
|
|||||||
|
|
||||||
# Allow disabling exceptions, but warn the user about the consequences
|
# Allow disabling exceptions, but warn the user about the consequences
|
||||||
if(NOT USE_CXX_EXCEPTIONS)
|
if(NOT USE_CXX_EXCEPTIONS)
|
||||||
message(WARNING "Exceptions have been disabled. Any operation that would "
|
message(
|
||||||
|
WARNING "Exceptions have been disabled. Any operation that would "
|
||||||
"throw an exception will result in a call to std::abort() instead.")
|
"throw an exception will result in a call to std::abort() instead.")
|
||||||
target_compile_definitions(Async++ PUBLIC LIBASYNC_NO_EXCEPTIONS)
|
target_compile_definitions(Async++ PUBLIC LIBASYNC_NO_EXCEPTIONS)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
@ -114,52 +116,54 @@ if (NOT USE_CXX_EXCEPTIONS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# /Zc:__cplusplus is required to make __cplusplus accurate
|
# /Zc:__cplusplus is required to make __cplusplus accurate /Zc:__cplusplus is
|
||||||
# /Zc:__cplusplus is available starting with Visual Studio 2017 version 15.7
|
# available starting with Visual Studio 2017 version 15.7 (according to
|
||||||
# (according to https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus)
|
# https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus) That
|
||||||
# That version is equivalent to _MSC_VER==1914
|
# version is equivalent to _MSC_VER==1914 (according to
|
||||||
# (according to https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019)
|
# https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019)
|
||||||
# CMake's ${MSVC_VERSION} is equivalent to _MSC_VER
|
# CMake's ${MSVC_VERSION} is equivalent to _MSC_VER (according to
|
||||||
# (according to https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html#variable:MSVC_VERSION)
|
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html#variable:MSVC_VERSION)
|
||||||
# GREATER and EQUAL are used because GREATER_EQUAL is available starting with CMake 3.7
|
# GREATER and EQUAL are used because GREATER_EQUAL is available starting with
|
||||||
# (according to https://cmake.org/cmake/help/v3.7/release/3.7.html#commands)
|
# CMake 3.7 (according to
|
||||||
|
# https://cmake.org/cmake/help/v3.7/release/3.7.html#commands)
|
||||||
if((MSVC) AND ((MSVC_VERSION GREATER 1914) OR (MSVC_VERSION EQUAL 1914)))
|
if((MSVC) AND ((MSVC_VERSION GREATER 1914) OR (MSVC_VERSION EQUAL 1914)))
|
||||||
target_compile_options(Async++ PUBLIC /Zc:__cplusplus)
|
target_compile_options(Async++ PUBLIC /Zc:__cplusplus)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/Async++Config.cmake.in"
|
configure_package_config_file(
|
||||||
"${PROJECT_BINARY_DIR}/Async++Config.cmake"
|
"${CMAKE_CURRENT_LIST_DIR}/Async++Config.cmake.in"
|
||||||
INSTALL_DESTINATION cmake
|
"${PROJECT_BINARY_DIR}/Async++Config.cmake" INSTALL_DESTINATION cmake)
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES "${PROJECT_BINARY_DIR}/Async++Config.cmake"
|
install(FILES "${PROJECT_BINARY_DIR}/Async++Config.cmake" DESTINATION cmake)
|
||||||
DESTINATION cmake
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install the library and produce a CMake export script
|
# Install the library and produce a CMake export script
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
install(TARGETS Async++
|
install(
|
||||||
|
TARGETS Async++
|
||||||
EXPORT Async++
|
EXPORT Async++
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
FRAMEWORK DESTINATION Frameworks
|
FRAMEWORK DESTINATION Frameworks)
|
||||||
)
|
|
||||||
export(EXPORT Async++)
|
export(EXPORT Async++)
|
||||||
install(EXPORT Async++ DESTINATION cmake)
|
install(EXPORT Async++ DESTINATION cmake)
|
||||||
if(APPLE AND BUILD_FRAMEWORK)
|
if(APPLE AND BUILD_FRAMEWORK)
|
||||||
set_target_properties(Async++ PROPERTIES OUTPUT_NAME Async++ FRAMEWORK ON)
|
set_target_properties(Async++ PROPERTIES OUTPUT_NAME Async++ FRAMEWORK ON)
|
||||||
set_source_files_properties(${ASYNCXX_INCLUDE} PROPERTIES MACOSX_PACKAGE_LOCATION Headers/async++)
|
set_source_files_properties(
|
||||||
set_source_files_properties(${PROJECT_SOURCE_DIR}/include/async++.h PROPERTIES MACOSX_PACKAGE_LOCATION Headers)
|
${ASYNCXX_INCLUDE} PROPERTIES MACOSX_PACKAGE_LOCATION Headers/async++)
|
||||||
|
set_source_files_properties(${PROJECT_SOURCE_DIR}/include/async++.h
|
||||||
|
PROPERTIES MACOSX_PACKAGE_LOCATION Headers)
|
||||||
else()
|
else()
|
||||||
set_target_properties(Async++ PROPERTIES OUTPUT_NAME async++)
|
set_target_properties(Async++ PROPERTIES OUTPUT_NAME async++)
|
||||||
target_include_directories(Async++ INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
|
target_include_directories(
|
||||||
|
Async++ INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>)
|
||||||
install(FILES ${PROJECT_SOURCE_DIR}/include/async++.h DESTINATION include)
|
install(FILES ${PROJECT_SOURCE_DIR}/include/async++.h DESTINATION include)
|
||||||
install(FILES ${ASYNCXX_INCLUDE} DESTINATION include/async++)
|
install(FILES ${ASYNCXX_INCLUDE} DESTINATION include/async++)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
SET(CPACK_GENERATOR "DEB")
|
set(CPACK_GENERATOR "DEB")
|
||||||
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "none") #required
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "none") # required
|
||||||
|
|
||||||
INCLUDE(CPack)
|
include(CPack)
|
||||||
|
Loading…
Reference in New Issue
Block a user