Skip to content
Snippets Groups Projects

Draft: Adapt for renamed cpplib

Open Joscha Schmiedt requested to merge f-linkahead-rename into dev
+ 50
32
#
# This file is a part of the CaosDB Project.
# This file is a part of the LinkAhead Project.
#
# Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
# Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
# Copyright (C) 2021-2024 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
@@ -20,30 +20,24 @@
cmake_minimum_required(VERSION 3.13)
project(OctaveCaosDB
DESCRIPTION "GNU/Octave wrapper for libcaosdb, the C++ client library of the CaosDB project."
project(OctaveLinkAhead
DESCRIPTION "GNU/Octave wrapper for liblinkahead, the C++ client library of the LinkAhead 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(KEEP_RPATHS)
# find dependencies
find_package(Boost CONFIG REQUIRED)
find_package(linkahead CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)
find_package(protobuf CONFIG REQUIRED)
find_package(GTest CONFIG REQUIRED)
# remove path-like elements from CONAN_LIBS, relevant on MacOS
string(REGEX REPLACE ";/[^;]+" "" CONAN_LIBS "${CONAN_LIBS}")
# 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}")
# string(REGEX REPLACE ";/[^;]+" "" CONAN_LIBS "${CONAN_LIBS}")
#######################################################
### code formatting with clang-format
@@ -84,6 +78,12 @@ string(REGEX REPLACE " " ";" OCTLIBS "${OCTLIBS}")
set(MAOXDB_DIR "${PROJECT_SOURCE_DIR}/src/lib")
add_library(maoxdb STATIC "${MAOXDB_DIR}/maoxdb.cpp")
set_target_properties(maoxdb PROPERTIES PUBLIC_HEADER "${MAOXDB_DIR}/maoxdb.hpp")
target_include_directories(maoxdb PUBLIC ${Boost_INCLUDE_DIRS} ${gRPC_INCLUDE_DIRS} ${protobuf_INCLUDE_DIRS} ${linkahead_INCLUDE_DIRS})
target_link_libraries(maoxdb PUBLIC
gRPC::grpc++ gRPC::grpc protobuf::libprotobuf ${Boost_LIBRARIES}
linkahead::linkahead ${OCTLIBS})
# TODO: For some reason, only linkahead is added ot the include path here, not the other dependencies.
#/usr/bin/c++ -DBOOST_FILESYSTEM_VERSION=3 -DCARES_STATICLIB -I/usr/include/octave-8.4.0/octave -I/home/joscha/caosdb/src/caosdb-octavelib/src/lib -isystem /home/joscha/.conan2/p/b/linkaf19fa7e027de2/p/include -m64 -O3 -DNDEBUG -std=gnu++17 -I/usr/include/octave-8.4.0/octave -fPIC -MD -MT CMakeFiles/maoxdb.dir/src/lib/maoxdb.cpp.o -MF CMakeFiles/maoxdb.dir/src/lib/maoxdb.cpp.o.d -o CMakeFiles/maoxdb.dir/src/lib/maoxdb.cpp.o -c /home/joscha/caosdb/src/caosdb-octavelib/src/lib/maoxdb.cpp
target_compile_options(maoxdb PRIVATE "-I${OCTINCLUDEDIR}" "-fPIC")
get_property(_MAOX_LIB_DIR TARGET maoxdb PROPERTY LIBRARY_OUTPUT_DIRECTORY)
# message("_MAOX_LIB_DIR: ${_MAOX_LIB_DIR}")
@@ -95,18 +95,29 @@ get_property(_MAOX_LIB_DIR TARGET maoxdb PROPERTY LIBRARY_OUTPUT_DIRECTORY)
# this is to change, the GLOB_RECURSE code needs to be changed.
# Absolute paths to the cpp files.
file(GLOB_RECURSE OCTAVE_CAOSDB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/private/*.cpp)
message("OCTAVE_CAOSDB_SRC: ${OCTAVE_CAOSDB_SRC}")
file(GLOB_RECURSE OCTAVE_LINKAHEAD_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/private/*.cpp)
message("OCTAVE_LINKAHEAD_SRC: ${OCTAVE_LINKAHEAD_SRC}")
set(PKG_INST_DIR "${PROJECT_SOURCE_DIR}/inst")
file(MAKE_DIRECTORY ${PKG_INST_DIR})
# Options for mex compilation
string(REGEX REPLACE ";" ";-I" _MKOCTFILE_INCLUDES "-I${CONAN_INCLUDE_DIRS};${MAOXDB_DIR}")
string(REGEX REPLACE ";" ";-L" _MKOCTFILE_LIB_DIRS "-L${CONAN_LIB_DIRS};${_MAOX_LIB_DIR}")
string(REGEX REPLACE ";" ";-l" _MKOCTFILE_LIBS "-lmaoxdb;${CONAN_LIBS}")
# WIP: Remove the CONAN_INCLUDE_DIRS and CONAN_LIB_DIRS, replace with CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH
message("INCLUDE_DIRS: ${CMAKE_INCLUDE_PATH}")
message("LIB_DIRS: ${CMAKE_LIBRARY_PATH}")
message("LIBS: ${LIBS}")
# TODO: What is the purpose of this?
string(REGEX REPLACE ";" ";-I" _MKOCTFILE_INCLUDES "-I${CMAKE_INCLUDE_PATH}")
string(REGEX REPLACE ";" ";-L" _MKOCTFILE_LIB_DIRS "-L${CMAKE_LIBRARY_PATH};${_MAOX_LIB_DIR}")
string(REGEX REPLACE ";" ";-l" _MKOCTFILE_LIBS "-lmaoxdb;linkahead")
message("INCLUDE_DIRS: ${CMAKE_INCLUDE_PATH}")
message("LIB_DIRS: ${CMAKE_LIBRARY_PATH}")
message("LIBS: ${LIBS}")
# Needs this in front: -Wl,-rpath,
string(REGEX REPLACE ";" ",-rpath," _MKOCTFILE_RPATH "${CONAN_LIB_DIRS}")
string(REGEX REPLACE ";" ",-rpath," _MKOCTFILE_RPATH "${CMAKE_LIBRARY_PATH}")
set(_MKOCTFILE_OPTIONS "-Wl,-rpath,${_MKOCTFILE_RPATH}" "--mex" "-std=gnu++17"
"-L/usr/local/lib" ${_MKOCTFILE_INCLUDES} ${_MKOCTFILE_LIB_DIRS} ${_MKOCTFILE_LIBS})
@@ -148,9 +159,9 @@ if(LINTING)
TARGET mex
COMMAND ${clang_tidy}
ARGS ${_CMAKE_CXX_CLANG_TIDY} ${_CMAKE_CXX_CLANG_TIDY_CHECKS}
${OCTAVE_CAOSDB_SRC} "--" ${_MKOCTFILE_INCLUDES} "-I/usr/include"
${OCTAVE_LINKAHEAD_SRC} "--" ${_MKOCTFILE_INCLUDES} "-I/usr/include"
"-I${OCTINCLUDEDIR}" "-std=c++17"
DEPENDS ${OCTAVE_CAOSDB_SRC})
DEPENDS ${OCTAVE_LINKAHEAD_SRC})
endif()
find_program(iwyu
@@ -169,8 +180,8 @@ if(LINTING)
COMMAND ${iwyu}
ARGS ${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE} "-I${OCTINCLUDEDIR}"
"-std=c++17" "-I/usr/include" ${_MKOCTFILE_INCLUDES}
${OCTAVE_CAOSDB_SRC} "||" "true"
DEPENDS ${OCTAVE_CAOSDB_SRC})
${OCTAVE_LINKAHEAD_SRC} "||" "true"
DEPENDS ${OCTAVE_LINKAHEAD_SRC})
endif()
else()
@@ -183,6 +194,7 @@ endif()
option(TEST "Unit test with gtest" OFF)
if(TEST)
find_package(GTest)
set(CMAKE_BUILD_TYPE Debug)
# cmake tests suffers from not being able to define dependencies, see
# https://stackoverflow.com/questions/733475, so we disable it for now.
@@ -193,7 +205,7 @@ if(TEST)
# append all the test cases here (file name without the ".cpp" suffix)
set(test_cases
test_utilities
test_caosdb_conversion
test_linkahead_conversion
)
# add special cmake functions for gtest, (although they are not used yet, see above)
include(GoogleTest)
@@ -211,13 +223,19 @@ if(TEST)
add_executable(${test_case_name} EXCLUDE_FROM_ALL test/${test_case_name}.cpp)
add_custom_target("test_${test_case_name}" "${test_case_name}" DEPENDS "${test_case_name}")
add_dependencies(test_detailed "test_${test_case_name}")
# set(libcaosdb_TEST_SRC
# "${CMAKE_CURRENT_SOURCE_DIR}/${test_case_name}.cpp ${libcaosdb_TEST_SRC}")
# set(liblinkahead_TEST_SRC
# "${CMAKE_CURRENT_SOURCE_DIR}/${test_case_name}.cpp ${liblinkahead_TEST_SRC}")
target_include_directories(${test_case_name} PUBLIC
${OCTINCLUDEDIR}
${MAOXDB_DIR})
target_link_libraries(${test_case_name} PUBLIC
maoxdb ${OCTLIBS} ${CONAN_LIBS_CAOSDB} ${CONAN_LIBS_GTEST} ${CONAN_LIBS_BOOST})
maoxdb ${OCTLIBS} linkahead::linkahead GTest::gtest
gRPC::grpc++ gRPC::grpc protobuf::libprotobuf ${Boost_LIBRARIES}
)
# TODO: For some reason, this causes: fatal error: absl/synchronization/mutex.h: No such file or directory
# Handling include directories should be handled by Conan, but it is not.
target_include_directories(${test_case_name} PUBLIC ${Boost_INCLUDE_DIRS} ${gRPC_INCLUDE_DIRS} ${protobuf_INCLUDE_DIRS} ${linkahead_INCLUDE_DIRS} ${CMAKE_INCLUDE_PATH} )
target_link_directories(${test_case_name} PUBLIC ${OCTLIBDIR})
message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")
gtest_discover_tests(${test_case_name}
Loading