Skip to content
Snippets Groups Projects
CMakeLists.txt 2.33 KiB
Newer Older
#
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
# Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

cmake_minimum_required(VERSION 3.15)

project(OctaveCaosDB
    DESCRIPTION "GNU/Octave wrapper for libcaosdb, the C++ client library of the CaosDB project."
    LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


# dependency management with conan
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

# fix grpc - remove unsecure (no-op ssl implementations)
string(REGEX REPLACE ";grpc\\+?\\+?_unsecure" "" CONAN_LIBS_GRPC
    "${CONAN_LIBS_GRPC}")
string(REGEX REPLACE ";grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS_GRPC
    "${CONAN_PKG_LIBS_GRPC}")
string(REGEX REPLACE ";grpc\\+?\\+?_unsecure" "" CONAN_LIBS
    "${CONAN_LIBS}")
string(REGEX REPLACE ";grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS
    "${CONAN_PKG_LIBS}")

add_subdirectory(src)

file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/inst)
string(REGEX REPLACE ";" ";-I" MKOCTFILE_INCLUDES "-I${CONAN_INCLUDE_DIRS}")
string(REGEX REPLACE ";" ";-L" MKOCTFILE_LIB_DIRS "-L${CONAN_LIB_DIRS}")
string(REGEX REPLACE ";" ";-l" MKOCTFILE_LIBS "-l${CONAN_LIBS}")
string(REGEX REPLACE ";" ":" MKOCTFILE_RPATH "${CONAN_LIB_DIRS}")
set(MKOCTFILE_OPTIONS "-o" "inst/caosdb.mex" "-Wl,-rpath,${MKOCTFILE_RPATH}" "--mex" "-std=gnu++17"
    "-L/usr/local/lib" ${MKOCTFILE_INCLUDES} ${MKOCTFILE_LIB_DIRS} ${MKOCTFILE_LIBS})
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/inst/caosdb.mex
    COMMAND mkoctfile
    ARGS ${MKOCTFILE_OPTIONS} ${OCTAVE_CAOSDB_SRC}
    DEPENDS ${OCTAVE_CAOSDB_SRC}
    )
add_custom_target(caosdb.mex ALL
    SOURCES ${CMAKE_BINARY_DIR}/inst/caosdb.mex)