Skip to content

Commit

Permalink
Add support for CMake package (#23)
Browse files Browse the repository at this point in the history
Fix #22
  • Loading branch information
kou committed Aug 15, 2022
1 parent e401f02 commit ccd8524
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
31 changes: 31 additions & 0 deletions datafusion-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2022 Sutou Kouhei <kou@clear-code.com>
#
# Licensed 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(datafusion_PACKAGE_PREFIX_DIR "${PACKAGE_PREFIX_DIR}")
set(datafusion_INCLUDE_DIR "${datafusion_PACKAGE_PREFIX_DIR}/@INCLUDE_DIR@")
set(datafusion_LIB_DIR "${datafusion_PACKAGE_PREFIX_DIR}/@LIB_DIR@")

add_library(datafusion::datafusion SHARED IMPORTED)
set_target_properties(datafusion::datafusion PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${datafusion_INCLUDE_DIR}")
if(WIN32)
set_target_properties(datafusion::datafusion PROPERTIES
IMPORTED_LOCATION "${datafusion_LIB_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}datafusion${CMAKE_IMPORT_LIBRARY_SUFFIX}")
else()
set_target_properties(datafusion::datafusion PROPERTIES
IMPORTED_LOCATION "${datafusion_LIB_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}datafusion${CMAKE_SHARED_LIBRARY_SUFFIX}.@PACKAGE_VERSION@"
IMPORTED_SONAME "${CMAKE_SHARED_LIBRARY_PREFIX}datafusion${CMAKE_SHARED_LIBRARY_SUFFIX}.@PACKAGE_VERSION_MAJOR@")
endif()
49 changes: 49 additions & 0 deletions datafusion-glib-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2022 Sutou Kouhei <kou@clear-code.com>
#
# Licensed 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(datafusion-glib_PACKAGE_PREFIX_DIR "${PACKAGE_PREFIX_DIR}")
set(datafusion-glib_INCLUDE_DIR "${datafusion-glib_PACKAGE_PREFIX_DIR}/@INCLUDE_DIR@")
set(datafusion-glib_LIB_DIR "${datafusion-glib_PACKAGE_PREFIX_DIR}/@LIB_DIR@")
set(datafusion-glib_DEFAULT_LIBRARY "@DEFAULT_LIBRARY@")

include(CMakeFindDependencyMacro)
find_dependency(arrow-glib)
find_dependency(datafusion)

if(datafusion-glib_DEFAULT_LIBRARY STREQUAL "shared" OR
datafusion-glib_DEFAULT_LIBRARY STREQUAL "both")
add_library(datafusion-glib::datafusion-glib-shared SHARED IMPORTED)
set_target_properties(datafusion-glib::datafusion-glib-shared PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${datafusion-glib_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "datafusion::datafusion;arrow-glib::arrow-glib-shared")
if(WIN32)
set_target_properties(datafusion-glib::datafusion-glib-shared PROPERTIES
IMPORTED_LOCATION "${datafusion-glib_LIB_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}datafusion-glib${CMAKE_IMPORT_LIBRARY_SUFFIX}")
else()
set_target_properties(datafusion-glib::datafusion-glib-shared PROPERTIES
IMPORTED_LOCATION "${datafusion-glib_LIB_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}datafusion-glib${CMAKE_SHARED_LIBRARY_SUFFIX}.@PACKAGE_VERSION@"
IMPORTED_SONAME "${CMAKE_SHARED_LIBRARY_PREFIX}datafusion-glib.${CMAKE_SHARED_LIBRARY_SUFFIX}.@PACKAGE_VERSION_MAJOR@")
endif()
endif()

if(datafusion-glib_DEFAULT_LIBRARY STREQUAL "static" OR
datafusion-glib_DEFAULT_LIBRARY STREQUAL "both")
add_library(datafusion-glib::datafusion-glib-static STATIC IMPORTED)
set_target_properties(datafusion-glib::datafusion-glib-static PROPERTIES
IMPORTED_LOCATION "${datafusion-glib_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}datafusion-glib${CMAKE_STATIC_LIBRARY_SUFFIX}"
INTERFACE_INCLUDE_DIRECTORIES "${datafusion-glib_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "datafusion::datafusion;arrow-glib::arrow-glib-static")
endif()
19 changes: 19 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,25 @@ if generate_vapi
endif

subdir('datafusion-glib')

cmake = import('cmake')
cmake_config = configuration_data()
cmake_config.set('DEFAULT_LIBRARY', get_option('default_library'))
cmake_config.set('INCLUDE_DIR', include_dir)
cmake_config.set('LIB_DIR', lib_dir)
cmake_config.set('PACKAGE_VERSION', version)
cmake_config.set('PACKAGE_VERSION_MAJOR', version_major)
cmake_config.set('PACKAGE_VERSION_MICRO', version_micro)
cmake_config.set('PACKAGE_VERSION_MINOR', version_minor)
cmake.write_basic_package_version_file(name: 'datafusion', version: version)
cmake.configure_package_config_file(name: 'datafusion',
input: 'datafusion-config.cmake.in',
configuration: cmake_config)
cmake.write_basic_package_version_file(name: 'datafusion-glib', version: version)
cmake.configure_package_config_file(name: 'datafusion-glib',
input: 'datafusion-glib-config.cmake.in',
configuration: cmake_config)

subdir('examples')
if get_option('doc')
subdir('doc/datafusion-glib')
Expand Down

0 comments on commit ccd8524

Please sign in to comment.