sandboxed-api/contrib/libxls/CMakeLists.txt
Christian Blichmann 51799f99ae Introduce a transitional logging utility library
Instead of calling `google::InitGoogleLogging()` directly, introduce an
indirection via a new utility library. After this change, Sandboxed API
should consistently use `sapi::InitLogging()` everywhere.

For now, `sapi::InitLogging()` simply calls its glog equivalent. However,
this enables us to migrate away from the gflags dependency and use Abseil
flags. Once a follow-up change lands, `sapi::InitLogging()` will instead
initialize the google logging library with flags defined from Aseil.

Later still, once Abseil releases logging, we can then drop the glog
dependency entirely.

PiperOrigin-RevId: 445363592
Change-Id: Ia23a7dc88b8ffe65a422ea4d5233bba7bdd1303a
2022-04-29 02:14:06 -07:00

112 lines
3.3 KiB
CMake

# Copyright 2022 Google LLC
#
# 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
#
# https://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.13..3.22)
project(sapi_libxls C CXX)
include(CTest)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(NOT TARGET sapi::sapi)
set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree")
add_subdirectory("${SAPI_ROOT}"
"${CMAKE_BINARY_DIR}/sandboxed-api-build"
EXCLUDE_FROM_ALL)
endif()
FetchContent_Declare(libxls
GIT_REPOSITORY https://github.com/libxls/libxls.git
GIT_TAG 448240067919707eb95fb009f76f3fdb439b1427
)
FetchContent_GetProperties(libxls)
if(NOT libxls_POPULATED)
FetchContent_Populate(libxls)
set(libxls_STATUS_FILE "${libxls_SOURCE_DIR}/config.status")
if(EXISTS "${libxls_STATUS_FILE}")
file(SHA256 "${libxls_STATUS_FILE}" _sapi_CONFIG_STATUS)
endif()
if(NOT _sapi_CONFIG_STATUS STREQUAL "${libxls_CONFIG_STATUS}")
message("-- Configuring libxls...")
execute_process(
COMMAND autoreconf -i
WORKING_DIRECTORY "${libxls_SOURCE_DIR}"
RESULT_VARIABLE _sapi_libxls_autoreconf_result
)
if(NOT _sapi_libxls_autoreconf_result EQUAL "0")
message(FATAL_ERROR "Configuration for libxls failed: "
"${_sapi_libxls_autoreconf_result}")
endif()
execute_process(
COMMAND ./configure --disable-dependency-tracking
--disable-shared
--quiet
WORKING_DIRECTORY "${libxls_SOURCE_DIR}"
RESULT_VARIABLE _sapi_libxls_config_result
)
if(NOT _sapi_libxls_config_result EQUAL "0")
message(FATAL_ERROR "Configuration for libxls failed: "
"${_sapi_libxls_config_result}")
endif()
file(SHA256 "${libxls_SOURCE_DIR}/config.status" _sapi_CONFIG_STATUS)
set(libxls_CONFIG_STATUS "${_sapi_CONFIG_STATUS}" CACHE INTERNAL "")
endif()
endif()
add_library(libxls STATIC
"${libxls_SOURCE_DIR}/src/endian.c"
"${libxls_SOURCE_DIR}/src/locale.c"
"${libxls_SOURCE_DIR}/src/ole.c"
"${libxls_SOURCE_DIR}/src/xls.c"
"${libxls_SOURCE_DIR}/src/xlstool.c"
)
target_include_directories(libxls PUBLIC
"${libxls_SOURCE_DIR}"
"${libxls_SOURCE_DIR}/include"
)
configure_file(xls.gen.h.in xls.gen.h)
add_sapi_library(sapi_libxls
FUNCTIONS xls_open_file
xls_getWorkSheet
xls_parseWorkSheet
xls_cell
xls_close_WS
xls_close_WB
xls_getError
INPUTS "${PROJECT_BINARY_DIR}/xls.gen.h"
LIBRARY libxls
LIBRARY_NAME Libxls
NAMESPACE ""
)
add_library(sapi_contrib::libxls ALIAS sapi_libxls)
target_include_directories(sapi_libxls INTERFACE
"${PROJECT_BINARY_DIR}"
)
if(SAPI_ENABLE_EXAMPLES)
add_subdirectory(example)
endif()
if(SAPI_ENABLE_TESTS)
add_subdirectory(test)
endif()