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

build: support generate project with cmake 3.18 #1885

Merged
merged 2 commits into from
May 26, 2022
Merged
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
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ project(openmldb)
if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif ()

if (NOT DEFINED CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/.deps/usr")
endif()

message (STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
set(OPENMLDB_VERSION_MAJOR 0)
set(OPENMLDB_VERSION_MINOR 5)
Expand All @@ -49,7 +54,6 @@ configure_file (
"${PROJECT_SOURCE_DIR}/src/version.h.in"
"${PROJECT_SOURCE_DIR}/src/version.h"
)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_definitions('-g')
add_definitions('-Wall')
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
Expand Down Expand Up @@ -90,9 +94,9 @@ if (MAC_TABLET_ENABLE)
add_compile_definitions(__mac_tablet__=1)
endif ()

if (NOT DEFINED CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/.deps/usr)
endif()
set(SWIG_DIR ${CMAKE_PREFIX_PATH}/share/swig/4.0.1)
find_package(SWIG REQUIRED)
include(UseSWIG)

find_package(OpenSSL REQUIRED)
find_library(BRPC_LIBRARY brpc)
Expand Down Expand Up @@ -178,9 +182,6 @@ llvm_map_components_to_libnames(LLVM_LIBS support core orcjit nativecodegen)
message(STATUS "Using LLVM components: ${LLVM_LIBS}")
add_definitions(${LLVM_DEFINITIONS})

set(SWIG_DIR ${CMAKE_PREFIX_PATH}/share/swig/4.0.1)
find_package(SWIG REQUIRED)
include(UseSWIG)
find_package(absl REQUIRED)
# modify absl::time_zone INTERFACE_LINK_LIBRARIES
set_target_properties(absl::time_zone PROPERTIES INTERFACE_LINK_LIBRARIES "\$<\$<PLATFORM_ID:Darwin>:-framework CoreFoundation>")
Expand Down
16 changes: 11 additions & 5 deletions hybridse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ option(BENCHMARK_ENABLE "Enable Benchmark" OFF)
option(EXAMPLES_ENABLE "Enable examples" ON)
option(LLVM_EXT_ENABLE "Enable llvm ext sources" OFF)

set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/usr" CACHE PATH "Path prefix for finding dependencies")
if (NOT DEFINED CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH ${DEPS_PREFIX})
set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/.deps/usr")
endif()

if (CMAKE_BUILD_TYPE STREQUAL "")
Expand All @@ -62,7 +61,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(SWIG_DIR ${CMAKE_PREFIX_PATH}/share/swig/4.0.1)
# llvm dependency
if (NOT DEFINED LLVM_DIR)
set(LLVM_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/llvm")
Expand Down Expand Up @@ -162,8 +160,16 @@ set(yaml_libs yaml-cpp)

add_definitions('-g')
add_definitions(${LLVM_DEFINITIONS})
find_package(SWIG REQUIRED)
include(UseSWIG)

# parent project may already found swig, skip if so.
# the check is added because the find may failed on cmake < 3.20
if (NOT SWIG_FOUND)
set(SWIG_DIR ${CMAKE_PREFIX_PATH}/share/swig/4.0.1)
find_package(SWIG REQUIRED)
include(UseSWIG)
else()
message(STATUS "SWIG already found: ${SWIG_EXECUTABLE}:${SWIG_VERSION}")
endif()

include_directories(
${PROJECT_SOURCE_DIR}/../include
Expand Down
19 changes: 13 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include_directories(${INCLUDE_DIRECTORIES} ${PROJECT_SOURCE_DIR}/src)
include_directories(
${INCLUDE_DIRECTORIES}
${PROJECT_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/src)

add_subdirectory(statistics)

file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/proto)

set(PROTO_FILES "")
function(compile_proto proto_name project_dir)
add_custom_command(OUTPUT ${project_dir}/src/proto/${proto_name}.pb.cc
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/src/proto/${proto_name}.pb.cc
COMMAND ${Protobuf_PROTOC_EXECUTABLE} -I ${PROJECT_SOURCE_DIR}/src/proto
--cpp_out=${project_dir}/src/proto/
--cpp_out=${CMAKE_BINARY_DIR}/src/proto
--java_out=${project_dir}/java/openmldb-native/src/main/java
--java_out=${project_dir}/java/openmldb-import/src/main/java
--java_out=${project_dir}/java/openmldb-taskmanager/src/main/java
--java_out=${project_dir}/java/openmldb-common/src/main/java
${project_dir}/src/proto/${proto_name}.proto
DEPENDS ${project_dir}/src/proto/${proto_name}.proto
)
DEPENDS ${project_dir}/src/proto/${proto_name}.proto)
list(APPEND PROTO_FILES ${CMAKE_BINARY_DIR}/src/proto/${proto_name}.pb.cc)
set(PROTO_FILES ${PROTO_FILES} PARENT_SCOPE)
endfunction(compile_proto)

function(compile_lib LIB_NAME DIR DEPEND_FILE_LIST)
Expand Down Expand Up @@ -103,7 +110,7 @@ compile_lib(log log "flags.cc")
compile_lib(openmldb_sdk sdk "")
compile_lib(apiserver apiserver "")

add_library(openmldb_proto STATIC proto/type.pb.cc proto/common.pb.cc proto/tablet.pb.cc proto/name_server.pb.cc proto/sql_procedure.pb.cc proto/api_server.pb.cc proto/taskmanager.pb.cc proto/name_server.pb.cc)
add_library(openmldb_proto STATIC ${PROTO_FILES})

add_library(openmldb_flags STATIC flags.cc)

Expand Down