From bec7f310ebfbe47592e01ccfaea14ef099b74d24 Mon Sep 17 00:00:00 2001 From: Ivan Daschinskiy Date: Mon, 22 Jun 2020 20:47:42 +0300 Subject: [PATCH] IGNITE-13078: C++: Add CMake build system support This closes #7854 --- .gitignore | 3 + LICENSE | 6 + modules/platforms/cpp/CMakeLists.txt | 83 ++++++++++ modules/platforms/cpp/DEVNOTES.txt | 45 ++++++ modules/platforms/cpp/binary/CMakeLists.txt | 73 +++++++++ modules/platforms/cpp/cmake/FindIgnite.cmake | 45 ++++++ modules/platforms/cpp/cmake/FindODBC.cmake | 148 ++++++++++++++++++ modules/platforms/cpp/common/CMakeLists.txt | 81 ++++++++++ .../include/ignite/common/concurrent_os.h | 6 +- .../os/linux/src/common/platform_utils.cpp | 5 +- .../platforms/cpp/core-test/CMakeLists.txt | 76 +++++++++ modules/platforms/cpp/core/CMakeLists.txt | 54 +++++++ modules/platforms/cpp/examples/CMakeLists.txt | 36 +++++ .../examples/compute-example/CMakeLists.txt | 31 ++++ .../continuous-query-example/CMakeLists.txt | 31 ++++ .../cpp/examples/odbc-example/CMakeLists.txt | 33 ++++ .../examples/put-get-example/CMakeLists.txt | 31 ++++ .../cpp/examples/query-example/CMakeLists.txt | 31 ++++ .../CMakeLists.txt | 28 ++++ modules/platforms/cpp/ignite/CMakeLists.txt | 32 ++++ modules/platforms/cpp/jni/CMakeLists.txt | 43 +++++ .../platforms/cpp/jni/os/linux/src/utils.cpp | 9 ++ modules/platforms/cpp/network/CMakeLists.txt | 74 +++++++++ .../linux/src/network/tcp_socket_client.cpp | 5 +- .../network/src/network/ssl/ssl_gateway.cpp | 16 +- .../platforms/cpp/odbc-test/CMakeLists.txt | 104 ++++++++++++ modules/platforms/cpp/odbc/CMakeLists.txt | 108 +++++++++++++ .../cpp/thin-client-test/CMakeLists.txt | 36 +++++ .../platforms/cpp/thin-client/CMakeLists.txt | 48 ++++++ parent/pom.xml | 2 + 30 files changed, 1313 insertions(+), 10 deletions(-) create mode 100644 modules/platforms/cpp/CMakeLists.txt create mode 100644 modules/platforms/cpp/binary/CMakeLists.txt create mode 100644 modules/platforms/cpp/cmake/FindIgnite.cmake create mode 100644 modules/platforms/cpp/cmake/FindODBC.cmake create mode 100644 modules/platforms/cpp/common/CMakeLists.txt create mode 100644 modules/platforms/cpp/core-test/CMakeLists.txt create mode 100644 modules/platforms/cpp/core/CMakeLists.txt create mode 100644 modules/platforms/cpp/examples/CMakeLists.txt create mode 100644 modules/platforms/cpp/examples/compute-example/CMakeLists.txt create mode 100644 modules/platforms/cpp/examples/continuous-query-example/CMakeLists.txt create mode 100644 modules/platforms/cpp/examples/odbc-example/CMakeLists.txt create mode 100644 modules/platforms/cpp/examples/put-get-example/CMakeLists.txt create mode 100644 modules/platforms/cpp/examples/query-example/CMakeLists.txt create mode 100644 modules/platforms/cpp/examples/thin-client-put-get-example/CMakeLists.txt create mode 100644 modules/platforms/cpp/ignite/CMakeLists.txt create mode 100644 modules/platforms/cpp/jni/CMakeLists.txt create mode 100644 modules/platforms/cpp/network/CMakeLists.txt create mode 100644 modules/platforms/cpp/odbc-test/CMakeLists.txt create mode 100644 modules/platforms/cpp/odbc/CMakeLists.txt create mode 100644 modules/platforms/cpp/thin-client-test/CMakeLists.txt create mode 100644 modules/platforms/cpp/thin-client/CMakeLists.txt diff --git a/.gitignore b/.gitignore index cdc70655df7fe..88ffb94bc5766 100644 --- a/.gitignore +++ b/.gitignore @@ -102,6 +102,9 @@ packages /modules/platforms/cpp/stamp-h1 /modules/platforms/cpp/thin-client-test/ignite-thin-client-tests +#CMake temp files +/modules/platforms/cpp/**/cmake-build** + #Files related to ML manual-runnable tests /modules/ml/src/test/resources/manualrun/trees/columntrees.manualrun.properties diff --git a/LICENSE b/LICENSE index 6e77825327930..8ab6fe621fcb2 100644 --- a/LICENSE +++ b/LICENSE @@ -243,3 +243,9 @@ This eBook is for the use of anyone anywhere at no cost and with almost no restrictions whatsoever. You may copy it, give it away or re-use it under the terms of the Project Gutenberg License included with this eBook or online at www.gutenberg.org + +============================================================================== +For CMake script FindODBC.cmake in C++ module. +============================================================================== +This module contains modified FindODBC.cmake script from CMake distribution, +which is available under a "3-clause BSD" license. For details, see https://cmake.org/licensing. diff --git a/modules/platforms/cpp/CMakeLists.txt b/modules/platforms/cpp/CMakeLists.txt new file mode 100644 index 0000000000000..48a04960d5e2b --- /dev/null +++ b/modules/platforms/cpp/CMakeLists.txt @@ -0,0 +1,83 @@ +# +# 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 +# +# http://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. +# + +cmake_minimum_required(VERSION 3.6) +project(Ignite.C++ VERSION 2.9.0.42453) + +set(CMAKE_CXX_STANDARD 98) + +find_package(Java 1.8 REQUIRED) +find_package(JNI REQUIRED) + +set(CMAKE_PROJECT_VERSION ${PROJECT_VERSION}) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIGNITE_IMPL -DIGNITE_FRIEND -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS") + +set(CMAKE_SKIP_BUILD_RPATH FALSE) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) + +if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +endif("${isSystemDir}" STREQUAL "-1") + +if (WIN32) + add_definitions(-DUNICODE=1) + + add_compile_options(/source-charset:utf-8) +endif() + +option (WITH_ODBC OFF) +option (WITH_THIN_CLIENT OFF) +option (WITH_TESTS OFF) + +add_subdirectory(common) +add_subdirectory(binary) +add_subdirectory(jni) +add_subdirectory(core) +add_subdirectory(ignite) + +if (${WITH_TESTS}) + enable_testing() + + if (EXISTS ${CMAKE_SOURCE_DIR}/core-test) + add_subdirectory(core-test) + endif() +endif() + +if (${WITH_THIN_CLIENT} OR ${WITH_ODBC}) + add_subdirectory(network) +endif() + +if (${WITH_THIN_CLIENT}) + add_subdirectory(thin-client) + + if (${WITH_TESTS} AND EXISTS ${CMAKE_SOURCE_DIR}/thin-client-test) + add_subdirectory(thin-client-test) + endif() +endif() + +if (${WITH_ODBC}) + add_subdirectory(odbc) + + if (${WITH_TESTS} AND EXISTS ${CMAKE_SOURCE_DIR}/odbc-test) + add_subdirectory(odbc-test) + endif() +endif() diff --git a/modules/platforms/cpp/DEVNOTES.txt b/modules/platforms/cpp/DEVNOTES.txt index e39a2b73b9425..8e92d36892950 100644 --- a/modules/platforms/cpp/DEVNOTES.txt +++ b/modules/platforms/cpp/DEVNOTES.txt @@ -64,6 +64,51 @@ Ignite expects for boost libraries and header to be found under default system p it is recommended to use package repository for your OS to install boost package for the development. +Building on Linux and Mac OS X with CMake +---------------------------------- + +Common Requirements: + + * GCC, g++, CMake >= 3.6 must be installed + * Java Development Kit (JDK) must be installed: https://java.com/en/download/index.jsp + * JAVA_HOME environment variable must be set pointing to Java installation directory. + * IGNITE_HOME environment variable must be set to Ignite installation directory. + +By default building tests, ODBC and thin-client are disabled. + * OpenSSL, 1.0 or later required for building ODBC and thin-client. + * UnixODBX required for building ODBC. + * For building tests, boost framework is required. The following boost libraries are used: + * boost_unit_test_framework + * boost_thread + * boost_system + * boost_chrono + +On Mac OS X all dependencies can be installed using Homebrew. + +Building and installing the Apache Ignite C++ components: + * Navigate to the directory $IGNITE_HOME/platforms/cpp + * Execute the following commands one by one to build the project: + * mkdir cmake-build-[release|debug] + * cd ./cmake-build-[release|debug] + * cmake -DCMAKE_BUILD_TYPE=[Release|Debug] [-DCMAKE_INSTALL_PREFIX=] .. + * make + * make install + + * For building ODBC add to cmake option -DWITH_ODBC=ON + * For building thin client add to cmake option -DWITH_THIN_CLIENT=ON + * For building with tests add to cmake option -DWITH_TESTS=ON + +Running test: + * For core tests: ctest -V -R IgniteCoreTest + * For thin-client tests: ctest -V -R IgniteThinClientTest + * For ODBC tests: ctest -V -R IgniteOdbcTest + * For all tests: ctest -V + +WARNING! + * For running ODBC tests, ODBC driver must be installed in driver manager. See odbc/README.txt for details. + * On Mac OS X Homebrew doesn't create symlinks for OpenSSL, so they should be created or as alternative + OPEN_SSL_HOME should be set before running ODBC or thin-client tests. + Building on Windows with Visual Studio (tm) ---------------------------------- diff --git a/modules/platforms/cpp/binary/CMakeLists.txt b/modules/platforms/cpp/binary/CMakeLists.txt new file mode 100644 index 0000000000000..e1f5fad8a8e64 --- /dev/null +++ b/modules/platforms/cpp/binary/CMakeLists.txt @@ -0,0 +1,73 @@ +# +# 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 +# +# http://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. +# + +project(ignite-binary) + +include_directories(include) + +set(TARGET ${PROJECT_NAME}) + +set(SOURCES src/binary/binary_containers.cpp + src/binary/binary_raw_writer.cpp + src/binary/binary_writer.cpp + src/binary/binary_reader.cpp + src/binary/binary_type.cpp + src/binary/binary_raw_reader.cpp + src/impl/binary/binary_type_manager.cpp + src/impl/binary/binary_type_impl.cpp + src/impl/binary/binary_utils.cpp + src/impl/binary/binary_reader_impl.cpp + src/impl/binary/binary_type_handler.cpp + src/impl/binary/binary_writer_impl.cpp + src/impl/binary/binary_schema.cpp + src/impl/binary/binary_type_snapshot.cpp + src/impl/binary/binary_object_header.cpp + src/impl/binary/binary_object_impl.cpp + src/impl/binary/binary_field_meta.cpp + src/impl/interop/interop_memory.cpp + src/impl/interop/interop_output_stream.cpp + src/impl/interop/interop_input_stream.cpp) + +list(APPEND _target_libs ${TARGET}) + +if (WIN32) + add_library(${TARGET}-objlib OBJECT ${SOURCES}) + + add_library(${TARGET} SHARED $) + + list(APPEND _target_libs ${TARGET}-objlib) +else() + add_library(${TARGET} SHARED ${SOURCES}) +endif() + +foreach(_target_lib IN LISTS _target_libs) + set_target_properties(${_target_lib} PROPERTIES VERSION ${CMAKE_PROJECT_VERSION}) + + if (${_target_lib} STREQUAL ${TARGET}-objlib) + set_target_properties(${_target_lib} PROPERTIES POSITION_INDEPENDENT_CODE 1) + + target_link_libraries(${_target_lib} ignite-common-objlib) + else() + target_link_libraries(${_target_lib} ignite-common) + endif() + + target_include_directories(${_target_lib} INTERFACE include) +endforeach() +unset(_target_libs) + +install(TARGETS ${TARGET} LIBRARY DESTINATION lib) +install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h*") diff --git a/modules/platforms/cpp/cmake/FindIgnite.cmake b/modules/platforms/cpp/cmake/FindIgnite.cmake new file mode 100644 index 0000000000000..ffdb9e3a8c9dc --- /dev/null +++ b/modules/platforms/cpp/cmake/FindIgnite.cmake @@ -0,0 +1,45 @@ +# +# 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 +# +# http://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. +# + +find_path(IGNITE_INCLUDE_DIR ignite/ignite.h + HINTS ${IGNITE_CPP_DIR}/include + PATH_SUFFIXES ignite) + +find_library(IGNITE_LIB ignite HINTS ${IGNITE_CPP_DIR}/lib) + +find_library(IGNITE_COMMON_LIB ignite-common HINTS ${IGNITE_CPP_DIR}/lib) + +find_library(IGNITE_NETWORK_LIB ignite-network HINTS ${IGNITE_CPP_DIR}/lib) + +find_library(IGNITE_JNI_LIB ignite-jni HINTS ${IGNITE_CPP_DIR}/lib) + +find_library(IGNITE_THIN_CLIENT_LIB ignite-thin-client HINTS ${IGNITE_CPP_DIR}/lib) + +find_library(IGNITE_ODBC_LIB ignite-odbc HINTS ${IGNITE_CPP_DIR}/lib) + +find_library(IGNITE_BINARY_LIB ignite-binary HINTS ${IGNITE_CPP_DIR}/lib) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(Ignite DEFAULT_MSG + IGNITE_LIB + IGNITE_THIN_CLIENT_LIB + IGNITE_ODBC_LIB + IGNITE_BINARY_LIB + IGNITE_NETWORK_LIB + IGNITE_COMMON_LIB + IGNITE_INCLUDE_DIR) diff --git a/modules/platforms/cpp/cmake/FindODBC.cmake b/modules/platforms/cpp/cmake/FindODBC.cmake new file mode 100644 index 0000000000000..33817c8868fe4 --- /dev/null +++ b/modules/platforms/cpp/cmake/FindODBC.cmake @@ -0,0 +1,148 @@ +# Distributed under the OSI-approved BSD 3-Clause License. Contains modified code from +# CMake distribution, see https://cmake.org/licensing for details. + +# Define lists used internally +set(_odbc_include_paths) +set(_odbc_lib_paths) +set(_odbc_lib_names) +set(_odbc_required_libs_names) + +### Try Windows Kits ########################################################## +if(WIN32) + set(_odbc_lib_names odbc32;) + + # List additional libraries required to use ODBC library + if(MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") + set(_odbc_required_libs_names odbccp32;ws2_32) + elseif(MINGW) + set(_odbc_required_libs_names odbccp32) + endif() +endif() + +### Try unixODBC or iODBC config program ###################################### +if (UNIX) + find_program(ODBC_CONFIG + NAMES odbc_config iodbc-config + DOC "Path to unixODBC config program") + mark_as_advanced(ODBC_CONFIG) +endif() + +if (UNIX AND ODBC_CONFIG) + # unixODBC and iODBC accept unified command line options + execute_process(COMMAND ${ODBC_CONFIG} --cflags + OUTPUT_VARIABLE _cflags OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${ODBC_CONFIG} --libs + OUTPUT_VARIABLE _libs OUTPUT_STRIP_TRAILING_WHITESPACE) + + # Collect paths of include directories from CFLAGS + separate_arguments(_cflags UNIX_COMMAND "${_cflags}") + foreach(arg IN LISTS _cflags) + if("${arg}" MATCHES "^-I(.*)$") + list(APPEND _odbc_include_paths "${CMAKE_MATCH_1}") + endif() + endforeach() + unset(_cflags) + + # Collect paths of library names and directories from LIBS + separate_arguments(_libs UNIX_COMMAND "${_libs}") + foreach(arg IN LISTS _libs) + if("${arg}" MATCHES "^-L(.*)$") + list(APPEND _odbc_lib_paths "${CMAKE_MATCH_1}") + elseif("${arg}" MATCHES "^-l(.*)$") + set(_lib_name ${CMAKE_MATCH_1}) + string(REGEX MATCH "odbc" _is_odbc ${_lib_name}) + if(_is_odbc) + list(APPEND _odbc_lib_names ${_lib_name}) + if (${_lib_name} STREQUAL odbc) + list(APPEND _odbc_required_libs_names odbcinst) + endif() + else() + list(APPEND _odbc_required_libs_names ${_lib_name}) + endif() + unset(_lib_name) + endif() + endforeach() + unset(_libs) +endif() + +### Try unixODBC or iODBC in include/lib filesystems ########################## +if (UNIX AND NOT ODBC_CONFIG) + # List names of both ODBC libraries and unixODBC + set(_odbc_lib_names odbc;odbcinst;iodbc;unixodbc;) +endif() + +### Find include directories ################################################## +find_path(ODBC_INCLUDE_DIR + NAMES sql.h + PATHS ${_odbc_include_paths}) + +if(NOT ODBC_INCLUDE_DIR AND WIN32) + set(ODBC_INCLUDE_DIR "") +endif() + +### Find libraries ############################################################ +if(NOT ODBC_LIBRARY) + find_library(ODBC_LIBRARY + NAMES ${_odbc_lib_names} + PATHS ${_odbc_lib_paths} + PATH_SUFFIXES odbc) + + foreach(_lib IN LISTS _odbc_required_libs_names) + find_library(_lib_path + NAMES ${_lib} + PATHS ${_odbc_lib_paths} # system paths or collected from ODBC_CONFIG + PATH_SUFFIXES odbc) + if(_lib_path) + list(APPEND _odbc_required_libs_paths ${_lib_path}) + endif() + unset(_lib_path CACHE) + endforeach() +endif() + +# Unset internal lists as no longer used +unset(_odbc_include_paths) +unset(_odbc_lib_paths) +unset(_odbc_lib_names) +unset(_odbc_required_libs_names) + +### Set result variables ###################################################### +set(_odbc_required_vars ODBC_LIBRARY) +if(NOT WIN32) + list(APPEND _odbc_required_vars ODBC_INCLUDE_DIR) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ODBC DEFAULT_MSG ${_odbc_required_vars}) + +unset(_odbc_required_vars) + +mark_as_advanced(ODBC_LIBRARY ODBC_INCLUDE_DIR) + +set(ODBC_INCLUDE_DIRS ${ODBC_INCLUDE_DIR}) +list(APPEND ODBC_LIBRARIES ${ODBC_LIBRARY}) +list(APPEND ODBC_LIBRARIES ${_odbc_required_libs_paths}) + +### Import targets ############################################################ +if(ODBC_FOUND) + if(NOT TARGET ODBC::ODBC) + if(IS_ABSOLUTE "${ODBC_LIBRARY}") + add_library(ODBC::ODBC UNKNOWN IMPORTED) + set_target_properties(ODBC::ODBC PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${ODBC_LIBRARY}") + else() + add_library(ODBC::ODBC INTERFACE IMPORTED) + set_target_properties(ODBC::ODBC PROPERTIES + IMPORTED_LIBNAME "${ODBC_LIBRARY}") + endif() + set_target_properties(ODBC::ODBC PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ODBC_INCLUDE_DIR}") + + if(_odbc_required_libs_paths) + set_property(TARGET ODBC::ODBC APPEND PROPERTY + INTERFACE_LINK_LIBRARIES "${_odbc_required_libs_paths}") + endif() + endif() +endif() + +unset(_odbc_required_libs_paths) diff --git a/modules/platforms/cpp/common/CMakeLists.txt b/modules/platforms/cpp/common/CMakeLists.txt new file mode 100644 index 0000000000000..7ea06389880c9 --- /dev/null +++ b/modules/platforms/cpp/common/CMakeLists.txt @@ -0,0 +1,81 @@ +# +# 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 +# +# http://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. +# + +project(ignite-common) + +include_directories(include) + +set(TARGET ${PROJECT_NAME}) + +set(SOURCES src/common/big_integer.cpp + src/common/bits.cpp + src/common/concurrent.cpp + src/common/decimal.cpp + src/common/utils.cpp + src/date.cpp + src/ignite_error.cpp + src/guid.cpp + src/timestamp.cpp + src/time.cpp) + +if (WIN32) + set(OS_INCLUDE os/win/include) + + list(APPEND SOURCES os/win/src/common/concurrent_os.cpp + os/win/src/common/platform_utils.cpp + os/win/src/common/dynamic_load_os.cpp) +else() + set(OS_INCLUDE os/linux/include) + + list(APPEND SOURCES os/linux/src/common/concurrent_os.cpp + os/linux/src/common/platform_utils.cpp + os/linux/src/common/dynamic_load_os.cpp) +endif() + +include_directories(${OS_INCLUDE}) + +list(APPEND _target_libs ${TARGET}) + +if (WIN32) + add_library(${TARGET}-objlib OBJECT ${SOURCES}) + + add_library(${TARGET} SHARED $) + + list(APPEND _target_libs ${TARGET}-objlib) +else() + add_library(${TARGET} SHARED ${SOURCES}) +endif() + +foreach(_target_lib IN LISTS _target_libs) + set_target_properties(${_target_lib} PROPERTIES VERSION ${CMAKE_PROJECT_VERSION}) + + if (${_target_lib} STREQUAL ${TARGET}-objlib) + set_target_properties(${_target_lib} PROPERTIES POSITION_INDEPENDENT_CODE 1) + endif() + + if (NOT WIN32) + find_package(Threads REQUIRED) + + target_link_libraries(${_target_lib} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) + endif() + + target_include_directories(${_target_lib} INTERFACE include ${OS_INCLUDE}) +endforeach() +unset(_target_libs) + +install(TARGETS ${TARGET} LIBRARY DESTINATION lib) +install(DIRECTORY include/ ${OS_INCLUDE}/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h*") diff --git a/modules/platforms/cpp/common/os/linux/include/ignite/common/concurrent_os.h b/modules/platforms/cpp/common/os/linux/include/ignite/common/concurrent_os.h index 3c588ffdfb602..5b84701f5c37b 100644 --- a/modules/platforms/cpp/common/os/linux/include/ignite/common/concurrent_os.h +++ b/modules/platforms/cpp/common/os/linux/include/ignite/common/concurrent_os.h @@ -451,9 +451,10 @@ namespace ignite int err = pthread_condattr_init(&attr); assert(!err); +#if !defined(__APPLE__) err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); assert(!err); - +#endif err = pthread_cond_init(&cond, &attr); assert(!err); } @@ -541,9 +542,10 @@ namespace ignite pthread_condattr_t attr; int err = pthread_condattr_init(&attr); assert(!err); - +#if !defined(__APPLE__) err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); assert(!err); +#endif err = pthread_cond_init(&cond, &attr); assert(!err); diff --git a/modules/platforms/cpp/common/os/linux/src/common/platform_utils.cpp b/modules/platforms/cpp/common/os/linux/src/common/platform_utils.cpp index cc8970f74ed9e..4417db0c01990 100644 --- a/modules/platforms/cpp/common/os/linux/src/common/platform_utils.cpp +++ b/modules/platforms/cpp/common/os/linux/src/common/platform_utils.cpp @@ -114,8 +114,11 @@ namespace ignite StdCharOutStream& Dle(StdCharOutStream& ostr) { +#ifdef __APPLE__ + static const char expansion[] = ".dylib"; +#else static const char expansion[] = ".so"; - +#endif ostr.write(expansion, sizeof(expansion) - 1); return ostr; diff --git a/modules/platforms/cpp/core-test/CMakeLists.txt b/modules/platforms/cpp/core-test/CMakeLists.txt new file mode 100644 index 0000000000000..ba24021532622 --- /dev/null +++ b/modules/platforms/cpp/core-test/CMakeLists.txt @@ -0,0 +1,76 @@ +# +# 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 +# +# http://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. +# + +project(ignite-tests) + +set(TARGET ${PROJECT_NAME}) + +find_package(Boost 1.53 REQUIRED COMPONENTS unit_test_framework chrono thread system) + +if (WIN32) + set(Boost_USE_STATIC_LIBS ON) +endif() + +include_directories(include ${Boost_INCLUDE_DIRS} ${JNI_INCLUDE_DIRS}) + +set(SOURCES src/reference_test.cpp + src/bits_test.cpp + src/binary_identity_resolver_test.cpp + src/cache_test.cpp + src/cache_query_test.cpp + src/cache_store_test.cpp + src/continuous_query_test.cpp + src/concurrent_test.cpp + src/compute_test.cpp + src/ignition_test.cpp + src/interop_memory_test.cpp + src/interop_test.cpp + src/cluster_test.cpp + src/cache_invoke_test.cpp + src/handle_registry_test.cpp + src/ignite_error_test.cpp + src/binary_test_defs.cpp + src/binary_object_test.cpp + src/binary_reader_writer_raw_test.cpp + src/binary_reader_writer_test.cpp + src/binary_session_test.cpp + src/date_time_test.cpp + src/decimal_test.cpp + src/dynamic_size_array_test.cpp + src/fixed_size_array_test.cpp + src/future_test.cpp + src/transactions_test.cpp + src/teamcity_messages.cpp + src/teamcity_boost.cpp + src/test_utils.cpp) + +add_executable(${TARGET} ${SOURCES}) + +target_link_libraries(${TARGET} ignite ${Boost_LIBRARIES}) + +if (NOT WIN32) + add_definitions(-DBOOST_TEST_DYN_LINK) + + target_link_libraries(${TARGET} -rdynamic) +endif() + +set(TEST_TARGET IgniteCoreTest) + +add_test(NAME ${TEST_TARGET} COMMAND ${TARGET} --catch_system_errors=no --log_level=all) + +set_tests_properties(${TEST_TARGET} PROPERTIES ENVIRONMENT + IGNITE_NATIVE_TEST_CPP_CONFIG_PATH=${PROJECT_SOURCE_DIR}/config) diff --git a/modules/platforms/cpp/core/CMakeLists.txt b/modules/platforms/cpp/core/CMakeLists.txt new file mode 100644 index 0000000000000..e84a8bb43eb65 --- /dev/null +++ b/modules/platforms/cpp/core/CMakeLists.txt @@ -0,0 +1,54 @@ +# +# 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 +# +# http://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. +# + +project(ignite) + +include_directories(${JNI_INCLUDE_DIRS} include) + +set(TARGET ${PROJECT_NAME}) + +set(SOURCES src/ignite.cpp + src/ignition.cpp + src/impl/ignite_environment.cpp + src/impl/binary/binary_type_updater_impl.cpp + src/impl/handle_registry.cpp + src/impl/cache/query/continuous/continuous_query_handle_impl.cpp + src/impl/cache/query/query_impl.cpp + src/impl/cache/cache_impl.cpp + src/impl/cache/query/query_batch.cpp + src/impl/interop/interop_external_memory.cpp + src/impl/interop/interop_target.cpp + src/impl/transactions/transaction_impl.cpp + src/impl/transactions/transactions_impl.cpp + src/impl/cluster/cluster_group_impl.cpp + src/impl/compute/cancelable_impl.cpp + src/impl/compute/compute_impl.cpp + src/impl/ignite_impl.cpp + src/impl/ignite_binding_impl.cpp + src/transactions/transaction.cpp + src/transactions/transactions.cpp) + +add_library(${TARGET} SHARED ${SOURCES}) + +set_target_properties(${TARGET} PROPERTIES VERSION ${CMAKE_PROJECT_VERSION}) + +target_link_libraries(${TARGET} ignite-binary ignite-jni) + +target_include_directories(${TARGET} INTERFACE include) + +install(TARGETS ${TARGET} LIBRARY DESTINATION lib) +install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h*") diff --git a/modules/platforms/cpp/examples/CMakeLists.txt b/modules/platforms/cpp/examples/CMakeLists.txt new file mode 100644 index 0000000000000..380eb8a0eb811 --- /dev/null +++ b/modules/platforms/cpp/examples/CMakeLists.txt @@ -0,0 +1,36 @@ +# +# 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 +# +# http://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. +# + +cmake_minimum_required(VERSION 3.6) +project(examples) + +set(CMAKE_CXX_STANDARD 98) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../cmake") + +if (WIN32) + add_definitions(-DUNICODE=1) + + add_compile_options(/source-charset:utf-8) +endif() + +add_subdirectory(compute-example) +add_subdirectory(continuous-query-example) +add_subdirectory(odbc-example) +add_subdirectory(put-get-example) +add_subdirectory(query-example) +add_subdirectory(thin-client-put-get-example) diff --git a/modules/platforms/cpp/examples/compute-example/CMakeLists.txt b/modules/platforms/cpp/examples/compute-example/CMakeLists.txt new file mode 100644 index 0000000000000..315477b988b34 --- /dev/null +++ b/modules/platforms/cpp/examples/compute-example/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# 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 +# +# http://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. +# + +project(compute-example) + +set(TARGET ignite-${PROJECT_NAME}) + +find_package(Ignite) +find_package(Threads) +find_package(Java 1.8 REQUIRED) +find_package(JNI REQUIRED) + +include_directories(../include ${IGNITE_INCLUDE_DIR} ${JNI_INCLUDE_DIRS}) + +add_executable(${TARGET} src/compute_example.cpp) + +target_link_libraries(${TARGET} ${IGNITE_LIB} ${IGNITE_BINARY_LIB} ${IGNITE_COMMON_LIB} ${CMAKE_THREAD_LIBS_INIT}) diff --git a/modules/platforms/cpp/examples/continuous-query-example/CMakeLists.txt b/modules/platforms/cpp/examples/continuous-query-example/CMakeLists.txt new file mode 100644 index 0000000000000..e67ec895662ed --- /dev/null +++ b/modules/platforms/cpp/examples/continuous-query-example/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# 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 +# +# http://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. +# + +project(continuous-query-example) + +set(TARGET ignite-${PROJECT_NAME}) + +find_package(Ignite) +find_package(Threads) +find_package(Java 1.8 REQUIRED) +find_package(JNI REQUIRED) + +include_directories(../include ${IGNITE_INCLUDE_DIR} ${JNI_INCLUDE_DIRS}) + +add_executable(${TARGET} src/continuous_query_example.cpp) + +target_link_libraries(${TARGET} ${IGNITE_LIB} ${IGNITE_BINARY_LIB} ${IGNITE_COMMON_LIB} ${CMAKE_THREAD_LIBS_INIT}) diff --git a/modules/platforms/cpp/examples/odbc-example/CMakeLists.txt b/modules/platforms/cpp/examples/odbc-example/CMakeLists.txt new file mode 100644 index 0000000000000..6fd613886d0c9 --- /dev/null +++ b/modules/platforms/cpp/examples/odbc-example/CMakeLists.txt @@ -0,0 +1,33 @@ +# +# 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 +# +# http://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. +# + +project(odbc-example) + +set(TARGET ignite-${PROJECT_NAME}) + +find_package(Ignite) +find_package(Threads) +find_package(Java 1.8 REQUIRED) +find_package(JNI REQUIRED) +find_package(ODBC REQUIRED) + +include_directories(../include ${IGNITE_INCLUDE_DIR} ${JNI_INCLUDE_DIRS}) + +add_executable(${TARGET} src/odbc_example.cpp) + +target_link_libraries(${TARGET} ${IGNITE_LIB} ${IGNITE_BINARY_LIB} ${IGNITE_COMMON_LIB} ${ODBC_LIBRARY} + ${CMAKE_THREAD_LIBS_INIT}) diff --git a/modules/platforms/cpp/examples/put-get-example/CMakeLists.txt b/modules/platforms/cpp/examples/put-get-example/CMakeLists.txt new file mode 100644 index 0000000000000..0f3e8b20a2ba5 --- /dev/null +++ b/modules/platforms/cpp/examples/put-get-example/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# 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 +# +# http://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. +# + +project(put-get-example) + +set(TARGET ignite-${PROJECT_NAME}) + +find_package(Ignite) +find_package(Threads) +find_package(Java 1.8 REQUIRED) +find_package(JNI REQUIRED) + +include_directories(../include ${IGNITE_INCLUDE_DIR} ${JNI_INCLUDE_DIRS}) + +add_executable(${TARGET} src/put_get_example.cpp) + +target_link_libraries(${TARGET} ${IGNITE_LIB} ${IGNITE_BINARY_LIB} ${IGNITE_COMMON_LIB} ${CMAKE_THREAD_LIBS_INIT}) diff --git a/modules/platforms/cpp/examples/query-example/CMakeLists.txt b/modules/platforms/cpp/examples/query-example/CMakeLists.txt new file mode 100644 index 0000000000000..c2df0e349a714 --- /dev/null +++ b/modules/platforms/cpp/examples/query-example/CMakeLists.txt @@ -0,0 +1,31 @@ +# +# 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 +# +# http://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. +# + +project(query-example) + +set(TARGET ignite-${PROJECT_NAME}) + +find_package(Ignite) +find_package(Threads) +find_package(Java 1.8 REQUIRED) +find_package(JNI REQUIRED) + +include_directories(../include ${IGNITE_INCLUDE_DIR} ${JNI_INCLUDE_DIRS}) + +add_executable(${TARGET} src/query_example.cpp) + +target_link_libraries(${TARGET} ${IGNITE_LIB} ${IGNITE_BINARY_LIB} ${IGNITE_COMMON_LIB} ${CMAKE_THREAD_LIBS_INIT}) diff --git a/modules/platforms/cpp/examples/thin-client-put-get-example/CMakeLists.txt b/modules/platforms/cpp/examples/thin-client-put-get-example/CMakeLists.txt new file mode 100644 index 0000000000000..7a00a349ee92c --- /dev/null +++ b/modules/platforms/cpp/examples/thin-client-put-get-example/CMakeLists.txt @@ -0,0 +1,28 @@ +# +# 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 +# +# http://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. +# + +project(thin-client-put-get-example) + +set(TARGET ignite-${PROJECT_NAME}) + +find_package(Ignite) + +include_directories(../include ${IGNITE_INCLUDE_DIR}) + +add_executable(${TARGET} src/thin_client_put_get_example.cpp) + +target_link_libraries(${TARGET} ${IGNITE_THIN_CLIENT_LIB} ${IGNITE_BINARY_LIB} ${IGNITE_COMMON_LIB}) diff --git a/modules/platforms/cpp/ignite/CMakeLists.txt b/modules/platforms/cpp/ignite/CMakeLists.txt new file mode 100644 index 0000000000000..1ffefafda04ed --- /dev/null +++ b/modules/platforms/cpp/ignite/CMakeLists.txt @@ -0,0 +1,32 @@ +# +# 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 +# +# http://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. +# + +project(ignite-bin) + +set(TARGET ignite-bin) + +include_directories(${JNI_INCLUDE_DIRS}) + +set(SOURCES src/ignite.cpp) + +add_executable(${TARGET} ${SOURCES}) + +target_link_libraries(${TARGET} ignite) + +set_target_properties(ignite-bin PROPERTIES OUTPUT_NAME ignite) + +install(TARGETS ${TARGET} RUNTIME DESTINATION bin) diff --git a/modules/platforms/cpp/jni/CMakeLists.txt b/modules/platforms/cpp/jni/CMakeLists.txt new file mode 100644 index 0000000000000..75f83f69af249 --- /dev/null +++ b/modules/platforms/cpp/jni/CMakeLists.txt @@ -0,0 +1,43 @@ +# +# 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 +# +# http://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. +# + +project(ignite-jni) + +set(TARGET ${PROJECT_NAME}) + +find_library(JVM_LIBRARY jvm ${JAVA_JVM_LIBRARY_DIRECTORIES}) + +include_directories(${JNI_INCLUDE_DIRS} include) + +set(SOURCES src/java.cpp src/exports.cpp) + +if (WIN32) + list(APPEND SOURCES os/win/src/utils.cpp) +else() + list(APPEND SOURCES os/linux/src/utils.cpp) +endif () + +add_library(${TARGET} SHARED ${SOURCES}) + +set_target_properties(${TARGET} PROPERTIES VERSION ${CMAKE_PROJECT_VERSION}) + +target_link_libraries(${TARGET} ignite-common ${JVM_LIBRARY}) + +target_include_directories(${TARGET} INTERFACE include) + +install(TARGETS ${TARGET} LIBRARY DESTINATION lib) +install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h*") diff --git a/modules/platforms/cpp/jni/os/linux/src/utils.cpp b/modules/platforms/cpp/jni/os/linux/src/utils.cpp index 0fda52dbed061..1fcdb317d27d4 100644 --- a/modules/platforms/cpp/jni/os/linux/src/utils.cpp +++ b/modules/platforms/cpp/jni/os/linux/src/utils.cpp @@ -39,6 +39,7 @@ namespace ignite const char* JAVA_HOME = "JAVA_HOME"; const char* JAVA_DLL1 = "/jre/lib/amd64/server/libjvm.so"; const char* JAVA_DLL2 = "/lib/server/libjvm.so"; + const char* JAVA_DLL_DARWIN = "libjvm.dylib"; const char* IGNITE_HOME = "IGNITE_HOME"; @@ -304,6 +305,9 @@ namespace ignite std::string FindJvmLibrary(const std::string& path) { +#ifdef __APPLE__ + return JAVA_DLL_DARWIN; +#else // If path is provided explicitly, then check only it. if (!path.empty() && FileExists(path)) return path; @@ -324,13 +328,18 @@ namespace ignite } return std::string(); +#endif } bool LoadJvmLibrary(const std::string& path) { +#ifdef __APPLE__ + return RTLD_DEFAULT; +#else void* hnd = dlopen(path.c_str(), RTLD_LAZY); return hnd != NULL; +#endif } /** diff --git a/modules/platforms/cpp/network/CMakeLists.txt b/modules/platforms/cpp/network/CMakeLists.txt new file mode 100644 index 0000000000000..d450f7dc3c9a3 --- /dev/null +++ b/modules/platforms/cpp/network/CMakeLists.txt @@ -0,0 +1,74 @@ +# +# 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 +# +# http://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. +# + +project(ignite-network) + +set(TARGET ${PROJECT_NAME}) + +find_package(OpenSSL REQUIRED) + +include_directories(include src ${OPENSSL_INCLUDE_DIR}) + +set(SOURCES src/network/network.cpp + src/network/ssl/secure_socket_client.cpp + src/network/ssl/ssl_gateway.cpp) + +if (WIN32) + include_directories(os/win/src) + + list(APPEND SOURCES os/win/src/network/tcp_socket_client.cpp + os/win/src/network/sockets.cpp + os/win/src/network/utils.cpp) +else() + include_directories(os/linux/src) + + list(APPEND SOURCES os/linux/src/network/tcp_socket_client.cpp + os/linux/src/network/sockets.cpp + os/linux/src/network/utils.cpp) +endif() + +list(APPEND _target_libs ${TARGET}) +if (WIN32) + add_library(${TARGET}-objlib OBJECT ${SOURCES}) + add_library(${TARGET} SHARED $) + + list(APPEND _target_libs ${TARGET}-objlib) +else() + add_library(${TARGET} SHARED ${SOURCES}) +endif() + +foreach(_target_lib IN LISTS _target_libs) + set_target_properties(${_target_lib} PROPERTIES VERSION ${CMAKE_PROJECT_VERSION}) + + if (${_target_lib} STREQUAL ${TARGET}-objlib) + set_target_properties(${_target_lib} PROPERTIES POSITION_INDEPENDENT_CODE 1) + + target_link_libraries(${_target_lib} ignite-common-objlib) + else() + target_link_libraries(${_target_lib} ignite-common) + endif() + + if (WIN32) + target_link_libraries(${_target_lib} wsock32 ws2_32 iphlpapi) + endif() + + target_include_directories(${_target_lib} INTERFACE include ${OS_INCLUDE}) +endforeach() +unset(_target_libs) + +install(TARGETS ${TARGET} LIBRARY DESTINATION lib) +install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h*") diff --git a/modules/platforms/cpp/network/os/linux/src/network/tcp_socket_client.cpp b/modules/platforms/cpp/network/os/linux/src/network/tcp_socket_client.cpp index e6fff91ae5c13..0ad5d9590d45c 100644 --- a/modules/platforms/cpp/network/os/linux/src/network/tcp_socket_client.cpp +++ b/modules/platforms/cpp/network/os/linux/src/network/tcp_socket_client.cpp @@ -206,8 +206,11 @@ namespace ignite // There is no sense in configuring keep alive params if we faileed to set up keep alive mode. return; } - +#ifdef __APPLE__ + setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPALIVE, reinterpret_cast(&idleOpt), sizeof(idleOpt)); +#else setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPIDLE, reinterpret_cast(&idleOpt), sizeof(idleOpt)); +#endif setsockopt(socketHandle, IPPROTO_TCP, TCP_KEEPINTVL, reinterpret_cast(&idleRetryOpt), sizeof(idleRetryOpt)); diff --git a/modules/platforms/cpp/network/src/network/ssl/ssl_gateway.cpp b/modules/platforms/cpp/network/src/network/ssl/ssl_gateway.cpp index e3139c1ee5305..94eea36d2fb8f 100644 --- a/modules/platforms/cpp/network/src/network/ssl/ssl_gateway.cpp +++ b/modules/platforms/cpp/network/src/network/ssl/ssl_gateway.cpp @@ -80,16 +80,20 @@ namespace ignite if (!home.empty()) { - std::stringstream constructor; + const char* paths[] = {"bin", "lib"}; - constructor << home << Fs << "bin" << Fs << fullName; + for (size_t i = 0; i < 2; i++) { + std::stringstream constructor; - std::string fullPath = constructor.str(); + constructor << home << Fs << paths[i] << Fs << fullName; - Module mod = LoadModule(fullPath); + std::string fullPath = constructor.str(); - if (mod.IsLoaded()) - return mod; + Module mod = LoadModule(fullPath); + + if (mod.IsLoaded()) + return mod; + } } return LoadModule(fullName); diff --git a/modules/platforms/cpp/odbc-test/CMakeLists.txt b/modules/platforms/cpp/odbc-test/CMakeLists.txt new file mode 100644 index 0000000000000..72e27e26cac8b --- /dev/null +++ b/modules/platforms/cpp/odbc-test/CMakeLists.txt @@ -0,0 +1,104 @@ +# +# 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 +# +# http://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. +# + +project(ignite-odbc-tests) + +set(TARGET ${PROJECT_NAME}) + +find_package(Boost 1.53 REQUIRED COMPONENTS unit_test_framework chrono thread system regex) + +if (WIN32) + set(Boost_USE_STATIC_LIBS ON) +endif() + +find_package(ODBC REQUIRED) + +include_directories(include ../odbc/include ../network/include ${ODBC_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${JNI_INCLUDE_DIRS}) + +set(SOURCES src/teamcity/teamcity_boost.cpp + src/teamcity/teamcity_messages.cpp + src/parser_test.cpp + src/cursor_test.cpp + src/connection_info_test.cpp + src/connection_test.cpp + src/application_data_buffer_test.cpp + src/column_test.cpp + src/configuration_test.cpp + src/row_test.cpp + src/meta_queries_test.cpp + src/utility_test.cpp + src/queries_test.cpp + src/queries_ssl_test.cpp + src/test_utils.cpp + src/sql_test_suite_fixture.cpp + src/sql_string_functions_test.cpp + src/sql_numeric_functions_test.cpp + src/sql_aggregate_functions_test.cpp + src/sql_system_functions_test.cpp + src/sql_esc_convert_function_test.cpp + src/sql_operators_test.cpp + src/sql_value_expressions_test.cpp + src/sql_types_test.cpp + src/sql_date_time_functions_test.cpp + src/sql_outer_join_test.cpp + src/sql_get_info_test.cpp + src/api_robustness_test.cpp + src/attributes_test.cpp + src/errors_test.cpp + src/odbc_test_suite.cpp + src/types_test.cpp + src/transaction_test.cpp + src/authentication_test.cpp + src/sql_parsing_test.cpp + src/streaming_test.cpp + ../odbc/src/log.cpp + ../odbc/src/cursor.cpp + ../odbc/src/diagnostic/diagnostic_record.cpp + ../odbc/src/diagnostic/diagnostic_record_storage.cpp + ../odbc/src/config/config_tools.cpp + ../odbc/src/config/configuration.cpp + ../odbc/src/config/connection_info.cpp + ../odbc/src/config/connection_string_parser.cpp + ../odbc/src/app/application_data_buffer.cpp + ../odbc/src/ssl_mode.cpp + ../odbc/src/sql/sql_parser.cpp + ../odbc/src/sql/sql_lexer.cpp + ../odbc/src/sql/sql_set_streaming_command.cpp + ../odbc/src/sql/sql_utils.cpp + ../odbc/src/row.cpp + ../odbc/src/protocol_version.cpp + ../odbc/src/column.cpp + ../odbc/src/common_types.cpp + ../odbc/src/utility.cpp + ../odbc/src/result_page.cpp + ../odbc/src/nested_tx_mode.cpp) + +add_executable(${TARGET} ${SOURCES}) + +target_link_libraries(${TARGET} ${Boost_LIBRARIES} ignite ${ODBC_LIBRARY}) + +if (WIN32) + remove_definitions(-DUNICODE=1) +else() + add_definitions(-DBOOST_TEST_DYN_LINK) +endif() + +set(TEST_TARGET IgniteOdbcTest) + +add_test(NAME ${TEST_TARGET} COMMAND ${TARGET} --catch_system_errors=no --log_level=all) + +set_tests_properties(${TEST_TARGET} PROPERTIES ENVIRONMENT IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH=${PROJECT_SOURCE_DIR}/config) diff --git a/modules/platforms/cpp/odbc/CMakeLists.txt b/modules/platforms/cpp/odbc/CMakeLists.txt new file mode 100644 index 0000000000000..5cbd99c2d913d --- /dev/null +++ b/modules/platforms/cpp/odbc/CMakeLists.txt @@ -0,0 +1,108 @@ +# +# 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 +# +# http://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. +# + +project(ignite-odbc) + +set(TARGET ${PROJECT_NAME}) + +find_package(ODBC REQUIRED) + +include_directories(include ${ODBC_INCLUDE_DIRS}) + +set(SOURCES src/app/application_data_buffer.cpp + src/app/parameter.cpp + src/app/parameter_set.cpp + src/common_types.cpp + src/config/config_tools.cpp + src/config/configuration.cpp + src/config/connection_info.cpp + src/config/connection_string_parser.cpp + src/connection.cpp + src/cursor.cpp + src/diagnostic/diagnosable_adapter.cpp + src/diagnostic/diagnostic_record.cpp + src/diagnostic/diagnostic_record_storage.cpp + src/environment.cpp + src/meta/column_meta.cpp + src/meta/table_meta.cpp + src/odbc.cpp + src/entry_points.cpp + src/dsn_config.cpp + src/query/column_metadata_query.cpp + src/query/data_query.cpp + src/query/batch_query.cpp + src/query/foreign_keys_query.cpp + src/query/primary_keys_query.cpp + src/query/table_metadata_query.cpp + src/query/type_info_query.cpp + src/query/special_columns_query.cpp + src/query/streaming_query.cpp + src/sql/sql_parser.cpp + src/sql/sql_lexer.cpp + src/sql/sql_set_streaming_command.cpp + src/sql/sql_utils.cpp + src/streaming/streaming_batch.cpp + src/streaming/streaming_context.cpp + src/ssl_mode.cpp + src/protocol_version.cpp + src/result_page.cpp + src/row.cpp + src/nested_tx_mode.cpp + src/message.cpp + src/column.cpp + src/statement.cpp + src/type_traits.cpp + src/utility.cpp + src/log.cpp) + +if (WIN32) + include_directories(os/win/include) + + list(APPEND SOURCES os/win/src/system_dsn.cpp + os/win/src/system/ui/custom_window.cpp + os/win/src/system/ui/dsn_configuration_window.cpp + os/win/src/system/ui/window.cpp) +endif () + +add_library(${TARGET} SHARED ${SOURCES}) + +set_target_properties(${TARGET} PROPERTIES VERSION ${CMAKE_PROJECT_VERSION}) + +target_link_libraries(${TARGET} ${ODBC_LIBRARIES}) + +if (WIN32) + target_link_libraries(${TARGET} ignite-common-objlib ignite-binary-objlib ignite-network-objlib shlwapi) + + remove_definitions(-DUNICODE=1) + + add_definitions(-DTARGET_MODULE_FULL_NAME="${TARGET}") + + if (MSVC_VERSION GREATER_EQUAL 1900) + target_link_libraries(${TARGET} legacy_stdio_definitions) + endif() +else() + target_link_libraries(${TARGET} ignite-common ignite-binary ignite-network) +endif() + +target_include_directories(${TARGET} INTERFACE include) + +install(TARGETS ${TARGET} LIBRARY DESTINATION lib) +install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h*") + +if (WIN32) + install(DIRECTORY os/win/include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h*") +endif() diff --git a/modules/platforms/cpp/thin-client-test/CMakeLists.txt b/modules/platforms/cpp/thin-client-test/CMakeLists.txt new file mode 100644 index 0000000000000..381220b79c558 --- /dev/null +++ b/modules/platforms/cpp/thin-client-test/CMakeLists.txt @@ -0,0 +1,36 @@ +project(ignite-thin-client-tests) + +set(TARGET ${PROJECT_NAME}) + +if (WIN32) + set(Boost_USE_STATIC_LIBS ON) +endif() + +find_package(Boost 1.53 REQUIRED COMPONENTS unit_test_framework chrono thread system) + +include_directories(include ${Boost_INCLUDE_DIRS} ${JNI_INCLUDE_DIRS}) + +set(SOURCES src/teamcity/teamcity_boost.cpp + src/teamcity/teamcity_messages.cpp + src/cache_client_test.cpp + src/test_utils.cpp + src/ignite_client_test.cpp + src/auth_test.cpp + src/ssl_test.cpp) + +add_executable(${TARGET} ${SOURCES}) + +target_link_libraries(${TARGET} ignite-thin-client ignite ${Boost_LIBRARIES}) + +if (NOT WIN32) + add_definitions(-DBOOST_TEST_DYN_LINK) + + target_link_libraries(${TARGET} -rdynamic) +endif() + +set(TEST_TARGET IgniteThinClientTest) + +add_test(NAME ${TEST_TARGET} COMMAND ${TARGET} --catch_system_errors=no --log_level=all) + +set_tests_properties(${TEST_TARGET} PROPERTIES ENVIRONMENT + IGNITE_NATIVE_TEST_CPP_THIN_CONFIG_PATH=${PROJECT_SOURCE_DIR}/config) diff --git a/modules/platforms/cpp/thin-client/CMakeLists.txt b/modules/platforms/cpp/thin-client/CMakeLists.txt new file mode 100644 index 0000000000000..5cd121f36072a --- /dev/null +++ b/modules/platforms/cpp/thin-client/CMakeLists.txt @@ -0,0 +1,48 @@ +# +# 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 +# +# http://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. +# + +project(ignite-thin-client) + +set(TARGET ${PROJECT_NAME}) + +include_directories(include src) + +set(SOURCES src/impl/data_channel.cpp + src/impl/utility.cpp + src/impl/protocol_version.cpp + src/impl/ignite_node.cpp + src/impl/ignite_client_impl.cpp + src/impl/data_router.cpp + src/impl/affinity/affinity_topology_version.cpp + src/impl/affinity/affinity_assignment.cpp + src/impl/affinity/affinity_manager.cpp + src/impl/remote_type_updater.cpp + src/impl/message.cpp + src/impl/cache/cache_client_proxy.cpp + src/impl/cache/cache_client_impl.cpp + src/ignite_client.cpp) + +add_library(${TARGET} SHARED ${SOURCES}) + +set_target_properties(${TARGET} PROPERTIES VERSION ${CMAKE_PROJECT_VERSION}) + +target_link_libraries(${TARGET} ignite-binary ignite-network) + +target_include_directories(${TARGET} INTERFACE include) + +install(TARGETS ${TARGET} LIBRARY DESTINATION lib) +install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h*") diff --git a/parent/pom.xml b/parent/pom.xml index cbc099ec2c4ef..c8d7a5bd60473 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -921,6 +921,8 @@ src/test/binaries/repo/org/apache/ignite/binary/test1/1.1/test1-1.1.jar src/test/binaries/repo/org/apache/ignite/binary/test2/1.1/test2-1.1.jar + **/*.cmake + **/CMakeLists.txt **/Makefile.am **/configure.ac **/Makefile.amrel