Commit 99c43535 authored by Dominik Charousset's avatar Dominik Charousset

Tidy up CMake setup, propagate flags via targets

parent 44c41ad2
This diff is collapsed.
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2016 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
// this header is auto-generated by CMake
#pragma once
#include "caf/detail/log_level.hpp"
// this header is auto-generated by CMake
#define CAF_LOG_LEVEL CAF_LOG_LEVEL_@CAF_LOG_LEVEL@
#cmakedefine CAF_ENABLE_RUNTIME_CHECKS
......
......@@ -2,13 +2,14 @@ add_custom_target(all_examples)
function(add_example folder name)
add_executable(${name} ${folder}/${name}.cpp ${ARGN})
install(FILES ${folder}/${name}.cpp DESTINATION ${CMAKE_INSTALL_DATADIR}/caf/examples/${folder})
install(FILES ${folder}/${name}.cpp
DESTINATION ${CMAKE_INSTALL_DATADIR}/caf/examples/${folder})
add_dependencies(${name} all_examples)
endfunction()
function(add_core_example folder name)
add_example(${folder} ${name} ${ARGN})
target_link_libraries(${name} CAF::core)
target_link_libraries(${name} PRIVATE CAF::internal CAF::core)
endfunction()
# -- examples for CAF::core ----------------------------------------------------
......@@ -43,7 +44,7 @@ add_core_example(custom_type custom_types_3)
# testing DSL
add_example(testing ping_pong)
target_link_libraries(ping_pong CAF::core CAF::test)
target_link_libraries(ping_pong PRIVATE CAF::internal CAF::core CAF::test)
# -- examples for CAF::io ------------------------------------------------------
......@@ -52,7 +53,7 @@ if(TARGET CAF::io)
function(add_io_example folder name)
add_example(${folder} ${name} ${ARGN})
target_link_libraries(${name} CAF::io CAF::core)
target_link_libraries(${name} PRIVATE CAF::internal CAF::io)
endfunction()
# basic remoting
......@@ -65,53 +66,52 @@ if(TARGET CAF::io)
add_io_example(broker simple_broker)
add_io_example(broker simple_http_broker)
endif()
if(CAF_ENABLE_PROTOBUF_EXAMPLES)
find_package(Protobuf REQUIRED)
if(NOT PROTOBUF_PROTOC_EXECUTABLE)
message(FATAL_ERROR "CMake was unable to set PROTOBUF_PROTOC_EXECUTABLE")
endif()
protobuf_generate_cpp(ProtoSources ProtoHeaders "${CMAKE_CURRENT_SOURCE_DIR}/remoting/pingpong.proto")
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(protobuf_broker broker/protobuf_broker.cpp ${ProtoSources})
target_link_libraries(protobuf_broker
PRIVATE ${PROTOBUF_LIBRARIES} CAF::internal CAF::io)
add_dependencies(protobuf_broker all_examples)
endif()
if(CAF_ENABLE_PROTOBUF_EXAMPLES)
find_package(Protobuf REQUIRED)
if(NOT PROTOBUF_PROTOC_EXECUTABLE)
message(FATAL_ERROR "CMake was unable to set PROTOBUF_PROTOC_EXECUTABLE")
if(CAF_ENABLE_QT5_EXAMPLES)
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
message(STATUS "Found Qt5")
#include(${QT_USE_FILE})
QT5_ADD_RESOURCES(GROUP_CHAT_RCS )
QT5_WRAP_UI(GROUP_CHAT_UI_HDR qtsupport/chatwindow.ui)
QT5_WRAP_CPP(GROUP_CHAT_MOC_SRC qtsupport/chatwidget.hpp)
# generated headers will be in cmake build directory
include_directories(qtsupport
${CMAKE_CURRENT_BINARY_DIR}
${Qt5Core_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS})
set(GROUP_CHAT_SRC qtsupport/qt_group_chat.cpp qtsupport/chatwidget.cpp)
add_executable(qt_group_chat
${GROUP_CHAT_SRC}
${GROUP_CHAT_MOC_SRC}
${GROUP_CHAT_UI_HDR})
target_link_libraries(qt_group_chat
Qt5::Core
Qt5::Gui
Qt5::Widgets
CAF::io)
add_dependencies(qt_group_chat all_examples)
endif()
protobuf_generate_cpp(ProtoSources ProtoHeaders "${CMAKE_CURRENT_SOURCE_DIR}/remoting/pingpong.proto")
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(protobuf_broker broker/protobuf_broker.cpp ${ProtoSources})
target_link_libraries(protobuf_broker ${PROTOBUF_LIBRARIES} CAF::core CAF::io)
add_dependencies(protobuf_broker all_examples)
endif()
if(CAF_ENABLE_QT5_EXAMPLES)
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
message(STATUS "Found Qt5")
#include(${QT_USE_FILE})
QT5_ADD_RESOURCES(GROUP_CHAT_RCS )
QT5_WRAP_UI(GROUP_CHAT_UI_HDR qtsupport/chatwindow.ui)
QT5_WRAP_CPP(GROUP_CHAT_MOC_SRC qtsupport/chatwidget.hpp)
# generated headers will be in cmake build directory
include_directories(qtsupport
${CMAKE_CURRENT_BINARY_DIR}
${Qt5Core_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS})
set(GROUP_CHAT_SRC qtsupport/qt_group_chat.cpp qtsupport/chatwidget.cpp)
add_executable(qt_group_chat
${GROUP_CHAT_SRC}
${GROUP_CHAT_MOC_SRC}
${GROUP_CHAT_UI_HDR})
target_link_libraries(qt_group_chat
Qt5::Core
Qt5::Gui
Qt5::Widgets
CAF::core
CAF::io)
add_dependencies(qt_group_chat all_examples)
endif()
if(CAF_ENABLE_CURL_EXAMPLES)
find_package(CURL REQUIRED)
add_executable(curl_fuse curl/curl_fuse.cpp)
include_directories(${CURL_INCLUDE_DIRS})
target_link_libraries(curl_fuse ${CURL_LIBRARY} CAF::io)
add_dependencies(curl_fuse all_examples)
endif()
if(CAF_ENABLE_CURL_EXAMPLES)
find_package(CURL REQUIRED)
add_executable(curl_fuse curl/curl_fuse.cpp)
include_directories(${CURL_INCLUDE_DIRS})
target_link_libraries(curl_fuse ${CURL_LIBRARY} CAF::core CAF::io)
add_dependencies(curl_fuse all_examples)
endif()
This diff is collapsed.
# -- get header files for creating "proper" XCode projects ---------------------
# -- collect header files ------------------------------------------------------
file(GLOB_RECURSE CAF_IO_HEADERS "caf/*.hpp")
# -- add consistency checks for enum to_string implementations -----------------
caf_add_enum_consistency_check("caf/io/basp/message_type.hpp"
"src/io/basp/message_type_strings.cpp")
caf_add_enum_consistency_check("caf/io/network/operation.hpp"
"src/io/network/operation_strings.cpp")
# -- utility function for setting default properties ---------------------------
function(caf_io_set_default_properties)
foreach(target ${ARGN})
# Set global defaults and set EXPORTS flag.
caf_set_default_properties(${target})
target_compile_definitions(${target} PRIVATE libcaf_io_EXPORTS)
# Pull in public dependencies.
caf_target_link_libraries(${target} PUBLIC CAF::core)
if(MSVC)
caf_target_link_libraries(${target} PUBLIC ws2_32 iphlpapi)
endif()
endforeach()
endfunction()
# -- add library target --------------------------------------------------------
add_library(libcaf_io_obj OBJECT ${CAF_IO_HEADERS}
src/detail/prometheus_broker.cpp
src/detail/remote_group_module.cpp
src/detail/socket_guard.cpp
src/io/abstract_broker.cpp
src/io/basp/header.cpp
src/io/basp/instance.cpp
src/io/basp/message_queue.cpp
src/io/basp/message_type_strings.cpp
src/io/basp/routing_table.cpp
src/io/basp/worker.cpp
src/io/basp_broker.cpp
src/io/broker.cpp
src/io/connection_helper.cpp
src/io/datagram_servant.cpp
src/io/doorman.cpp
src/io/middleman.cpp
src/io/middleman_actor.cpp
src/io/middleman_actor_impl.cpp
src/io/network/acceptor.cpp
src/io/network/acceptor_manager.cpp
src/io/network/datagram_handler.cpp
src/io/network/datagram_manager.cpp
src/io/network/datagram_servant_impl.cpp
src/io/network/default_multiplexer.cpp
src/io/network/doorman_impl.cpp
src/io/network/event_handler.cpp
src/io/network/interfaces.cpp
src/io/network/ip_endpoint.cpp
src/io/network/manager.cpp
src/io/network/multiplexer.cpp
src/io/network/native_socket.cpp
src/io/network/operation_strings.cpp
src/io/network/pipe_reader.cpp
src/io/network/protocol.cpp
src/io/network/receive_buffer.cpp
src/io/network/scribe_impl.cpp
src/io/network/stream.cpp
src/io/network/stream_manager.cpp
src/io/network/test_multiplexer.cpp
src/io/scribe.cpp
src/policy/tcp.cpp
src/policy/udp.cpp
)
add_library(libcaf_io
"${PROJECT_SOURCE_DIR}/cmake/dummy.cpp"
$<TARGET_OBJECTS:libcaf_io_obj>)
caf_io_set_default_properties(libcaf_io_obj libcaf_io)
caf_export_and_install_lib(io)
# -- build unit tests ----------------------------------------------------------
if(NOT CAF_ENABLE_TESTING)
return()
endif()
add_executable(caf-io-test
test/io-test.cpp
$<TARGET_OBJECTS:libcaf_io_obj>)
caf_io_set_default_properties(caf-io-test)
target_include_directories(caf-io-test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/test")
target_link_libraries(caf-io-test PRIVATE CAF::test)
caf_add_test_suites(caf-io-test
detail.prometheus_broker
io.basp.message_queue
io.basp_broker
io.broker
io.http_broker
io.monitor
io.network.default_multiplexer
io.network.ip_endpoint
io.receive_buffer
io.remote_actor
io.remote_group
io.remote_spawn
io.unpublish
io.worker
)
if(NOT WIN32)
# -- add targets ---------------------------------------------------------------
caf_add_component(
io
DEPENDENCIES
PUBLIC
CAF::core
$<$<CXX_COMPILER_ID:MSVC>:ws2_32>
PRIVATE
CAF::internal
ENUM_CONSISTENCY_CHECKS
io.basp.message_type
io.network.operation
HEADERS
${CAF_IO_HEADERS}
SOURCES
src/detail/prometheus_broker.cpp
src/detail/remote_group_module.cpp
src/detail/socket_guard.cpp
src/io/abstract_broker.cpp
src/io/basp/header.cpp
src/io/basp/instance.cpp
src/io/basp/message_queue.cpp
src/io/basp/message_type_strings.cpp
src/io/basp/routing_table.cpp
src/io/basp/worker.cpp
src/io/basp_broker.cpp
src/io/broker.cpp
src/io/connection_helper.cpp
src/io/datagram_servant.cpp
src/io/doorman.cpp
src/io/middleman.cpp
src/io/middleman_actor.cpp
src/io/middleman_actor_impl.cpp
src/io/network/acceptor.cpp
src/io/network/acceptor_manager.cpp
src/io/network/datagram_handler.cpp
src/io/network/datagram_manager.cpp
src/io/network/datagram_servant_impl.cpp
src/io/network/default_multiplexer.cpp
src/io/network/doorman_impl.cpp
src/io/network/event_handler.cpp
src/io/network/interfaces.cpp
src/io/network/ip_endpoint.cpp
src/io/network/manager.cpp
src/io/network/multiplexer.cpp
src/io/network/native_socket.cpp
src/io/network/operation_strings.cpp
src/io/network/pipe_reader.cpp
src/io/network/protocol.cpp
src/io/network/receive_buffer.cpp
src/io/network/scribe_impl.cpp
src/io/network/stream.cpp
src/io/network/stream_manager.cpp
src/io/network/test_multiplexer.cpp
src/io/scribe.cpp
src/policy/tcp.cpp
src/policy/udp.cpp
TEST_SOURCES
test/io-test.cpp
TEST_SUITES
detail.prometheus_broker
io.basp.message_queue
io.basp_broker
io.broker
io.http_broker
io.monitor
io.network.default_multiplexer
io.network.ip_endpoint
io.receive_buffer
io.remote_actor
io.remote_group
io.remote_spawn
io.unpublish
io.worker)
if(CAF_ENABLE_TESTING AND UNIX)
caf_add_test_suites(caf-io-test io.middleman)
endif()
# -- get header files for creating "proper" XCode projects ---------------------
# -- collect header files ------------------------------------------------------
file(GLOB_RECURSE CAF_OPENSSL_HEADERS "caf/*.hpp")
......@@ -8,55 +8,27 @@ if(NOT TARGET OpenSSL::SSL OR NOT TARGET OpenSSL::Crypto)
find_package(OpenSSL REQUIRED)
endif()
# -- utility function for setting default properties ---------------------------
function(caf_openssl_set_default_properties)
foreach(target ${ARGN})
# Set global defaults and set EXPORTS flag.
caf_set_default_properties(${target})
target_compile_definitions(${target} PRIVATE libcaf_openssl_EXPORTS)
# Pull in public dependencies.
caf_target_link_libraries(${target} PUBLIC
CAF::core CAF::io OpenSSL::SSL OpenSSL::Crypto)
endforeach()
endfunction()
# -- add library target --------------------------------------------------------
add_library(libcaf_openssl_obj OBJECT ${CAF_OPENSSL_HEADERS}
src/openssl/manager.cpp
src/openssl/middleman_actor.cpp
src/openssl/publish.cpp
src/openssl/remote_actor.cpp
src/openssl/session.cpp
)
add_library(libcaf_openssl
"${PROJECT_SOURCE_DIR}/cmake/dummy.cpp"
$<TARGET_OBJECTS:libcaf_openssl_obj>)
caf_openssl_set_default_properties(libcaf_openssl_obj libcaf_openssl)
caf_export_and_install_lib(openssl)
# -- build unit tests ----------------------------------------------------------
if(NOT CAF_ENABLE_TESTING)
return()
endif()
add_executable(caf-openssl-test
test/openssl-test.cpp
${CAF_OPENSSL_TEST_SOURCES}
$<TARGET_OBJECTS:libcaf_openssl_obj>)
caf_openssl_set_default_properties(caf-openssl-test)
target_include_directories(caf-openssl-test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/test")
target_link_libraries(caf-openssl-test PRIVATE CAF::test)
caf_add_test_suites(caf-openssl-test
openssl.authentication
openssl.remote_actor
)
# -- add targets ---------------------------------------------------------------
caf_add_component(
openssl
DEPENDENCIES
PUBLIC
CAF::io
OpenSSL::SSL
OpenSSL::Crypto
PRIVATE
CAF::internal
HEADERS
${CAF_OPENSSL_HEADERS}
SOURCES
src/openssl/manager.cpp
src/openssl/middleman_actor.cpp
src/openssl/publish.cpp
src/openssl/remote_actor.cpp
src/openssl/session.cpp
TEST_SOURCES
test/openssl-test.cpp
TEST_SUITES
openssl.authentication
openssl.remote_actor)
......@@ -7,13 +7,13 @@ macro(add name)
endmacro()
add(caf-vec)
target_link_libraries(caf-vec PRIVATE CAF::core)
target_link_libraries(caf-vec PRIVATE CAF::internal CAF::core)
if(TARGET CAF::io)
if(WIN32)
message(STATUS "skip caf-run (not supported on Windows)")
message(STATUS "Skip caf-run (not supported on Windows)")
else()
add(caf-run)
target_link_libraries(caf-run PRIVATE CAF::io CAF::core)
target_link_libraries(caf-run PRIVATE CAF::internal CAF::io)
endif()
endif()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment