Skip to content

Commit

Permalink
IGNITE-13078: C++: Add CMake build system support
Browse files Browse the repository at this point in the history
This closes apache#7854
  • Loading branch information
ivandasch authored and isapego committed Jun 22, 2020
1 parent 385ff65 commit bec7f31
Show file tree
Hide file tree
Showing 30 changed files with 1,313 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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.
83 changes: 83 additions & 0 deletions modules/platforms/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
45 changes: 45 additions & 0 deletions modules/platforms/cpp/DEVNOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=<install_dir>] ..
* 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)
----------------------------------

Expand Down
73 changes: 73 additions & 0 deletions modules/platforms/cpp/binary/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 $<TARGET_OBJECTS:${TARGET}-objlib>)

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*")
45 changes: 45 additions & 0 deletions modules/platforms/cpp/cmake/FindIgnite.cmake
Original file line number Diff line number Diff line change
@@ -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)
Loading

0 comments on commit bec7f31

Please sign in to comment.