Skip to content

Commit

Permalink
Separate header file dependencies for test and src.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinLeeo committed Jan 5, 2025
1 parent 854f7b7 commit 874074f
Show file tree
Hide file tree
Showing 23 changed files with 132 additions and 429 deletions.
17 changes: 4 additions & 13 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,13 @@ elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
endif()
message("CMAKE DEBUG: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")

set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
set(PROJECT_INCLUDE_DIR ${PROJECT_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/third_party/lz4
${PROJECT_SOURCE_DIR}/third_party/lzokay
${PROJECT_SOURCE_DIR}/third_party/zlib-1.2.13
${PROJECT_BINARY_DIR}/third_party/zlib-1.2.13
)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
include_directories(${PROJECT_INCLUDE_DIR})

include_directories(${PROJECT_SOURCE_DIR}/third_party/antlr4-cpp-runtime-4/runtime/src)
# All libs will store here, including libtsfile, compress-encoding lib.
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

set(PROJECT_SRC_DIR ${PROJECT_SOURCE_DIR}/src)
set(LIBRARY_INCLUDE_DIR ${PROJECT_BINARY_DIR}/include)
add_subdirectory(third_party)

add_subdirectory(src)

add_subdirectory(test)
Expand Down
21 changes: 21 additions & 0 deletions cpp/cmake/CopyToDIr.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# CopyToDir.cmake

# This function is used to copy files to a directory.
function(copy_to_dir)
set(INCLUDE_EXPORT_DR ${LIBRARY_INCLUDE_DIR} CACHE INTERNAL "Include export directory")
message(STATUS "Copying files to ${INCLUDE_EXPORT_DR}")
foreach(file ${ARGN})
get_filename_component(file_name ${file} NAME)
get_filename_component(file_path ${file} PATH)
string(REPLACE "${CMAKE_SOURCE_DIR}/src" "" relative_path "${file_path}")
add_custom_target(
copy_${file_name} ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${INCLUDE_EXPORT_DR}/${relative_path}
COMMAND ${CMAKE_COMMAND} -E copy ${file} ${INCLUDE_EXPORT_DR}/${relative_path}/${file_name}
COMMENT "Copying ${file_name} to ${INCLUDE_EXPORT_DR}/${relative_path}"
message(STATUS "Copying ${file_name} to ${INCLUDE_EXPORT_DR}/${relative_path}")
)
endforeach()
endfunction()


37 changes: 25 additions & 12 deletions cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,33 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
]]
message("Running in src diectory")
cmake_minimum_required(VERSION 3.11)
project(TsFile_CPP_SDK)

include (${CMAKE_SOURCE_DIR}/cmake/CopyToDir.cmake)

if(POLICY CMP0079)
cmake_policy(SET CMP0079 NEW)
endif()

message("Running in src directory")
if (${COV_ENABLED})
add_compile_options(-fprofile-arcs -ftest-coverage)
endif ()
add_definitions(-DANTLR4CPP_STATIC)
set(ANTLR4_WITH_STATIC_CRT OFF)


set(PROJECT_INCLUDE_DIR
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/lz4
${CMAKE_SOURCE_DIR}/third_party/lzokay
${CMAKE_SOURCE_DIR}/third_party/zlib-1.2.13
${CMAKE_SOURCE_DIR}/third_party/antlr4-cpp-runtime-4/runtime/src
)

include_directories(${PROJECT_INCLUDE_DIR})

add_subdirectory(parser)
add_subdirectory(common)
add_subdirectory(compress)
Expand All @@ -32,6 +53,7 @@ add_subdirectory(reader)
add_subdirectory(utils)
add_subdirectory(writer)


set(COMPRESSION_LIBS snappy LZ4 lzokay zlibstatic)
target_link_libraries(parser_obj antlr4_static)
target_link_libraries(compress_obj ${COMPRESSION_LIBS})
Expand All @@ -53,16 +75,7 @@ set(LIBTSFILE_SO_VERSION ${TsFile_CPP_VERSION})
set_target_properties(tsfile PROPERTIES VERSION ${LIBTSFILE_PROJECT_VERSION})
set_target_properties(tsfile PROPERTIES SOVERSION ${LIBTSFILE_SO_VERSION})

set(LIBTSFILE_SDK_DIR ${LIBRARY_OUTPUT_PATH})
install(TARGETS tsfile LIBRARY DESTINATION ${LIBTSFILE_SDK_DIR})
install(TARGETS tsfile LIBRARY DESTINATION ${LIBRARY_OUTPUT_PATH})


# set(CMAKE_PREFIX_PATH ../../third-party/lz4-dev/lib)
# set(LZ4_LIB_DIR ../../third-party/lz4-dev/lib)
# find_library(my_lz4_lib NAMES lz4 PATHS ${LZ4_LIB_DIR} NO_DEFAULT_PATH REQUIRED)
# link_directories(${LZ4_LIB_DIR})
# target_link_libraries(tsfile ${my_lz4_lib})

# if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
# add_custom_command(TARGET tsfile POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change `otool -L ${LIBRARY_OUTPUT_PATH}/libtsfile.dylib | grep liblz4 | sed 's/dylib.*/dylib/g'` ${my_lz4_lib} ${LIBRARY_OUTPUT_PATH}/libtsfile.dylib)
# add_custom_command(TARGET tsfile POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change `otool -L ${LIBRARY_OUTPUT_PATH}/libtsfile.dylib | grep libz | sed 's/dylib.*/dylib/g'` ${my_z_lib} ${LIBRARY_OUTPUT_PATH}/libtsfile.dylib)
# endif()
6 changes: 6 additions & 0 deletions cpp/src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ add_library(common_obj OBJECT ${common_SRC_LIST}
${common_mutex_SRC_LIST}
${common_datatype_SRC_LIST})

# install header files recursively
file(GLOB_RECURSE HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
copy_to_dir(${HEADERS})



110 changes: 0 additions & 110 deletions cpp/src/common/allocator/object_pool.h

This file was deleted.

2 changes: 0 additions & 2 deletions cpp/src/common/allocator/page_arena.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
#include "page_arena.h"

#include <stdio.h>

#include <new>

namespace common {
Expand Down
90 changes: 0 additions & 90 deletions cpp/src/common/allocator/stl_allocator.h

This file was deleted.

Loading

0 comments on commit 874074f

Please sign in to comment.