Commit f14a6e3a authored by Dominik Charousset's avatar Dominik Charousset

Fix CMake dependencies

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