[go: nahoru, domu]

Skip to content

Commit

Permalink
fix divsufsort64.h copy order
Browse files Browse the repository at this point in the history
oh my god this was the worst to fix. divsufsort64.h is generated only at compiletime, so a sensible ordering of copying didn't work.
This waits until the end of the cmake script to copy that particular header to the build directory.
  • Loading branch information
Sawwave committed Feb 8, 2024
1 parent cd8ada2 commit e76b663
Showing 1 changed file with 49 additions and 13 deletions.
62 changes: 49 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build)


#PUBLIC_H_FILES is missing divsufsort64.h, because it doesn't exist until after divsufsort is built
set(
PUBLIC_H_FILES

src/AwFmIndex.h
lib/libdivsufsort/build/include/divsufsort64.h
lib/FastaVector/src/FastaVector.h
lib/FastaVector/src/FastaVectorMetadataVector.h
lib/FastaVector/src/FastaVectorString.h
Expand Down Expand Up @@ -70,27 +71,25 @@ add_library(
${C_FILES}
)

# Set public headers for awfmindex_static
set_target_properties(
awfmindex_static awfmindex
awfmindex_static
PROPERTIES
PUBLIC_HEADER "${PUBLIC_H_FILES}"
)

PROPERTIES
PUBLIC_HEADER ${PUBLIC_H_FILES}
# Set public headers for awfmindex
set_target_properties(
awfmindex
PROPERTIES
PUBLIC_HEADER "${PUBLIC_H_FILES}"
)

add_custom_target(
copy_headers
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/include/AWFMIndex
)

foreach(HEADER ${PUBLIC_H_FILES})
add_custom_command(
TARGET copy_headers
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}
${CMAKE_CURRENT_BINARY_DIR}/build
)
endforeach()


#copy the libdivsufsort and fastavector static libs to the build director
add_custom_command(
Expand Down Expand Up @@ -140,6 +139,24 @@ install(
# ------------

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/)

# Custom target for building submodules
add_custom_target(build_submodule
COMMENT "Building submodules"
)


# Custom command to copy public headers after building submodules
foreach(HEADER ${PUBLIC_H_FILES})
add_custom_command(
TARGET build_submodule # Add dependency on build_submodule
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}
${CMAKE_CURRENT_BINARY_DIR}/build
)
endforeach()

add_dependencies(awfmindex_static build_submodule)
add_dependencies(awfmindex_static copy_headers)

# FastaVector
Expand Down Expand Up @@ -169,3 +186,22 @@ target_include_directories(

target_link_libraries(awfmindex_static PRIVATE divsufsort64)
target_link_libraries(awfmindex PRIVATE divsufsort64)



# Custom target for building submodules
add_custom_target(build_divsufsort
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/lib/
COMMENT "Building submodule"
)

# Custom command to move the divsufsort64.h file after the end of the build
add_custom_command(
TARGET awfmindex_static POST_BUILD # Add dependency on build_submodule
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/lib/libdivsufsort/include/divsufsort64.h
${CMAKE_CURRENT_BINARY_DIR}/build/
)

# Add a dependency on build_submodule
add_dependencies(awfmindex_static build_divsufsort)

0 comments on commit e76b663

Please sign in to comment.