Merge memgraph_link_target into memgraph executable target
Summary: Memgraph's executable target is unnecessarily complicated by having a name which depends on the commit hash and build type. It is now renamed to simply 'memgraph', while the executable output uses the encoding of commit hash and build type as the name. This simplifies the dependency handling in cmake, where now the full path to the executable can be easily obtained by using the generator expression: `$<TARGET_FILE:memgraph>`. In addition to the above simplification, memgraph_link_target is now replaced with a post build step on memgraph target itself. This guarantees that the symlink always exists after building the executable, as well as simplify the make invocation. The invocation now boils down to `make memgraph` instead of `make memgraph_link_target`. Reviewers: mferencevic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1043
This commit is contained in:
parent
8d356d3f9e
commit
0d40f6a759
@ -72,34 +72,35 @@ set(VERSION_STRING ${memgraph_VERSION})
|
||||
configure_file(version.hpp.in version.hpp @ONLY)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(MEMGRAPH_BUILD_NAME "memgraph-${memgraph_VERSION}-${COMMIT_HASH}_${CMAKE_BUILD_TYPE}")
|
||||
|
||||
# memgraph main executable
|
||||
add_executable(${MEMGRAPH_BUILD_NAME} memgraph_bolt.cpp)
|
||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} memgraph_lib)
|
||||
# Output the executable in main binary dir.
|
||||
set_target_properties(${MEMGRAPH_BUILD_NAME} PROPERTIES
|
||||
add_executable(memgraph memgraph_bolt.cpp)
|
||||
target_link_libraries(memgraph memgraph_lib)
|
||||
set_target_properties(memgraph PROPERTIES
|
||||
# Set the executable output name to include version information.
|
||||
OUTPUT_NAME "memgraph-${memgraph_VERSION}-${COMMIT_HASH}_${CMAKE_BUILD_TYPE}"
|
||||
# Output the executable in main binary dir.
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
# Create symlink to the built executable.
|
||||
add_custom_command(TARGET memgraph POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:memgraph> ${CMAKE_BINARY_DIR}/memgraph
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/memgraph
|
||||
COMMENT Creating symlink to memgraph executable)
|
||||
|
||||
# Strip the executable in release build.
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} lower_build_type)
|
||||
|
||||
if (lower_build_type STREQUAL "release")
|
||||
add_custom_command(TARGET ${MEMGRAPH_BUILD_NAME} POST_BUILD
|
||||
COMMAND strip -s $<TARGET_FILE:${MEMGRAPH_BUILD_NAME}>
|
||||
COMMENT Stripping symbols and sections from
|
||||
${MEMGRAPH_BUILD_NAME})
|
||||
add_custom_command(TARGET memgraph POST_BUILD
|
||||
COMMAND strip -s $<TARGET_FILE:memgraph>
|
||||
COMMENT Stripping symbols and sections from memgraph)
|
||||
endif()
|
||||
|
||||
add_custom_target(memgraph_link_target ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:${MEMGRAPH_BUILD_NAME}> ${CMAKE_BINARY_DIR}/memgraph
|
||||
DEPENDS ${MEMGRAPH_BUILD_NAME})
|
||||
|
||||
# Everything here is under "memgraph" install component.
|
||||
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "memgraph")
|
||||
|
||||
# Install and rename executable to just 'memgraph' Since we have to rename,
|
||||
# we cannot use the recommended `install(TARGETS ...)`.
|
||||
install(PROGRAMS ${CMAKE_BINARY_DIR}/${MEMGRAPH_BUILD_NAME}
|
||||
install(PROGRAMS $<TARGET_FILE:memgraph>
|
||||
DESTINATION bin RENAME memgraph)
|
||||
# Install the config file (must use absolute path).
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/config/community.conf
|
||||
|
@ -17,7 +17,7 @@ mkdir build_release
|
||||
cd build_release
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=release ..
|
||||
TIMEOUT=1000 make -j$THREADS memgraph_link_target memgraph__macro_benchmark memgraph__stress
|
||||
TIMEOUT=1000 make -j$THREADS memgraph memgraph__macro_benchmark memgraph__stress
|
||||
|
||||
# Install tools, because they may be needed to run some benchmarks and tests.
|
||||
cd ../tools
|
||||
|
@ -21,7 +21,7 @@ mkdir build_release
|
||||
|
||||
cd build_release
|
||||
cmake -DCMAKE_BUILD_TYPE=release ..
|
||||
TIMEOUT=1000 make -j$THREADS memgraph_link_target memgraph__macro_benchmark memgraph__stress
|
||||
TIMEOUT=1000 make -j$THREADS memgraph memgraph__macro_benchmark memgraph__stress
|
||||
|
||||
cd ../../parent
|
||||
|
||||
@ -30,7 +30,7 @@ TIMEOUT=600 ./init
|
||||
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=release ..
|
||||
TIMEOUT=1000 make -j$THREADS memgraph_link_target memgraph__macro_benchmark
|
||||
TIMEOUT=1000 make -j$THREADS memgraph memgraph__macro_benchmark
|
||||
|
||||
# Install tools, because they may be needed to run some benchmarks and tests.
|
||||
cd ../../memgraph/tools
|
||||
|
Loading…
Reference in New Issue
Block a user