Skip to content
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
35 changes: 35 additions & 0 deletions modules/platforms/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ option(WARNINGS_AS_ERRORS "Treat warning as errors" OFF)
option(INSTALL_IGNITE_FILES "Install Ignite files" ON)
option(ENABLE_IWYU "Enable include-what-you-use tool" OFF)

set(IGNITE_INSTALL_DESTINATION "" CACHE STRING "Install directory for Ignite")

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})

get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

set(IGNITE_CMAKE_TOP_DIR ${CMAKE_CURRENT_LIST_DIR})

include(dependencies)
if(${INSTALL_IGNITE_FILES})
set(CMAKE_INSTALL_PREFIX ${IGNITE_INSTALL_DESTINATION})
Expand Down Expand Up @@ -191,3 +195,34 @@ if (CLANG_FORMAT_BIN)
else()
message(STATUS "Failed to find clang-format. So there is no 'format' target now.")
endif()

if (${INSTALL_IGNITE_FILES})
if (${ENABLE_CLIENT})
list(APPEND IGNITE_AVAILABLE_COMPONENTS client)
endif()
if (${ENABLE_ODBC})
list(APPEND IGNITE_AVAILABLE_COMPONENTS odbc)
endif()

include(CMakePackageConfigHelpers)
configure_package_config_file(
${IGNITE_CMAKE_TOP_DIR}/cmake/ignite-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/ignite-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}
PATH_VARS IGNITE_INCLUDEDIR
)

add_subdirectory(pkgconfig)

set(IGNITE_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake)

write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/cmake/ignite-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/cmake/ignite-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/ignite-config-version.cmake
DESTINATION ${IGNITE_INSTALL_CMAKEDIR}
)
endif()
2 changes: 1 addition & 1 deletion modules/platforms/cpp/cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set(MBEDTLS_AS_SUBPROJECT ON)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

add_compile_definitions(TF_PSA_CRYPTO_USER_CONFIG_FILE="${CMAKE_CURRENT_SOURCE_DIR}/ignite/common/detail/ignite_mbedtls_config.h")
add_compile_definitions(TF_PSA_CRYPTO_USER_CONFIG_FILE="${IGNITE_CMAKE_TOP_DIR}/ignite/common/detail/ignite_mbedtls_config.h")

if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.30.0")
# Avoid warning about FetchContent_Populate:
Expand Down
28 changes: 28 additions & 0 deletions modules/platforms/cpp/cmake/ignite-config-version.cmake.in
Original file line number Diff line number Diff line change
@@ -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.
#

set(PACKAGE_VERSION "@PROJECT_VERSION@")

# Check whether the requested PACKAGE_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
70 changes: 70 additions & 0 deletions modules/platforms/cpp/cmake/ignite-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# 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.
#

@PACKAGE_INIT@

set(ignite_VERSION @PROJECT_VERSION@)

cmake_policy(SET CMP0057 NEW)

# Compute installation paths
get_filename_component(ignite_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(ignite_INCLUDE_DIR "${ignite_CMAKE_DIR}/..")

# Available components
set(ignite_AVAILABLE_COMPONENTS @IGNITE_AVAILABLE_COMPONENTS@)

# Set default component if none specified
if(NOT ignite_FIND_COMPONENTS)
set(ignite_FIND_COMPONENTS client)
endif()

# Validate requested components
foreach(_comp ${ignite_FIND_COMPONENTS})
if(NOT _comp IN_LIST ignite_AVAILABLE_COMPONENTS)
set(ignite_FOUND FALSE)
set(ignite_NOT_FOUND_MESSAGE "Requested component '${_comp}' not available. Available components: ${ignite_AVAILABLE_COMPONENTS}")
endif()
endforeach()

# Include component-specific target files
foreach(_comp ${ignite_FIND_COMPONENTS})
set(_target_file "${ignite_CMAKE_DIR}/ignite-${_comp}-targets.cmake")
if(EXISTS "${_target_file}")
include("${_target_file}")
set(ignite_${_comp}_FOUND TRUE)
else()
set(ignite_${_comp}_FOUND FALSE)
if(ignite_FIND_REQUIRED_${_comp})
set(ignite_FOUND FALSE)
set(ignite_NOT_FOUND_MESSAGE "Component '${_comp}' not found")
endif()
endif()
endforeach()

check_required_components(ignite)

# Set legacy variables for compatibility
if(ignite_client_FOUND)
set(ignite_client_INCLUDE_DIR "${ignite_INCLUDE_DIR}")
set(ignite_client_LIBRARIES ignite::client)
endif()

if(ignite_odbc_FOUND)
set(ignite_odbc_INCLUDE_DIR "${ignite_INCLUDE_DIR}")
set(ignite_odbc_LIBRARIES ignite::odbc)
endif()
33 changes: 27 additions & 6 deletions modules/platforms/cpp/ignite/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ set(PUBLIC_HEADERS
)

add_library(${TARGET}-obj OBJECT ${SOURCES})
target_include_directories(${TARGET}-obj PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${TARGET}-obj PUBLIC ${IGNITE_CMAKE_TOP_DIR})

add_library(${TARGET} SHARED ${SOURCES})
set_target_properties(${TARGET} PROPERTIES EXPORT_NAME client)

add_library(${TARGET}-static STATIC ${SOURCES})
set_target_properties(${TARGET}-static PROPERTIES EXPORT_NAME client-static)

set(LIBRARIES
ignite-common
Expand All @@ -113,16 +115,35 @@ foreach(_target_lib IN LISTS _target_libs)
set_target_properties(${_target_lib} PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
endif()

target_link_libraries(${_target_lib} ${LIBRARIES})
target_link_libraries(${_target_lib}
PRIVATE ignite-tuple ignite-network ignite-protocol uni-algo::uni-algo
INTERFACE ignite-common)
endforeach()
unset(_target_libs)


add_library(ignite::client ALIAS ${TARGET})
add_library(ignite::client-static ALIAS ${TARGET}-static)

if (${INSTALL_IGNITE_FILES})
install(TARGETS ${TARGET}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
get_target_property(IGNITE_CLIENT_INCLUDES ${TARGET} INCLUDE_DIRECTORIES)
install(TARGETS ${TARGET} ignite-common tfpsacrypto
EXPORT ignite-client-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

export(EXPORT ignite-client-targets
NAMESPACE ignite::
FILE "${CMAKE_BINARY_DIR}/cmake/ignite-client-targets.cmake"
)

install(EXPORT ignite-client-targets
NAMESPACE ignite::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ignite"
FILE "ignite-client-targets.cmake"
)

ignite_install_headers(FILES ${PUBLIC_HEADERS} DESTINATION ${IGNITE_INCLUDEDIR}/client)
Expand Down
4 changes: 2 additions & 2 deletions modules/platforms/cpp/ignite/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ add_library(${TARGET} STATIC ${SOURCES})
target_link_libraries(${TARGET} PUBLIC TF-PSA-Crypto::tfpsacrypto)

target_include_directories(${TARGET} INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<BUILD_INTERFACE:${IGNITE_CMAKE_TOP_DIR}>
$<INSTALL_INTERFACE:${IGNITE_INCLUDEDIR}>
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)

if (${INSTALL_IGNITE_FILES})
ignite_install_headers(FILES ${PUBLIC_HEADERS} DESTINATION ${IGNITE_INCLUDEDIR}/common)
Expand Down
29 changes: 22 additions & 7 deletions modules/platforms/cpp/ignite/odbc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,17 @@ set(EXTRA_FILES)

if (WIN32)
string(REPLACE "." "," CMAKE_PROJECT_VERSION_COMMAS ${CMAKE_PROJECT_VERSION})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
configure_file(${IGNITE_CMAKE_TOP_DIR}/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
set(EXTRA_FILES ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif()

add_compile_definitions(CMAKE_PROJECT_VERSION="${CMAKE_PROJECT_VERSION}")

add_library(${TARGET}-obj OBJECT ${SOURCES})
target_include_directories(${TARGET}-obj PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${ODBC_INCLUDE_DIRS})
target_include_directories(${TARGET}-obj PUBLIC ${IGNITE_CMAKE_TOP_DIR} ${ODBC_INCLUDE_DIRS})

add_library(${TARGET} SHARED $<TARGET_OBJECTS:${TARGET}-obj> module.def ${EXTRA_FILES})
set_target_properties(${TARGET} PROPERTIES EXPORT_NAME odbc)

set(LIBRARIES
ignite-common
Expand Down Expand Up @@ -94,19 +95,33 @@ foreach(_target_lib IN LISTS _target_libs)
endif()

target_include_directories(${_target_lib} SYSTEM INTERFACE ${ODBC_INCLUDE_DIRS})
target_link_libraries(${_target_lib} ${LIBRARIES})
target_link_libraries(${_target_lib} PRIVATE ${LIBRARIES})
endforeach()
unset(_target_libs)

add_library(ignite::odbc ALIAS ${TARGET})

if (${INSTALL_IGNITE_FILES})
install(TARGETS ${TARGET}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
EXPORT ignite-odbc-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

export(EXPORT ignite-odbc-targets
NAMESPACE ignite::
FILE "${CMAKE_BINARY_DIR}/cmake/ignite-odbc-targets.cmake"
)

install(EXPORT ignite-odbc-targets
NAMESPACE ignite::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ignite"
FILE "ignite-odbc-targets.cmake"
)
endif()

ignite_test(connection_info_test DISCOVER SOURCES config/connection_info_test.cpp LIBS ${TARGET}-obj ${LIBRARIES})
ignite_test(config_tools_test DISCOVER SOURCES config/config_tools_test.cpp LIBS ${TARGET}-obj ${LIBRARIES})
ignite_test(application_data_buffer_test DISCOVER SOURCES app/application_data_buffer_test.cpp LIBS ${TARGET}-obj ${LIBRARIES})

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "config_tools.h"
#include "configuration.h"
#include "odbc_error.h"
#include "ignite/odbc/odbc_error.h"

#include <gtest/gtest.h>

Expand Down
2 changes: 1 addition & 1 deletion modules/platforms/cpp/ignite/protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set(SOURCES
)

add_library(${TARGET} OBJECT ${SOURCES})
target_link_libraries(${TARGET} ignite-common msgpack-c)
target_link_libraries(${TARGET} PUBLIC ignite-common msgpack-c)

set_target_properties(${TARGET} PROPERTIES VERSION ${CMAKE_PROJECT_VERSION})
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE 1)
6 changes: 0 additions & 6 deletions modules/platforms/cpp/ignite/tuple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,5 @@ target_link_libraries(${TARGET} ignite-common)
ignite_test(tuple_test DISCOVER SOURCES tuple_test.cpp LIBS ${TARGET})

if (${INSTALL_IGNITE_FILES})
install(TARGETS ${TARGET}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

ignite_install_headers(FILES ${PUBLIC_HEADERS} DESTINATION ${IGNITE_INCLUDEDIR}/tuple)
endif()
38 changes: 38 additions & 0 deletions modules/platforms/cpp/pkgconfig/CMakeLists.txt
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
#
# 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.
#

if (${ENABLE_CLIENT})
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/ignite-client.pc.in
${CMAKE_CURRENT_BINARY_DIR}/ignite-client.pc
@ONLY
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ignite-client.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif()

if (${ENABLE_ODBC})
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/ignite-odbc.pc.in
${CMAKE_CURRENT_BINARY_DIR}/ignite-odbc.pc
@ONLY
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ignite-odbc.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif()
11 changes: 11 additions & 0 deletions modules/platforms/cpp/pkgconfig/ignite-client.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: ignite-client
Description: Apache Ignite C++ Client Library
Version: @PROJECT_VERSION@
Requires:
Libs: -L${libdir} -lignite-client
Cflags: -I${includedir}
11 changes: 11 additions & 0 deletions modules/platforms/cpp/pkgconfig/ignite-odbc.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: ignite-odbc
Description: Apache Ignite ODBC Driver
Version: @PROJECT_VERSION@
Requires:
Libs: -L${libdir} -lignite-odbc
Cflags: -I${includedir}
4 changes: 2 additions & 2 deletions modules/platforms/cpp/tests/fake_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(SOURCES
main.cpp
fake_server.cpp
tcp_client_channel.cpp
connection_test.cpp
connection_test.cpp
)

ignite_test(${TARGET} SOURCES ${SOURCES} LIBS ignite-test-common ignite3-client)
ignite_test(${TARGET} SOURCES ${SOURCES} LIBS ignite-test-common ignite3-client msgpack-c)
Loading