Don't pass MEMGRAPH_ALL_LIBS to all cmake targets

Summary:
CMake is smart enough to transitively detect dependencies and link them
appropriately. Therefore, it is enough that we put all libraries that
memgraph uses to the dependency list of memgraph_lib and memgraph_pic
targets.

Patch the fmt library for C++14 and higher

fmt library would detect that C++11 is supported and then put the
compiler flag. This flag was set so it overrides parent project compiler
flags. This override from fmt would prevent us from using C++14
features. New version (3.1) of fmt resolves this issue, but it hasn't
been released yet. Therefore, this commit updates the script which
clones fmt to use the released 3.0.1 version and apply the fix on that.

Reviewers: dgleich, buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D441
This commit is contained in:
Teon Banek 2017-06-08 12:23:23 +02:00
parent 9c6c0c655b
commit 7091be1891
8 changed files with 23 additions and 20 deletions

View File

@ -379,21 +379,21 @@ set(memgraph_src_files
)
# -----------------------------------------------------------------------------
# STATIC library used by memgraph executables
add_library(memgraph_lib STATIC ${memgraph_src_files})
target_link_libraries(memgraph_lib stdc++fs gflags)
add_dependencies(memgraph_lib generate_opencypher_parser
generate_plan_compiler_flags)
# executables that require memgraph_lib should link MEMGRAPH_ALL_LIBS to link all dependant libraries
set(MEMGRAPH_ALL_LIBS memgraph_lib stdc++fs Threads::Threads fmt yaml-cpp antlr_opencypher_parser_lib dl)
# memgraph_lib and memgraph_pic depend on these libraries
set(MEMGRAPH_ALL_LIBS gflags stdc++fs Threads::Threads fmt yaml-cpp antlr_opencypher_parser_lib dl)
if (READLINE_FOUND)
list(APPEND MEMGRAPH_ALL_LIBS ${READLINE_LIBRARY})
endif()
# -----------------------------------------------------------------------------
# STATIC library used by memgraph executables
add_library(memgraph_lib STATIC ${memgraph_src_files})
target_link_libraries(memgraph_lib ${MEMGRAPH_ALL_LIBS})
add_dependencies(memgraph_lib generate_opencypher_parser
generate_plan_compiler_flags)
# STATIC PIC library used by query engine
add_library(memgraph_pic STATIC)
target_link_libraries(memgraph_pic stdc++fs gflags)
add_library(memgraph_pic STATIC ${memgraph_src_files})
target_link_libraries(memgraph_pic ${MEMGRAPH_ALL_LIBS})
add_dependencies(memgraph_pic generate_opencypher_parser
generate_plan_compiler_flags)
set_property(TARGET memgraph_pic PROPERTY POSITION_INDEPENDENT_CODE TRUE)
@ -442,7 +442,7 @@ if (MEMGRAPH)
add_executable(${MEMGRAPH_BUILD_NAME} ${src_dir}/memgraph_bolt.cpp)
set_property(TARGET ${MEMGRAPH_BUILD_NAME}
PROPERTY CXX_STANDARD ${cxx_standard})
target_link_libraries(${MEMGRAPH_BUILD_NAME} ${MEMGRAPH_ALL_LIBS})
target_link_libraries(${MEMGRAPH_BUILD_NAME} memgraph_lib)
endif()
# utility target to copy hardcoded queries
@ -450,7 +450,7 @@ endif()
add_executable(__copy_hardcoded_queries ${src_dir}/copy_hardcoded_queries.cpp)
set_property(TARGET __copy_hardcoded_queries PROPERTY CXX_STANDARD
${cxx_standard})
target_link_libraries(__copy_hardcoded_queries ${MEMGRAPH_ALL_LIBS})
target_link_libraries(__copy_hardcoded_queries memgraph_lib)
add_custom_target(copy_hardcoded_queries ./__copy_hardcoded_queries --src
${CMAKE_SOURCE_DIR}/tests/integration/hardcoded_query --dst
${CMAKE_BINARY_DIR}/compiled/hardcode
@ -478,7 +478,7 @@ if(HARDCODED_TARGETS)
set(target_name __${file_name}_hardcoded_target)
add_executable(${target_name} ${CMAKE_SOURCE_DIR}/libs/__main.cpp
${file_path})
target_link_libraries(${target_name} ${MEMGRAPH_ALL_LIBS})
target_link_libraries(${target_name} memgraph_lib)
set_property(TARGET ${target_name} PROPERTY CXX_STANDARD ${cxx_standard})
set_target_properties(${target_name}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY

View File

@ -19,9 +19,12 @@ cd ..
# fmt
git clone https://github.com/fmtlib/fmt.git
fmt_tag="e5e4fb370ccf327bbdcdcd782eb3e53580e11094" # v3.0.0
fmt_tag="7fa8f8fa48b0903deab5bb42e6760477173ac485" # v3.0.1
# Commit which fixes an issue when compiling with C++14 and higher.
fmt_cxx14_fix="b9aaa507fc49680d037fd84c043f747a395bce04"
cd fmt
git checkout ${fmt_tag}
git cherry-pick ${fmt_cxx14_fix}
cd ..
# google benchmark

View File

@ -25,6 +25,6 @@ foreach(poc_cpp ${poc_cpps})
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
# link libraries
target_link_libraries(${target_name} ${MEMGRAPH_ALL_LIBS})
target_link_libraries(${target_name} memgraph_lib)
endforeach()

View File

@ -26,7 +26,7 @@ foreach(test_cpp ${test_type_cpps})
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
# link libraries
target_link_libraries(${target_name} ${MEMGRAPH_ALL_LIBS})
target_link_libraries(${target_name} memgraph_lib)
# google-benchmark
target_link_libraries(${target_name} benchmark ${CMAKE_THREAD_LIBS_INIT})

View File

@ -26,7 +26,7 @@ foreach(test_cpp ${test_type_cpps})
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
# link libraries
target_link_libraries(${target_name} ${MEMGRAPH_ALL_LIBS})
target_link_libraries(${target_name} memgraph_lib)
# gtest
target_link_libraries(${target_name} gtest gtest_main)

View File

@ -24,7 +24,7 @@ foreach(test_cpp ${test_type_cpps})
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
# link libraries
target_link_libraries(${target_name} ${MEMGRAPH_ALL_LIBS})
target_link_libraries(${target_name} memgraph_lib)
# register test
add_test(${target_name} ${exec_name})

View File

@ -31,6 +31,6 @@ foreach(test_cpp ${test_type_cpps})
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
# link libraries
target_link_libraries(${target_name} ${MEMGRAPH_ALL_LIBS})
target_link_libraries(${target_name} memgraph_lib)
endforeach()

View File

@ -28,7 +28,7 @@ foreach(test_cpp ${test_type_cpps})
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
# link libraries
target_link_libraries(${target_name} ${MEMGRAPH_ALL_LIBS})
target_link_libraries(${target_name} memgraph_lib)
# gtest
target_link_libraries(${target_name} gtest gtest_main gmock)
if(${TEST_COVERAGE})