|
| 1 | +# ----------------------------------------------------------------------------- |
| 2 | +# |
| 3 | +# This file is the copyrighted property of Tableau Software and is protected |
| 4 | +# by registered patents and other applicable U.S. and international laws and |
| 5 | +# regulations. |
| 6 | +# |
| 7 | +# Unlicensed use of the contents of this file is prohibited. Please refer to |
| 8 | +# the NOTICES.txt file for further details. |
| 9 | +# |
| 10 | +# ----------------------------------------------------------------------------- |
| 11 | + |
| 12 | +# This is an example CMake project that builds and tests the included C++ example code. |
| 13 | +# |
| 14 | +# To configure this project, run |
| 15 | +# |
| 16 | +# cmake <optional CMake arguments> -S "<directory of this file>" |
| 17 | +# |
| 18 | +# You can optionally override the directory where the Tableau Hyper API for C++ is searched by specifying |
| 19 | +# |
| 20 | +# -D CMAKE_PREFIX_PATH:PATH="<directory of Tableau Hyper API for C++>/share/cmake" |
| 21 | +# |
| 22 | +# By default, the `hyperd` executable is searched in the `bin/hyper/` directory of the `tableauhyperapi-cxx` package. |
| 23 | +# You can override the directory by specifying |
| 24 | +# |
| 25 | +# -D HYPER_PATH:PATH="<directory of hyperd>" |
| 26 | +# |
| 27 | +# To build and test the examples, run |
| 28 | +# |
| 29 | +# cmake --build . |
| 30 | +# ctest |
| 31 | + |
| 32 | +cmake_minimum_required(VERSION 3.1) |
| 33 | + |
| 34 | +# If CMAKE_PREFIX_PATH is not specified, provide a convenient default, so that the `find_package()` below can find |
| 35 | +# the Hyper API. This default assumes this `CMakeLists.txt` to be in its original location under `examples/`. |
| 36 | +if (NOT DEFINED CMAKE_PREFIX_PATH) |
| 37 | + get_filename_component(HAPI_PACKAGE_LOCATION "${CMAKE_SOURCE_DIR}/.." REALPATH) |
| 38 | + set(CMAKE_PREFIX_PATH "${HAPI_PACKAGE_LOCATION}/share/cmake" CACHE PATH "CMake prefix path" FORCE) |
| 39 | +endif () |
| 40 | + |
| 41 | +project("Tableau Hyper API for C++ Examples" LANGUAGES CXX) |
| 42 | + |
| 43 | +find_package(tableauhyperapi-cxx REQUIRED CONFIG) |
| 44 | + |
| 45 | +# Determine some directories in the `tableauhyperapi-c` package for use below. |
| 46 | +get_filename_component(tableauhyperapi-c_BINARY_DIR "${tableauhyperapi-c_DIR}/../../bin" ABSOLUTE) |
| 47 | +get_filename_component(tableauhyperapi-c_LIBRARY_DIR "${tableauhyperapi-c_DIR}/../../lib" ABSOLUTE) |
| 48 | +if (WIN32) |
| 49 | + set(tableauhyperapi-c_DYLIB_DIR "${tableauhyperapi-c_BINARY_DIR}") |
| 50 | +else () |
| 51 | + set(tableauhyperapi-c_DYLIB_DIR "${tableauhyperapi-c_LIBRARY_DIR}") |
| 52 | +endif () |
| 53 | + |
| 54 | +set(CMAKE_CXX_STANDARD 11) |
| 55 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 56 | + |
| 57 | +enable_testing() |
| 58 | + |
| 59 | +# Copy over the superstore CSV dataset. |
| 60 | +file(COPY "${CMAKE_SOURCE_DIR}/data/sample_extracts/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/data") |
| 61 | +file(COPY "${CMAKE_SOURCE_DIR}/data/superstore_normalized/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/data") |
| 62 | +if (WIN32) |
| 63 | + # On Windows, the Hyper API is copied into the binary directory so the examples can pick it up during execution. |
| 64 | + # On Posix systems, the Hyper API path is already compiled into the RPATH of the examples. |
| 65 | + file(COPY "${tableauhyperapi-c_DYLIB_DIR}/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") |
| 66 | +endif () |
| 67 | + |
| 68 | +# ----------------------------------------------------------------------------- |
| 69 | +# `create_hyper_file_from_csv.cpp` |
| 70 | + |
| 71 | +add_executable(create_hyper_file_from_csv create_hyper_file_from_csv.cpp) |
| 72 | +target_link_libraries(create_hyper_file_from_csv PRIVATE Tableau::tableauhyperapi-cxx) |
| 73 | +add_test( |
| 74 | + NAME create_hyper_file_from_csv |
| 75 | + COMMAND ${CMAKE_COMMAND} -E env HYPER_PATH=${HYPER_PATH} $<TARGET_FILE:create_hyper_file_from_csv> |
| 76 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 77 | + |
| 78 | +# ----------------------------------------------------------------------------- |
| 79 | +# `delete_data_in_existing_hyper_file.cpp` |
| 80 | + |
| 81 | +add_executable(delete_data_in_existing_hyper_file delete_data_in_existing_hyper_file.cpp) |
| 82 | +target_link_libraries(delete_data_in_existing_hyper_file PRIVATE Tableau::tableauhyperapi-cxx) |
| 83 | +add_test( |
| 84 | + NAME delete_data_in_existing_hyper_file |
| 85 | + COMMAND ${CMAKE_COMMAND} -E env HYPER_PATH=${HYPER_PATH} $<TARGET_FILE:delete_data_in_existing_hyper_file> |
| 86 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 87 | + |
| 88 | +# ----------------------------------------------------------------------------- |
| 89 | +# `insert_data_into_multiple_tables.cpp` |
| 90 | + |
| 91 | +add_executable(insert_data_into_multiple_tables insert_data_into_multiple_tables.cpp) |
| 92 | +target_link_libraries(insert_data_into_multiple_tables PRIVATE Tableau::tableauhyperapi-cxx) |
| 93 | +add_test( |
| 94 | + NAME insert_data_into_multiple_tables |
| 95 | + COMMAND ${CMAKE_COMMAND} -E env HYPER_PATH=${HYPER_PATH} $<TARGET_FILE:insert_data_into_multiple_tables> |
| 96 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 97 | + |
| 98 | +# ----------------------------------------------------------------------------- |
| 99 | +# `insert_data_into_single_table.cpp` |
| 100 | + |
| 101 | +add_executable(insert_data_into_single_table insert_data_into_single_table.cpp) |
| 102 | +target_link_libraries(insert_data_into_single_table PRIVATE Tableau::tableauhyperapi-cxx) |
| 103 | +add_test( |
| 104 | + NAME insert_data_into_single_table |
| 105 | + COMMAND ${CMAKE_COMMAND} -E env HYPER_PATH=${HYPER_PATH} $<TARGET_FILE:insert_data_into_single_table> |
| 106 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 107 | + |
| 108 | +# ----------------------------------------------------------------------------- |
| 109 | +# `insert_data_into_single_table.cpp` |
| 110 | + |
| 111 | +add_executable(insert_data_with_expressions insert_data_with_expressions.cpp) |
| 112 | +target_link_libraries(insert_data_with_expressions PRIVATE Tableau::tableauhyperapi-cxx) |
| 113 | +add_test( |
| 114 | + NAME insert_data_with_expressions |
| 115 | + COMMAND ${CMAKE_COMMAND} -E env HYPER_PATH=${HYPER_PATH} $<TARGET_FILE:insert_data_with_expressions> |
| 116 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 117 | + |
| 118 | +# ----------------------------------------------------------------------------- |
| 119 | +# `insert_spatial_data_to_a_hyper_file.cpp` |
| 120 | + |
| 121 | +add_executable(insert_spatial_data_to_a_hyper_file insert_spatial_data_to_a_hyper_file.cpp) |
| 122 | +target_link_libraries(insert_spatial_data_to_a_hyper_file PRIVATE Tableau::tableauhyperapi-cxx) |
| 123 | +add_test( |
| 124 | + NAME insert_spatial_data_to_a_hyper_file |
| 125 | + COMMAND ${CMAKE_COMMAND} -E env HYPER_PATH=${HYPER_PATH} $<TARGET_FILE:insert_spatial_data_to_a_hyper_file> |
| 126 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 127 | + |
| 128 | +# ----------------------------------------------------------------------------- |
| 129 | +# `read_and_print_data_from_existing_hyper_file.cpp` |
| 130 | + |
| 131 | +add_executable(read_and_print_data_from_existing_hyper_file read_and_print_data_from_existing_hyper_file.cpp) |
| 132 | +target_link_libraries(read_and_print_data_from_existing_hyper_file PRIVATE Tableau::tableauhyperapi-cxx) |
| 133 | +add_test( |
| 134 | + NAME read_and_print_data_from_existing_hyper_file |
| 135 | + COMMAND ${CMAKE_COMMAND} -E env HYPER_PATH=${HYPER_PATH} $<TARGET_FILE:read_and_print_data_from_existing_hyper_file> |
| 136 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 137 | + |
| 138 | +# ----------------------------------------------------------------------------- |
| 139 | +# `update_data_in_existing_hyper_file.cpp` |
| 140 | + |
| 141 | +add_executable(update_data_in_existing_hyper_file update_data_in_existing_hyper_file.cpp) |
| 142 | +target_link_libraries(update_data_in_existing_hyper_file PRIVATE Tableau::tableauhyperapi-cxx) |
| 143 | +add_test( |
| 144 | + NAME update_data_in_existing_hyper_file |
| 145 | + COMMAND ${CMAKE_COMMAND} -E env HYPER_PATH=${HYPER_PATH} $<TARGET_FILE:update_data_in_existing_hyper_file> |
| 146 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 147 | + |
0 commit comments