Skip to content

Commit bec7f31

Browse files
ivandaschisapego
authored andcommitted
IGNITE-13078: C++: Add CMake build system support
This closes apache#7854
1 parent 385ff65 commit bec7f31

File tree

30 files changed

+1313
-10
lines changed

30 files changed

+1313
-10
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ packages
102102
/modules/platforms/cpp/stamp-h1
103103
/modules/platforms/cpp/thin-client-test/ignite-thin-client-tests
104104

105+
#CMake temp files
106+
/modules/platforms/cpp/**/cmake-build**
107+
105108
#Files related to ML manual-runnable tests
106109
/modules/ml/src/test/resources/manualrun/trees/columntrees.manualrun.properties
107110

LICENSE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,9 @@ This eBook is for the use of anyone anywhere at no cost and with
243243
almost no restrictions whatsoever. You may copy it, give it away or
244244
re-use it under the terms of the Project Gutenberg License included
245245
with this eBook or online at www.gutenberg.org
246+
247+
==============================================================================
248+
For CMake script FindODBC.cmake in C++ module.
249+
==============================================================================
250+
This module contains modified FindODBC.cmake script from CMake distribution,
251+
which is available under a "3-clause BSD" license. For details, see https://cmake.org/licensing.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
cmake_minimum_required(VERSION 3.6)
19+
project(Ignite.C++ VERSION 2.9.0.42453)
20+
21+
set(CMAKE_CXX_STANDARD 98)
22+
23+
find_package(Java 1.8 REQUIRED)
24+
find_package(JNI REQUIRED)
25+
26+
set(CMAKE_PROJECT_VERSION ${PROJECT_VERSION})
27+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
28+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIGNITE_IMPL -DIGNITE_FRIEND -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS")
29+
30+
set(CMAKE_SKIP_BUILD_RPATH FALSE)
31+
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
32+
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
33+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
34+
35+
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
36+
37+
if("${isSystemDir}" STREQUAL "-1")
38+
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
39+
endif("${isSystemDir}" STREQUAL "-1")
40+
41+
if (WIN32)
42+
add_definitions(-DUNICODE=1)
43+
44+
add_compile_options(/source-charset:utf-8)
45+
endif()
46+
47+
option (WITH_ODBC OFF)
48+
option (WITH_THIN_CLIENT OFF)
49+
option (WITH_TESTS OFF)
50+
51+
add_subdirectory(common)
52+
add_subdirectory(binary)
53+
add_subdirectory(jni)
54+
add_subdirectory(core)
55+
add_subdirectory(ignite)
56+
57+
if (${WITH_TESTS})
58+
enable_testing()
59+
60+
if (EXISTS ${CMAKE_SOURCE_DIR}/core-test)
61+
add_subdirectory(core-test)
62+
endif()
63+
endif()
64+
65+
if (${WITH_THIN_CLIENT} OR ${WITH_ODBC})
66+
add_subdirectory(network)
67+
endif()
68+
69+
if (${WITH_THIN_CLIENT})
70+
add_subdirectory(thin-client)
71+
72+
if (${WITH_TESTS} AND EXISTS ${CMAKE_SOURCE_DIR}/thin-client-test)
73+
add_subdirectory(thin-client-test)
74+
endif()
75+
endif()
76+
77+
if (${WITH_ODBC})
78+
add_subdirectory(odbc)
79+
80+
if (${WITH_TESTS} AND EXISTS ${CMAKE_SOURCE_DIR}/odbc-test)
81+
add_subdirectory(odbc-test)
82+
endif()
83+
endif()

modules/platforms/cpp/DEVNOTES.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,51 @@ Ignite expects for boost libraries and header to be found under default system p
6464
it is recommended to use package repository for your OS to install boost package for the
6565
development.
6666

67+
Building on Linux and Mac OS X with CMake
68+
----------------------------------
69+
70+
Common Requirements:
71+
72+
* GCC, g++, CMake >= 3.6 must be installed
73+
* Java Development Kit (JDK) must be installed: https://java.com/en/download/index.jsp
74+
* JAVA_HOME environment variable must be set pointing to Java installation directory.
75+
* IGNITE_HOME environment variable must be set to Ignite installation directory.
76+
77+
By default building tests, ODBC and thin-client are disabled.
78+
* OpenSSL, 1.0 or later required for building ODBC and thin-client.
79+
* UnixODBX required for building ODBC.
80+
* For building tests, boost framework is required. The following boost libraries are used:
81+
* boost_unit_test_framework
82+
* boost_thread
83+
* boost_system
84+
* boost_chrono
85+
86+
On Mac OS X all dependencies can be installed using Homebrew.
87+
88+
Building and installing the Apache Ignite C++ components:
89+
* Navigate to the directory $IGNITE_HOME/platforms/cpp
90+
* Execute the following commands one by one to build the project:
91+
* mkdir cmake-build-[release|debug]
92+
* cd ./cmake-build-[release|debug]
93+
* cmake -DCMAKE_BUILD_TYPE=[Release|Debug] [-DCMAKE_INSTALL_PREFIX=<install_dir>] ..
94+
* make
95+
* make install
96+
97+
* For building ODBC add to cmake option -DWITH_ODBC=ON
98+
* For building thin client add to cmake option -DWITH_THIN_CLIENT=ON
99+
* For building with tests add to cmake option -DWITH_TESTS=ON
100+
101+
Running test:
102+
* For core tests: ctest -V -R IgniteCoreTest
103+
* For thin-client tests: ctest -V -R IgniteThinClientTest
104+
* For ODBC tests: ctest -V -R IgniteOdbcTest
105+
* For all tests: ctest -V
106+
107+
WARNING!
108+
* For running ODBC tests, ODBC driver must be installed in driver manager. See odbc/README.txt for details.
109+
* On Mac OS X Homebrew doesn't create symlinks for OpenSSL, so they should be created or as alternative
110+
OPEN_SSL_HOME should be set before running ODBC or thin-client tests.
111+
67112
Building on Windows with Visual Studio (tm)
68113
----------------------------------
69114

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
project(ignite-binary)
19+
20+
include_directories(include)
21+
22+
set(TARGET ${PROJECT_NAME})
23+
24+
set(SOURCES src/binary/binary_containers.cpp
25+
src/binary/binary_raw_writer.cpp
26+
src/binary/binary_writer.cpp
27+
src/binary/binary_reader.cpp
28+
src/binary/binary_type.cpp
29+
src/binary/binary_raw_reader.cpp
30+
src/impl/binary/binary_type_manager.cpp
31+
src/impl/binary/binary_type_impl.cpp
32+
src/impl/binary/binary_utils.cpp
33+
src/impl/binary/binary_reader_impl.cpp
34+
src/impl/binary/binary_type_handler.cpp
35+
src/impl/binary/binary_writer_impl.cpp
36+
src/impl/binary/binary_schema.cpp
37+
src/impl/binary/binary_type_snapshot.cpp
38+
src/impl/binary/binary_object_header.cpp
39+
src/impl/binary/binary_object_impl.cpp
40+
src/impl/binary/binary_field_meta.cpp
41+
src/impl/interop/interop_memory.cpp
42+
src/impl/interop/interop_output_stream.cpp
43+
src/impl/interop/interop_input_stream.cpp)
44+
45+
list(APPEND _target_libs ${TARGET})
46+
47+
if (WIN32)
48+
add_library(${TARGET}-objlib OBJECT ${SOURCES})
49+
50+
add_library(${TARGET} SHARED $<TARGET_OBJECTS:${TARGET}-objlib>)
51+
52+
list(APPEND _target_libs ${TARGET}-objlib)
53+
else()
54+
add_library(${TARGET} SHARED ${SOURCES})
55+
endif()
56+
57+
foreach(_target_lib IN LISTS _target_libs)
58+
set_target_properties(${_target_lib} PROPERTIES VERSION ${CMAKE_PROJECT_VERSION})
59+
60+
if (${_target_lib} STREQUAL ${TARGET}-objlib)
61+
set_target_properties(${_target_lib} PROPERTIES POSITION_INDEPENDENT_CODE 1)
62+
63+
target_link_libraries(${_target_lib} ignite-common-objlib)
64+
else()
65+
target_link_libraries(${_target_lib} ignite-common)
66+
endif()
67+
68+
target_include_directories(${_target_lib} INTERFACE include)
69+
endforeach()
70+
unset(_target_libs)
71+
72+
install(TARGETS ${TARGET} LIBRARY DESTINATION lib)
73+
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include FILES_MATCHING PATTERN "*.h*")
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
find_path(IGNITE_INCLUDE_DIR ignite/ignite.h
19+
HINTS ${IGNITE_CPP_DIR}/include
20+
PATH_SUFFIXES ignite)
21+
22+
find_library(IGNITE_LIB ignite HINTS ${IGNITE_CPP_DIR}/lib)
23+
24+
find_library(IGNITE_COMMON_LIB ignite-common HINTS ${IGNITE_CPP_DIR}/lib)
25+
26+
find_library(IGNITE_NETWORK_LIB ignite-network HINTS ${IGNITE_CPP_DIR}/lib)
27+
28+
find_library(IGNITE_JNI_LIB ignite-jni HINTS ${IGNITE_CPP_DIR}/lib)
29+
30+
find_library(IGNITE_THIN_CLIENT_LIB ignite-thin-client HINTS ${IGNITE_CPP_DIR}/lib)
31+
32+
find_library(IGNITE_ODBC_LIB ignite-odbc HINTS ${IGNITE_CPP_DIR}/lib)
33+
34+
find_library(IGNITE_BINARY_LIB ignite-binary HINTS ${IGNITE_CPP_DIR}/lib)
35+
36+
include(FindPackageHandleStandardArgs)
37+
38+
find_package_handle_standard_args(Ignite DEFAULT_MSG
39+
IGNITE_LIB
40+
IGNITE_THIN_CLIENT_LIB
41+
IGNITE_ODBC_LIB
42+
IGNITE_BINARY_LIB
43+
IGNITE_NETWORK_LIB
44+
IGNITE_COMMON_LIB
45+
IGNITE_INCLUDE_DIR)

0 commit comments

Comments
 (0)