diff --git a/cmake-scripts/setup-libfmt.cmake b/cmake-scripts/setup-libfmt.cmake new file mode 100644 index 0000000..9bf4322 --- /dev/null +++ b/cmake-scripts/setup-libfmt.cmake @@ -0,0 +1,61 @@ +# Copyright (c) 2024 [Ribose Inc](https://www.ribose.com). +# All rights reserved. +# This file is a part of tebako +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +def_ext_prj_t(LIBFMT "10.2.1" "312151a2d13c8327f5c9c586ac6cf7cddc1658e8f53edae0ec56509c8fa516c9") + +message(STATUS "Collecting libfmt - " v${LIBFMT_VER} " at " ${LIBFMT_SOURCE_DIR}) + +set(__LIBFMT "${DEPS}/lib/libfmt.a") + +set(CMAKE_ARGUMENTS -DCMAKE_INSTALL_PREFIX=${DEPS} + -DFMT_DOC=OFF + -DFMT_TEST=OFF + -DFMT_FUZZ=OFF + -DFMT_CUDA_TEST=OFF + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} +) + +if(TEBAKO_BUILD_TARGET) + list(APPEND CMAKE_ARGUMENTS -DCMAKE_C_FLAGS=--target=${TEBAKO_BUILD_TARGET}) + list(APPEND CMAKE_ARGUMENTS -DCMAKE_EXE_LINKER_FLAGS=--target=${TEBAKO_BUILD_TARGET}) + list(APPEND CMAKE_ARGUMENTS -DCMAKE_SHARED_LINKER_FLAGS=--target=${TEBAKO_BUILD_TARGET}) +endif(TEBAKO_BUILD_TARGET) + +ExternalProject_Add(${LIBFMT_PRJ} + PREFIX "${DEPS}" + URL https://github.com/fmtlib/fmt/releases/download/${LIBFMT_VER}/fmt-${LIBFMT_VER}.zip + URL_HASH SHA256=${LIBFMT_HASH} + DOWNLOAD_NO_PROGRESS true + CMAKE_ARGS ${CMAKE_ARGUMENTS} + SOURCE_DIR ${LIBFMT_SOURCE_DIR} + BINARY_DIR ${LIBFMT_BINARY_DIR} + BUILD_BYPRODUCTS ${__LIBFMT} +) + +add_library(_LIBFMT STATIC IMPORTED) +set_target_properties(_LIBFMT PROPERTIES IMPORTED_LOCATION ${__LIBFMT}) +add_dependencies(_LIBFMT ${LIBFMT_PRJ})