Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate header file dependencies for test and src. #364

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ under the License.
cmake_minimum_required(VERSION 3.11)
project(TsFile_CPP)

cmake_policy(SET CMP0079 NEW)
set(TsFile_CPP_VERSION 2.0.0.dev)
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -Wall -Werror")
message("cmake using: USE_CPP11=${USE_CPP11}")


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D__STDC_FORMAT_MACROS")

if(DEFINED ENV{CXX})
set(CMAKE_CXX_COMPILER $ENV{CXX})
Expand Down Expand Up @@ -65,24 +64,18 @@ elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
endif()
message("CMAKE DEBUG: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")


# All libs will be stored here, including libtsfile, compress-encoding lib.
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})
# TsFile code will be stored here.
set(PROJECT_SRC_DIR ${PROJECT_SOURCE_DIR}/src)

include_directories(${PROJECT_SOURCE_DIR}/third_party/antlr4-cpp-runtime-4/runtime/src)
# All include files will be installed here.
set(LIBRARY_INCLUDE_DIR ${PROJECT_BINARY_DIR}/include)

add_subdirectory(third_party)

add_subdirectory(src)

add_subdirectory(test)
if(TESTS_ENABLED)
add_dependencies(TsFile_Test tsfile)
Expand Down
38 changes: 38 additions & 0 deletions cpp/cmake/CopyToDir.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#[[
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
]]

# CopyToDir.cmake

# This function is used to copy files to a directory and it will handle relative paths automatically.
function(copy_to_dir)
set(INCLUDE_EXPORT_DR ${LIBRARY_INCLUDE_DIR} CACHE INTERNAL "Include export directory")
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_if_different ${file} ${INCLUDE_EXPORT_DR}/${relative_path}/${file_name}
COMMENT "Copying ${file_name} to ${INCLUDE_EXPORT_DR}/${relative_path}"
)
endforeach()
endfunction()


43 changes: 31 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 @@ -40,29 +62,26 @@ target_link_libraries(read_obj ${COMPRESSION_LIBS})
target_link_libraries(write_obj ${COMPRESSION_LIBS})

add_library(tsfile SHARED)
add_library(tsfile_static STATIC)
if (${COV_ENABLED})
message("Enable code cov...")
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj -lgcov)
target_link_libraries(tsfile_static common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj -lgcov)
else()
message("Disable code cov...")
target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj)
target_link_libraries(tsfile_static common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj)
endif()

set(LIBTSFILE_PROJECT_VERSION ${TsFile_CPP_VERSION})
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_target_properties(tsfile_static PROPERTIES VERSION ${LIBTSFILE_PROJECT_VERSION})
set_target_properties(tsfile_static PROPERTIES SOVERSION ${LIBTSFILE_SO_VERSION})

install(TARGETS tsfile LIBRARY DESTINATION ${LIBRARY_OUTPUT_PATH})
install(TARGETS tsfile_static LIBRARY DESTINATION ${LIBRARY_OUTPUT_PATH})

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

# 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()
3 changes: 3 additions & 0 deletions cpp/src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ 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
Loading