Skip to content

Commit

Permalink
Merge pull request #50 from ComparativeGenomicsToolkit/chop
Browse files Browse the repository at this point in the history
Fix build script
  • Loading branch information
glennhickey authored Sep 3, 2021
2 parents 0834ba8 + b8d6ab3 commit bfa3de8
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
78 changes: 78 additions & 0 deletions build-tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Specify the minimum version for CMake
cmake_minimum_required(VERSION 3.10)

# This defines default install directories like "lib"
include(GNUInstallDirs)

# Project's name
project(libhandlegraph)
# We build using c++14
set(CMAKE_CXX_STANDARD 14)

# Use all standard-compliant optimizations
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -g")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -g")

# Let cmake decide where to put the output files, allowing for out-of-tree builds.

if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
# We are probably an external project. Don't use @rpath in Mac builds'
# install_name fields (AKA LC_ID_DYLIB in otool -l output). Populate with
# an absolute path instead. This will let us actually find the library when
# we use it as a CMake external project and don't fully install it to any
# normal lib directory.
message("libhandlegraph is root project or external_project")
set (CMAKE_MACOSX_RPATH OFF)
else()
# We are probably an add_subdirectory. We will expect to be in the root
# project's lib directory, so we do want to have our non-installed
# install_name use @rpath.
message("libhandlegraph is add_subdirectory project")
set (CMAKE_MACOSX_RPATH ON)
endif()

# The install_name gets modified on installation to be this.
set (CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")

add_library(handlegraph_objs OBJECT
src/handle.cpp
src/include/handlegraph/handle_graph.hpp
src/include/handlegraph/mutable_handle_graph.hpp
src/include/handlegraph/deletable_handle_graph.hpp
src/include/handlegraph/path_handle_graph.hpp
src/include/handlegraph/path_position_handle_graph.hpp
src/include/handlegraph/mutable_path_handle_graph.hpp
src/include/handlegraph/mutable_path_mutable_handle_graph.hpp
src/include/handlegraph/mutable_path_deletable_handle_graph.hpp
src/include/handlegraph/expanding_overlay_graph.hpp
src/include/handlegraph/util.hpp
src/include/handlegraph/types.hpp
src/include/handlegraph/iteratee.hpp
)

# Use the include directory when building the objects.
# It can't be picked up via dependency by the other libraries even if it's public.
target_include_directories(handlegraph_objs PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/include")

# Build objects position-independent to allow a shared library
set_target_properties(handlegraph_objs PROPERTIES POSITION_INDEPENDENT_CODE TRUE)

# Make static and shared versions with the same base name.
# Make sure to give them interface include directories that depending targets can use.
#add_library(handlegraph_shared SHARED $<TARGET_OBJECTS:handlegraph_objs>)
#set_target_properties(handlegraph_shared PROPERTIES OUTPUT_NAME handlegraph)
#target_include_directories(handlegraph_shared INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/include")
add_library(handlegraph_static STATIC $<TARGET_OBJECTS:handlegraph_objs>)
set_target_properties(handlegraph_static PROPERTIES OUTPUT_NAME handlegraph)
target_include_directories(handlegraph_static INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/include")

# Set up for installability
#install(TARGETS handlegraph_shared handlegraph_static
install(TARGETS handlegraph_static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY src/include/handlegraph
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.hpp"
)
5 changes: 4 additions & 1 deletion build-tools/makeBinRelease
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ REL_TAG=$(getLatestReleaseTag)
git checkout "${REL_TAG}"
git submodule update --init --recursive

# todo: update / figure out / remove hack:
cp ./build-tools/CMakeLists.txt ./deps/libbdsg-easy/deps/libhandlegraph/CMakeLists.txt

if [ $(man gcc | grep nehalem | wc -l) -ge 1 ]
then
# attempt to increase portability by using older architecture
Expand All @@ -36,5 +39,5 @@ else
make check-static
fi

cp hal2vg clip-vg halRemoveDupes halMergeChroms ${buildDir}/
cp hal2vg clip-vg halRemoveDupes halMergeChroms halUnclip ${buildDir}/

0 comments on commit bfa3de8

Please sign in to comment.