Commit f14a6e3a authored by Dominik Charousset's avatar Dominik Charousset

Fix CMake dependencies

parent a0cc8e5b
......@@ -353,118 +353,94 @@ include_directories("${LIBCAF_INCLUDE_DIRS}")
################################################################################
# add subprojects #
# add targets #
################################################################################
# build libcaf_test if not being told otherwise
if(NOT CAF_NO_UNIT_TESTS)
#message(STATUS "Enter subdirectory libcaf_test")
#add_subdirectory(libcaf_test)
endif()
# core library
add_subdirectory(libcaf_core)
add_unit_tests("libcaf_core/test/*.cpp")
add_unit_tests("libcaf_io/test/*.cpp")
# set core lib for sub directories
if(NOT CAF_BUILD_STATIC_ONLY)
set(LIBCAF_CORE_LIBRARY libcaf_core_shared)
else()
set(LIBCAF_CORE_LIBRARY libcaf_core_static)
endif()
add_subdirectory(libcaf_io)
# set io lib for sub directories
if(NOT CAF_BUILD_STATIC_ONLY)
set(LIBCAF_IO_LIBRARY libcaf_io_shared)
else()
set(LIBCAF_IO_LIBRARY libcaf_io_static)
endif()
# set opencl lib for sub directories if not told otherwise
if(NOT CAF_NO_OPENCL
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt")
find_package(OpenCL REQUIRED)
add_subdirectory(libcaf_opencl)
macro(add_caf_lib name)
string(TOUPPER ${name} upper_name)
set(full_name libcaf_${name})
set(shared_target ${full_name}_shared)
set(static_target ${full_name}_static)
add_subdirectory(${full_name})
set(lib_varname CAF_LIBRARY_${upper_name})
set(lib_varname_static ${lib_varname}_STATIC)
if(NOT CAF_BUILD_STATIC_ONLY)
set(LIBCAF_OPENCL_LIBRARY libcaf_opencl_shared)
set(${lib_varname} ${shared_target})
set(CAF_LIBRARIES ${CAF_LIBRARIES} ${shared_target})
else()
set(LIBCAF_OPENCL_LIBRARY libcaf_opencl_static)
set(${lib_varname} ${static_target})
set(CAF_LIBRARIES ${CAF_LIBRARIES} ${static_target})
endif()
add_unit_tests("libcaf_opencl/test/*.cpp")
endif()
# tell CMake caf_io depends on caf_core
add_dependencies(libcaf_io libcaf_core)
# set LIBCAF_LIBRARIES for other subprojects
set(LIBCAF_LIBRARIES "${LIBCAF_CORE_LIBRARY}"
"${LIBCAF_IO_LIBRARY}"
"${LIBCAF_OPENCL_LIBRARY}")
# build examples if not being told otherwise
if(NOT CAF_NO_EXAMPLES)
add_subdirectory(examples)
add_dependencies(all_examples libcaf_core libcaf_io)
if(NOT CAF_NO_OPENCL
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_opencl/CMakeLists.txt")
add_subdirectory(libcaf_opencl/examples)
endif()
endif()
# build RIAC if not being told otherwise
if(NOT CAF_NO_RIAC
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_riac/CMakeLists.txt")
add_subdirectory(libcaf_riac)
add_dependencies(libcaf_riac libcaf_core libcaf_io)
if(NOT CAF_BUILD_STATIC_ONLY)
set(LIBCAF_LIBRARIES "${LIBCAF_LIBRARIES}" libcaf_riac_shared)
else()
set(LIBCAF_LIBRARIES "${LIBCAF_LIBRARIES}" libcaf_riac_static)
if(CAF_BUILD_STATIC_ONLY OR CAF_BUILD_STATIC)
set(${lib_varname_static} ${static_target})
endif()
add_unit_tests("${full_name}/test/*.cpp")
# add headers to include directories so other subprojects can use RIAC
include_directories("${LIBCAF_INCLUDE_DIRS}"
"${CMAKE_CURRENT_SOURCE_DIR}/libcaf_riac")
# add libcaf_riac to the list of caf libraries
set(CAF_HAS_RIAC yes)
# add unit tests
add_unit_tests("libcaf_riac/test/*.cpp")
else()
set(CAF_HAS_RIAC no)
endif()
# build nexus if not being told otherwise
if(NOT CAF_NO_NEXUS
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/nexus/CMakeLists.txt")
if(NOT CAF_HAS_RIAC)
message(WARNING "cannot build nexus without RIAC submodule")
set(CAF_NO_NEXUS yes)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/libcaf_${name}")
endmacro()
macro(add_optional_caf_lib name)
string(TOUPPER ${name} upper_name)
set(flag_varname CAF_NO_${upper_name})
if(NOT ${flag_varname}
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libcaf_${name}/CMakeLists.txt")
add_caf_lib(${name})
else()
add_subdirectory(nexus)
add_dependencies(nexus libcaf_riac)
set(CAF_NO_NEXUS no)
set(${flag_name} yes)
endif()
else()
# make sure variable is set for build log
set(CAF_NO_NEXUS yes)
endif()
# build cash if not being told otherwise
if(NOT CAF_NO_CASH
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cash/CMakeLists.txt")
if(NOT CAF_HAS_RIAC)
message(WARNING "cannot build cash without RIAC submodule")
set(CAF_NO_CASH yes)
endmacro()
macro(add_optional_caf_binaries name)
string(TOUPPER ${name} upper_name)
set(dependency_failed no)
# check all aditional dependency flags
foreach(flag_name ${ARGN})
if(${flag_name})
set(dependency_failed yes)
endif()
endforeach()
if(NOT dependency_failed)
if(NOT CAF_NO_${upper_name}
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${name}/CMakeLists.txt")
add_subdirectory(${name})
else()
# make sure variable is set for nicer build log
set(CAF_NO_${upper_name} yes)
endif()
else()
add_subdirectory(cash)
add_dependencies(cash libcaf_riac)
set(CAF_NO_CASH no)
message(STATUS
"Disable ${name}, one of the following flags was set: ${ARGN}")
# make sure variable is set for nicer build log
set(CAF_NO_${upper_name} yes)
endif()
endmacro()
# build core and I/O library
add_caf_lib(core)
add_caf_lib(io)
# build opencl library if not told otherwise and OpenCL package was found
if(NOT CAF_NO_OPENCL)
find_package(OpenCL)
if(OpenCL_FOUND)
add_optional_caf_lib(opencl)
endif()
else()
# make sure variable is set for build log
set(CAF_NO_CASH yes)
endif()
# build RIAC library if not being told otherwise
add_optional_caf_lib(riac)
# build examples if not being told otherwise
add_optional_caf_binaries(examples)
# build nexus if not being told otherwise
add_optional_caf_binaries(nexus CAF_NO_RIAC)
# build cash if not being told otherwise
add_optional_caf_binaries(cash CAF_NO_RIAC)
# build benchmarks if not being told otherwise
if(NOT CAF_NO_BENCHMARKS
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/CMakeLists.txt")
add_subdirectory(benchmarks)
add_dependencies(all_benchmarks libcaf_io)
else()
# make sure variable is set for build log
set(CAF_NO_BENCHMARKS yes)
endif()
add_optional_caf_binaries(benchmarks)
################################################################################
......@@ -480,7 +456,7 @@ if(NOT CAF_NO_UNIT_TESTS)
${CAF_ALL_UNIT_TESTS})
target_link_libraries(caf-test
${LD_FLAGS}
${LIBCAF_LIBRARIES}
${CAF_LIBRARIES}
${PTHREAD_LIBRARIES})
add_custom_target(all_unit_tests)
add_dependencies(caf-test all_unit_tests)
......@@ -580,6 +556,7 @@ endmacro()
# invert CAF_NO_* variables for nicer output
invertYesNo(CAF_NO_EXAMPLES CAF_BUILD_EXAMPLES)
invertYesNo(CAF_NO_UNIT_TESTS CAF_BUILD_UNIT_TESTS)
invertYesNo(CAF_NO_RIAC CAF_BUILD_RIAC)
invertYesNo(CAF_NO_NEXUS CAF_BUILD_NEXUS)
invertYesNo(CAF_NO_CASH CAF_BUILD_CASH)
invertYesNo(CAF_NO_MEM_MANAGEMENT CAF_BUILD_MEM_MANAGEMENT)
......@@ -604,7 +581,7 @@ if(NOT CAF_NO_SUMMARY)
"\n"
"\nBuild examples: ${CAF_BUILD_EXAMPLES}"
"\nBuild unit tests: ${CAF_BUILD_UNIT_TESTS}"
"\nBuild riac: ${CAF_HAS_RIAC}"
"\nBuild riac: ${CAF_BUILD_RIAC}"
"\nBuild nexus: ${CAF_BUILD_NEXUS}"
"\nBuild cash: ${CAF_BUILD_CASH}"
"\nBuild benchmarks: ${CAF_BUILD_BENCHMARKS}"
......
Subproject commit 1edec8c646254633b13594b5d6fc759737d41b06
Subproject commit 59548f4df2681e5e335ff4da0eaadee992d257cd
Subproject commit a263ec8727dd8ac769c14312582b192fe05b47ee
Subproject commit cf6a541595c2a669f47990f4ca9ad71dd7621fd4
......@@ -15,7 +15,7 @@ macro(add name folder)
add_executable(${name} ${folder}/${name}.cpp ${ARGN})
target_link_libraries(${name}
${LD_FLAGS}
${LIBCAF_LIBRARIES}
${CAF_LIBRARIES}
${PTHREAD_LIBRARIES}
${WSLIB})
install(FILES ${folder}/${name}.cpp DESTINATION share/caf/examples/${folder})
......@@ -47,7 +47,7 @@ if(NOT CAF_NO_PROTOBUF_EXAMPLES)
# add binary dir as include path as generated headers will be located there
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(protobuf_broker brokers/protobuf_broker.cpp ${ProtoSources})
target_link_libraries(protobuf_broker ${CMAKE_DL_LIBS} ${LIBCAF_LIBRARIES} ${PTHREAD_LIBRARIES} ${PROTOBUF_LIBRARIES})
target_link_libraries(protobuf_broker ${CMAKE_DL_LIBS} ${CAF_LIBRARIES} ${PTHREAD_LIBRARIES} ${PROTOBUF_LIBRARIES})
add_dependencies(protobuf_broker all_examples)
endif(PROTOBUF_FOUND AND PROTOBUF_PROTOC_EXECUTABLE)
endif()
......@@ -74,7 +74,7 @@ if(NOT CAF_NO_QT_EXAMPLES)
${GROUP_CHAT_UI_HDR})
target_link_libraries(qt_group_chat
${CMAKE_DL_LIBS}
${LIBCAF_LIBRARIES}
${CAF_LIBRARIES}
Qt5::Core
Qt5::Gui
Qt5::Widgets)
......@@ -97,7 +97,7 @@ if(NOT CAF_NO_QT_EXAMPLES)
${GROUP_CHAT_UI_HDR})
target_link_libraries(qt_group_chat
${CMAKE_DL_LIBS}
${LIBCAF_LIBRARIES}
${CAF_LIBRARIES}
${QT_LIBRARIES})
add_dependencies(qt_group_chat all_examples)
endif()
......@@ -109,7 +109,7 @@ if(NOT CAF_NO_CURL_EXAMPLES)
if(CURL_FOUND)
add_executable(curl_fuse curl/curl_fuse.cpp)
include_directories(${CURL_INCLUDE_DIRS})
target_link_libraries(curl_fuse ${CMAKE_DL_LIBS} ${LIBCAF_LIBRARIES} ${PTHREAD_LIBRARIES} ${CURL_LIBRARY})
target_link_libraries(curl_fuse ${CMAKE_DL_LIBS} ${CAF_LIBRARIES} ${PTHREAD_LIBRARIES} ${CURL_LIBRARY})
add_dependencies(curl_fuse all_examples)
endif(CURL_FOUND)
endif()
......@@ -35,7 +35,7 @@ add_custom_target(libcaf_io)
# build shared library if not compiling static only
if (NOT CAF_BUILD_STATIC_ONLY)
add_library(libcaf_io_shared SHARED ${LIBCAF_IO_SRCS} ${LIBCAF_IO_HDRS})
target_link_libraries(libcaf_io_shared ${LD_FLAGS} ${LIBCAF_CORE_LIBRARY})
target_link_libraries(libcaf_io_shared ${LD_FLAGS} ${CAF_LIBRARY_CORE})
set_target_properties(libcaf_io_shared
PROPERTIES
SOVERSION ${CAF_VERSION}
......@@ -50,7 +50,7 @@ endif ()
# build static library only if --build-static or --build-static-only was set
if (CAF_BUILD_STATIC_ONLY OR CAF_BUILD_STATIC)
add_library(libcaf_io_static STATIC ${LIBCAF_IO_HDRS} ${LIBCAF_IO_SRCS})
target_link_libraries(libcaf_io_static ${LD_FLAGS} ${LIBCAF_CORE_LIBRARY})
target_link_libraries(libcaf_io_static ${LD_FLAGS} ${CAF_LIBRARY_CORE_STATIC})
set_target_properties(libcaf_io_static PROPERTIES OUTPUT_NAME caf_io_static)
if(NOT WIN32)
install(TARGETS libcaf_io_static ARCHIVE DESTINATION lib)
......
Subproject commit b1d00989d681ccc6debf221730b1d6e800651544
Subproject commit 7d57285753289ca7368bd084f711de218e0fde07
Subproject commit 538fead880460a2b96e44cecacc3f9ae4fc06fe7
Subproject commit e66010a61cdceeef662dd701afd5a8cda411e320
Subproject commit 1a9c3cc5068a82036e540a245f3c459e00ce5b1b
Subproject commit a33c3c4f80e8a276d16276bab8763eb48e898581
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