Skip to content

Commit

Permalink
Build for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
kotbegemot authored and theirix committed Mar 27, 2024
1 parent d42c620 commit 7c11188
Show file tree
Hide file tree
Showing 31 changed files with 84 additions and 191 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on: [push, pull_request]

jobs:
build:
strategy:
matrix:
cxx_standard: [11, 14, 17]
build_type: ["Release", "Debug"]

runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: Install system dependencies
run: |
brew install ninja cmake
python3 -m pip install --no-cache-dir conan==1.63
- name: Configure CMake
env:
BUILD_TYPE: ${{matrix.build_type}}
CXX_STANDARD: ${{matrix.cxx_standard}}
run: |
mkdir -p build
cmake -B build -GNinja \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.cxx_standard}} \
-DALLOW_EXAMPLES=ON \
-DALLOW_TESTS=ON \
-DENABLE_TESTS_MEASUREMENTS=ON \
-DALLOW_BENCHMARK=ON
- name: Build
run: cmake --build build

- name: Test
working-directory: build
run: ctest --rerun-failed --output-on-failure
53 changes: 37 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
cmake_minimum_required(VERSION 3.0)

cmake_minimum_required(VERSION 3.5)
PROJECT(actor-zeta LANGUAGES C CXX)

message(STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "CMAKE_C_COMPILER_ID = ${CMAKE_C_COMPILER_ID}")
message(STATUS "STANDARD CPP = ${CMAKE_CXX_STANDARD}")
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND UNIX AND NOT APPLE ) #------------------------------------- Clang
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
endif() #--------------------------------------------------------------------------- Clang

set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard whose features are requested.")
set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ standard whose features are requested.")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand All @@ -32,19 +31,42 @@ message(STATUS "RTTI_DISABLE = ${RTTI_DISABLE}")
message(STATUS "EXCEPTIONS_DISABLE = ${EXCEPTIONS_DISABLE}")

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE
STRING "Build type (default Debug):" FORCE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type (default Debug):" FORCE)
endif()

add_compile_options(
"$<$<AND:$<CXX_COMPILER_ID:GNU,Clang,AppleClang>,$<CONFIG:DEBUG>>:-fno-rtti;-Wall>"
"$<$<AND:$<CXX_COMPILER_ID:GNU,Clang,AppleClang>,$<CONFIG:RELEASE>>:-fno-rtti;-Wall>"
"$<$<AND:$<CXX_COMPILER_ID:GNU,Clang,AppleClang>,$<CONFIG:DEBUG>>:-fno-rtti;>"
"$<$<AND:$<CXX_COMPILER_ID:GNU,Clang,AppleClang>,$<CONFIG:RELEASE>>:-fno-rtti;>"
)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}/header)

if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compile_options(
-Wall
-Wextra
-Wpedantic

-Wcast-align
-Wcast-qual
-Wconversion
-Wctor-dtor-privacy
-Wenum-compare
-Wfloat-equal
-Wnon-virtual-dtor
-Wold-style-cast
-Woverloaded-virtual
-Wredundant-decls
-Wsign-conversion
-Wsign-promo
)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/W4 /WX)
endif ()


############## FINAL PROJECT CONFIG #################

file(GLOB ${PROJECT_NAME}_HEADERS
Expand Down Expand Up @@ -76,7 +98,7 @@ file(GLOB ${PROJECT_NAME}_HEADERS
header/*.h
)

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND NOT APPLE) #------------------------------------- Clang
############## LLVM CONFIGURATION #################
# https://github.com/nsumner/llvm-demo Example LLVM Build

Expand Down Expand Up @@ -127,7 +149,7 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #---------------------------------
set(LIBCXX "libc++")
endif()

if (${CLANG_LIBCPP_ABI} MATCHES "CLANG_LIBCPP_ABI-NOTFOUND")
if (CLANG_LIBCPP_ABI MATCHES "CLANG_LIBCPP_ABI-NOTFOUND")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++abi")
endif()
Expand All @@ -145,9 +167,6 @@ add_library(
${${PROJECT_NAME}_HEADERS}
)

# Unneeded transitional variable
set(REQ_LLVM_LIBRARIES "")

find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC
${CMAKE_THREAD_LIBS_INIT}
Expand All @@ -165,9 +184,11 @@ if (CONAN_EXPERIMENTAL_INCLUDE)
endif ()
include(conan.cmake)

# https://docs.conan.io/1/reference/config_files/settings.yml.html#c-standard-libraries-aka-compiler-libcxx
#conan_cmake_autodetect(CONAN_SETTINGS)
set(CONAN_SETTINGS "build_type=${CMAKE_BUILD_TYPE};compiler.libcxx=${LIBCXX};compiler.cppstd=${CMAKE_CXX_STANDARD}")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND UNIX AND NOT APPLE )
# https://docs.conan.io/1/reference/config_files/settings.yml.html#c-standard-libraries-aka-compiler-libcxx
#conan_cmake_autodetect(CONAN_SETTINGS)
set(CONAN_SETTINGS "build_type=${CMAKE_BUILD_TYPE};compiler.libcxx=${LIBCXX};compiler.cppstd=${CMAKE_CXX_STANDARD}")
endif ()

message(STATUS "CONAN_SETTINGS: ${CONAN_SETTINGS}")

Expand Down
2 changes: 0 additions & 2 deletions benchmark/actors/multithreaded/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cmake_minimum_required(VERSION 3.0)

set(project benchmark_actors_multithreaded)
if (CMAKE_VERSION VERSION_LESS 3.0)
PROJECT(${project} CXX)
Expand Down
6 changes: 0 additions & 6 deletions benchmark/actors/scheduled/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_HEADERS}
)

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
target_link_libraries(${PROJECT_NAME}
PUBLIC ${REQ_LLVM_LIBRARIES}
)
endif() #--------------------------------------------------------------------------- Clang

target_link_libraries(${PROJECT_NAME}
PUBLIC actor-zeta
PUBLIC CONAN_PKG::benchmark
Expand Down
2 changes: 1 addition & 1 deletion benchmark/actors/singlethreaded/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)

set(project benchmark_actors_singlethreaded)
if (CMAKE_VERSION VERSION_LESS 3.0)
Expand Down
12 changes: 0 additions & 12 deletions benchmark/message/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_HEADERS}
)

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
target_link_libraries(${PROJECT_NAME}
PUBLIC ${REQ_LLVM_LIBRARIES}
)
endif() #--------------------------------------------------------------------------- Clang

target_link_libraries(${PROJECT_NAME}
PUBLIC actor-zeta
PUBLIC CONAN_PKG::benchmark
Expand All @@ -46,12 +40,6 @@ add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_HEADERS}
)

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
target_link_libraries(${PROJECT_NAME}
PUBLIC ${REQ_LLVM_LIBRARIES}
)
endif() #--------------------------------------------------------------------------- Clang

target_link_libraries(${PROJECT_NAME}
PUBLIC actor-zeta
PUBLIC CONAN_PKG::benchmark
Expand Down
6 changes: 0 additions & 6 deletions examples/balancer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
target_link_libraries(${PROJECT_NAME}
PUBLIC ${REQ_LLVM_LIBRARIES}
)
endif() #--------------------------------------------------------------------------- Clang

target_link_libraries(${PROJECT_NAME}
PUBLIC actor-zeta
)
6 changes: 0 additions & 6 deletions examples/broadcast/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
target_link_libraries(${PROJECT_NAME}
PUBLIC ${REQ_LLVM_LIBRARIES}
)
endif() #--------------------------------------------------------------------------- Clang

target_link_libraries(${PROJECT_NAME}
PUBLIC actor-zeta
)
6 changes: 0 additions & 6 deletions examples/dataflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
target_link_libraries(${PROJECT_NAME}
PUBLIC ${REQ_LLVM_LIBRARIES}
)
endif() #--------------------------------------------------------------------------- Clang

target_link_libraries(${PROJECT_NAME}
PUBLIC actor-zeta
)
2 changes: 1 addition & 1 deletion examples/dataflow/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class actor_test_t final : public actor_zeta::basic_actor<actor_test_t> {
}

void process_data(data_t&& data) {
auto ms_dur = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - data.time()).count();
///auto ms_dur = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - data.time()).count();
packets_a--;
if (packets_a.load() > 0)
std::cout << __func__ << " :: packets_a " << packets_a.load() << " OUT >>>" << std::endl;
Expand Down
6 changes: 0 additions & 6 deletions examples/timer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
target_link_libraries(${PROJECT_NAME}
PUBLIC ${REQ_LLVM_LIBRARIES}
)
endif() #--------------------------------------------------------------------------- Clang

target_link_libraries(${PROJECT_NAME}
PUBLIC actor-zeta
)
6 changes: 3 additions & 3 deletions header/actor-zeta/base/behavior.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace actor_zeta { namespace base {
behavior_t(behavior_t&&) = default;
behavior_t& operator=(behavior_t&&) = default;

behavior_t(actor_zeta::pmr::memory_resource* resource, id name, action handler) {
behavior_t(actor_zeta::pmr::memory_resource*, id name, action handler) {
///assert(id_.integer_value() == mailbox::detail::default_async_value);
id_ = name;
handler_ = std::move(handler);
Expand Down Expand Up @@ -72,7 +72,7 @@ namespace actor_zeta { namespace base {

template<class F>
behavior_t make_behavior(actor_zeta::pmr::memory_resource* resource, F&& f) {
return {resource, mailbox::message_id{}, std::move(action(std::forward<F>(f)))};
return {resource, mailbox::message_id{}, action(std::forward<F>(f))};
}
//// todo: rename behavior
/*template<class F>
Expand All @@ -86,7 +86,7 @@ namespace actor_zeta { namespace base {
}
*/
template<class T>
void invoke(behavior_t& instance, T* ptr, mailbox::message* msg) {
void invoke(behavior_t& instance, T* , mailbox::message* msg) {
instance(msg);
/// todo: add error handling
/*
Expand Down
3 changes: 1 addition & 2 deletions header/actor-zeta/base/detail/hfsm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ namespace actor_zeta { namespace detail {
hfsm& operator=(const hfsm&) = delete;
hfsm() = delete;

hfsm(actor_zeta::pmr::memory_resource* resource) {
}
hfsm(actor_zeta::pmr::memory_resource* ) {}

void pop_back() {
assert(!elements_.empty());
Expand Down
7 changes: 0 additions & 7 deletions header/actor-zeta/impl/actor/actor_abstract.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@

namespace actor_zeta { namespace base {

static void error_sync_contacts(const std::string& name, const std::string& error) {
std::cerr << "WARNING" << '\n';
std::cerr << "Actor name : " << name << '\n';
std::cerr << "Not initialization address type:" << error << '\n';
std::cerr << "WARNING" << std::endl;
}

actor_abstract::~actor_abstract() {
}

Expand Down
2 changes: 1 addition & 1 deletion header/actor-zeta/impl/handler.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace actor_zeta { namespace base {
void apply_impl_for_class(ClassPtr *ptr,F &&f, mailbox::message *ctx, type_traits::index_sequence<I...>) {
using call_trait = type_traits::get_callable_trait_t<type_traits::remove_reference_t<F>>;
using args_type_list = typename call_trait::args_types;
using result_type = typename call_trait::result_type;
//using result_type = typename call_trait::result_type;
///using Tuple = type_list_to_tuple_t<args_type_list>;
auto &args = ctx->body();
//(ptr->*f)(static_cast< forward_arg<args_type_list, I>>(std::get<I>(args))...);
Expand Down
2 changes: 1 addition & 1 deletion header/actor-zeta/impl/scheduler/scheduler_abstract.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace actor_zeta { namespace scheduler {

dummy_unit dummy{};
while (!dummy.resumables.empty()) {
auto sub = dummy.resumables.back();
/* ??? auto sub = ??? */ dummy.resumables.back();
dummy.resumables.pop_back();
}

Expand Down
6 changes: 0 additions & 6 deletions test/actor-id/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
target_link_libraries(${PROJECT_NAME}
PUBLIC ${REQ_LLVM_LIBRARIES}
)
endif() #--------------------------------------------------------------------------- Clang

target_link_libraries(${PROJECT_NAME}
PUBLIC actor-zeta
PUBLIC tooltestsuites
Expand Down
2 changes: 1 addition & 1 deletion test/actor-id/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class storage_t final : public actor_zeta::basic_actor<storage_t> {
actor_zeta::behavior_t behavior() {
return actor_zeta::make_behavior(
resource(),
[this](actor_zeta::message* msg) -> void {
[](actor_zeta::message* ) -> void {

});
}
Expand Down
6 changes: 0 additions & 6 deletions test/behavior/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
target_link_libraries(${PROJECT_NAME}
PUBLIC ${REQ_LLVM_LIBRARIES}
)
endif() #--------------------------------------------------------------------------- Clang

target_link_libraries(${PROJECT_NAME}
PUBLIC actor-zeta
PUBLIC tooltestsuites
Expand Down
6 changes: 0 additions & 6 deletions test/intrusive_ptr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
target_link_libraries(${PROJECT_NAME}
PUBLIC ${REQ_LLVM_LIBRARIES}
)
endif() #--------------------------------------------------------------------------- Clang

target_link_libraries(${PROJECT_NAME}
PUBLIC actor-zeta
PUBLIC CONAN_PKG::catch2
Expand Down
6 changes: 0 additions & 6 deletions test/life-cycle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") #------------------------------------- Clang
target_link_libraries(${PROJECT_NAME}
PUBLIC ${REQ_LLVM_LIBRARIES}
)
endif() #--------------------------------------------------------------------------- Clang

target_link_libraries(${PROJECT_NAME}
PUBLIC actor-zeta
PUBLIC tooltestsuites
Expand Down
Loading

0 comments on commit 7c11188

Please sign in to comment.