Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
c168bec6
Commit
c168bec6
authored
11 months ago
by
Joscha Schmiedt
Browse files
Options
Downloads
Patches
Plain Diff
WIP: get call to protoc running
parent
3df261b1
No related branches found
No related tags found
2 merge requests
!61
Release 0.3.0
,
!53
Add vcpkg support
Pipeline
#53854
failed
11 months ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
CMakeLists.txt
+340
-310
340 additions, 310 deletions
CMakeLists.txt
with
340 additions
and
310 deletions
CMakeLists.txt
+
340
−
310
View file @
c168bec6
...
@@ -86,70 +86,86 @@ add_subdirectory(doc)
...
@@ -86,70 +86,86 @@ add_subdirectory(doc)
# TODO: Replace this with the protobuf_generate_cpp function
# TODO: Replace this with the protobuf_generate_cpp function
# Protobuf/Grpc source files
# Protobuf/Grpc source files
set
(
PROTO_FILES
set
(
PROTO_FILES
${
PROJECT_SOURCE_DIR
}
/proto/proto/caosdb/info/v1/main.proto
${
PROJECT_SOURCE_DIR
}
/proto/proto/caosdb/info/v1/main.proto
${
PROJECT_SOURCE_DIR
}
/proto/proto/caosdb/entity/v1/main.proto
${
PROJECT_SOURCE_DIR
}
/proto/proto/caosdb/entity/v1/main.proto
)
)
IF
(
BUILD_ACM
)
IF
(
BUILD_ACM
)
list
(
APPEND PROTO_FILES
list
(
APPEND PROTO_FILES
${
PROJECT_SOURCE_DIR
}
/proto/proto/caosdb/acm/v1alpha1/main.proto
${
PROJECT_SOURCE_DIR
}
/proto/proto/caosdb/acm/v1alpha1/main.proto
)
)
ENDIF
()
ENDIF
()
set
(
PROTO_PATH
${
PROJECT_SOURCE_DIR
}
/proto/proto
)
find_package
(
protobuf REQUIRED
)
include_directories
(
${
Protobuf_INCLUDE_DIRS
}
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
)
# protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
protobuf_generate_cpp
(
PROTO_SRCS PROTO_HDRS
${
PROJECT_SOURCE_DIR
}
/proto/proto/caosdb/info/v1/main.proto
)
protobuf_generate_cpp
(
PROTO_SRCS PROTO_HDRS
${
PROJECT_SOURCE_DIR
}
/proto/proto/caosdb/entity/v1/main.proto
)
message
(
STATUS
"PROTO_FILES:
${
PROTO_FILES
}
"
)
message
(
STATUS
"PROTO_SRCS:
${
PROTO_SRCS
}
"
)
message
(
STATUS
"PROTO_HDRS:
${
PROTO_HDRS
}
"
)
# set(PROTO_PATH ${PROJECT_SOURCE_DIR}/proto/proto)
# compiler binaries
# compiler binaries
IF
(
WIN32
)
set
(
_PROTOBUF_PROTOC
"
${
CMAKE_BINARY_DIR
}
/build_tools/protoc.exe"
)
set
(
_GRPC_CPP_PLUGIN_EXECUTABLE
"
${
CMAKE_BINARY_DIR
}
/build_tools/grpc_cpp_plugin.exe"
)
ELSE
()
set
(
_PROTOBUF_PROTOC
"
${
CMAKE_BINARY_DIR
}
/build_tools/protoc"
)
set
(
_GRPC_CPP_PLUGIN_EXECUTABLE
"
${
CMAKE_BINARY_DIR
}
/build_tools/grpc_cpp_plugin"
)
ENDIF
()
# Generated sources
list
(
LENGTH PROTO_FILES len_proto_files
)
math
(
EXPR len_proto_files
"
${
len_proto_files
}
- 1"
)
# IF (WIN32)
foreach
(
i RANGE
"
${
len_proto_files
}
"
)
# set(_PROTOBUF_PROTOC "${CMAKE_BINARY_DIR}/build_tools/protoc.exe")
list
(
GET PROTO_FILES
${
i
}
next_proto_file
)
# set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_BINARY_DIR}/build_tools/grpc_cpp_plugin.exe")
# ELSE()
# strip away the prefix path and the ".proto" suffix
# set(_PROTOBUF_PROTOC "${CMAKE_BINARY_DIR}/build_tools/protoc")
string
(
REPLACE
# set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_BINARY_DIR}/build_tools/grpc_cpp_plugin")
"
${
PROJECT_SOURCE_DIR
}
/proto/proto/caosdb/"
# ENDIF()
""
next_proto_module
# # Generated sources
"
${
next_proto_file
}
"
)
# list(LENGTH PROTO_FILES len_proto_files)
string
(
REPLACE
# math(EXPR len_proto_files "${len_proto_files} - 1")
".proto"
# foreach(i RANGE "${len_proto_files}")
""
# list(GET PROTO_FILES ${i} next_proto_file)
next_proto_module
"
${
next_proto_module
}
"
)
# # strip away the prefix path and the ".proto" suffix
set
(
next_proto_src
# string(REPLACE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/include/caosdb/
${
next_proto_module
}
.pb.cc"
)
# "${PROJECT_SOURCE_DIR}/proto/proto/caosdb/"
set
(
next_proto_hdr
# ""
"
${
CMAKE_CURRENT_BINARY_DIR
}
/include/caosdb/
${
next_proto_module
}
.pb.h"
)
# next_proto_module
set
(
next_grpc_src
# "${next_proto_file}")
"
${
CMAKE_CURRENT_BINARY_DIR
}
/include/caosdb/
${
next_proto_module
}
.grpc.pb.cc"
)
# string(REPLACE
set
(
next_grpc_hdr
# ".proto"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/include/caosdb/
${
next_proto_module
}
.grpc.pb.h"
)
# ""
list
(
APPEND GRPC_GENERATED_HEADERS
"
${
next_proto_hdr
}
"
"
${
next_grpc_hdr
}
"
)
# next_proto_module
list
(
APPEND GRPC_GENERATED_SOURCES
"
${
next_proto_src
}
"
"
${
next_grpc_src
}
"
)
# "${next_proto_module}")
endforeach
()
# set(next_proto_src
# "${CMAKE_CURRENT_BINARY_DIR}/include/caosdb/${next_proto_module}.pb.cc")
set
(
GRPC_GENERATED
# set(next_proto_hdr
${
GRPC_GENERATED_SOURCES
}
# "${CMAKE_CURRENT_BINARY_DIR}/include/caosdb/${next_proto_module}.pb.h")
${
GRPC_GENERATED_HEADERS
}
)
# set(next_grpc_src
add_custom_command
(
# "${CMAKE_CURRENT_BINARY_DIR}/include/caosdb/${next_proto_module}.grpc.pb.cc")
OUTPUT
${
GRPC_GENERATED
}
# set(next_grpc_hdr
COMMAND
${
_PROTOBUF_PROTOC
}
# "${CMAKE_CURRENT_BINARY_DIR}/include/caosdb/${next_proto_module}.grpc.pb.h")
ARGS --grpc_out
"
${
CMAKE_CURRENT_BINARY_DIR
}
/include"
# list(APPEND GRPC_GENERATED_HEADERS "${next_proto_hdr}" "${next_grpc_hdr}")
--cpp_out
"
${
CMAKE_CURRENT_BINARY_DIR
}
/include"
# list(APPEND GRPC_GENERATED_SOURCES "${next_proto_src}" "${next_grpc_src}")
-I
"
${
PROTO_PATH
}
"
# endforeach()
--plugin=protoc-gen-grpc=
"
${
_GRPC_CPP_PLUGIN_EXECUTABLE
}
"
${
PROTO_FILES
}
# set(GRPC_GENERATED
DEPENDS
${
PROTO_FILES
}
)
# ${GRPC_GENERATED_SOURCES}
# ${GRPC_GENERATED_HEADERS})
# add_custom_command(
# OUTPUT ${GRPC_GENERATED}
# COMMAND ${_PROTOBUF_PROTOC}
# ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}/include"
# --cpp_out "${CMAKE_CURRENT_BINARY_DIR}/include"
# -I "${PROTO_PATH}"
# --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
# ${PROTO_FILES}
# DEPENDS ${PROTO_FILES})
# show generated files
# show generated files
message
(
DEBUG
"GRPC_GENERATED:
${
GRPC_GENERATED
}
"
)
message
(
DEBUG
"GRPC_GENERATED:
${
GRPC_GENERATED
}
"
)
...
@@ -165,10 +181,24 @@ message(DEBUG "GRPC_GENERATED: ${GRPC_GENERATED}")
...
@@ -165,10 +181,24 @@ message(DEBUG "GRPC_GENERATED: ${GRPC_GENERATED}")
###############################################################################
###############################################################################
find_package
(
gRPC CONFIG REQUIRED
)
find_package
(
gRPC CONFIG REQUIRED
)
find_package
(
Protobuf CONFIG REQUIRED
)
# find_package(protobuf CONFIG REQUIRED)
find_package
(
Boost REQUIRED
)
# boost
find_package
(
boost_smart_ptr CONFIG REQUIRED
)
find_package
(
boost_filesystem CONFIG REQUIRED
)
find_package
(
boost_json CONFIG REQUIRED
)
find_package
(
boost_log CONFIG REQUIRED
)
find_package
(
boost_thread CONFIG REQUIRED
)
find_package
(
boost_beast CONFIG REQUIRED
)
find_package
(
GTest REQUIRED
)
find_package
(
GTest REQUIRED
)
set
(
dependencies
gRPC::gpr gRPC::grpc gRPC::grpc++ protobuf::libprotoc protobuf::libprotobuf
Boost::beast Boost::smart_ptr Boost::filesystem Boost::json Boost::log Boost::thread
)
# print include directories for debugging
# print include directories for debugging
message
(
DEBUG
"CMAKE_INCLUDE_PATH:
${
CMAKE_INCLUDE_PATH
}
"
)
message
(
DEBUG
"CMAKE_INCLUDE_PATH:
${
CMAKE_INCLUDE_PATH
}
"
)
message
(
DEBUG
"PROTOBUF_INCLUDE_DIRS:
${
PROTOBUF_INCLUDE_DIRS
}
"
)
message
(
DEBUG
"PROTOBUF_INCLUDE_DIRS:
${
PROTOBUF_INCLUDE_DIRS
}
"
)
...
@@ -202,7 +232,7 @@ else()
...
@@ -202,7 +232,7 @@ else()
add_library
(
caosdb
add_library
(
caosdb
SHARED
${
libcaosdb_INCL
}
${
libcaosdb_SRC
}
${
GRPC_GENERATED
}
)
SHARED
${
libcaosdb_INCL
}
${
libcaosdb_SRC
}
${
GRPC_GENERATED
}
)
target_link_libraries
(
caosdb
target_link_libraries
(
caosdb
grpc::grpc protobuf::protobuf boost::boost
${
dependencies
}
stdc++fs
stdc++fs
)
)
set
(
LIBCAOSDB caosdb
)
set
(
LIBCAOSDB caosdb
)
...
@@ -219,54 +249,54 @@ target_include_directories(caosdb PUBLIC
...
@@ -219,54 +249,54 @@ target_include_directories(caosdb PUBLIC
# libccaosdb
#
# libccaosdb
# ----------
#
# ----------
add_library
(
ccaosdb SHARED src/ccaosdb.cpp
)
#
add_library(ccaosdb SHARED src/ccaosdb.cpp)
target_link_libraries
(
ccaosdb
#
target_link_libraries(ccaosdb
grpc::grpc protobuf::protobuf boost::boost
#
dependencies
${
LIBCAOSDB
}
#
${LIBCAOSDB}
stdc++fs
#
stdc++fs
)
#
)
target_include_directories
(
ccaosdb PUBLIC
#
target_include_directories(ccaosdb PUBLIC
$<BUILD_INTERFACE:
${
libcaosdb_SOURCE_DIR
}
/include>
#
$<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include>
$<BUILD_INTERFACE:
${
libcaosdb_BINARY_DIR
}
/include>
#
$<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
#
$<INSTALL_INTERFACE:include>
)
#
)
# ccaosdbcli
#
# ccaosdbcli
# ----------
#
# ----------
add_executable
(
ccaosdbcli EXCLUDE_FROM_ALL src/ccaosdbcli.c
)
#
add_executable(ccaosdbcli EXCLUDE_FROM_ALL src/ccaosdbcli.c)
target_include_directories
(
ccaosdbcli PUBLIC
#
target_include_directories(ccaosdbcli PUBLIC
$<BUILD_INTERFACE:
${
libcaosdb_SOURCE_DIR
}
/include>
#
$<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include>
$<BUILD_INTERFACE:
${
libcaosdb_BINARY_DIR
}
/include>
#
$<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
#
$<INSTALL_INTERFACE:include>
)
#
)
target_include_directories
(
ccaosdbcli SYSTEM PUBLIC
#
target_include_directories(ccaosdbcli SYSTEM PUBLIC
${
CONAN_INCLUDE_DIRS
}
#
${CONAN_INCLUDE_DIRS}
)
#
)
target_link_libraries
(
ccaosdbcli
#
target_link_libraries(ccaosdbcli
grpc::grpc protobuf::protobuf boost::boost
#
dependencies
${
LIBCAOSDB
}
#
${LIBCAOSDB}
ccaosdb
#
ccaosdb
)
#
)
# cxxcaosdbcli
#
# cxxcaosdbcli
# ------------
#
# ------------
add_executable
(
cxxcaosdbcli EXCLUDE_FROM_ALL src/cxxcaosdbcli.cpp
)
#
add_executable(cxxcaosdbcli EXCLUDE_FROM_ALL src/cxxcaosdbcli.cpp)
target_include_directories
(
cxxcaosdbcli PUBLIC
#
target_include_directories(cxxcaosdbcli PUBLIC
$<BUILD_INTERFACE:
${
libcaosdb_SOURCE_DIR
}
/include>
#
$<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include>
$<BUILD_INTERFACE:
${
libcaosdb_BINARY_DIR
}
/include>
#
$<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
#
$<INSTALL_INTERFACE:include>
)
#
)
target_include_directories
(
cxxcaosdbcli SYSTEM PUBLIC
#
target_include_directories(cxxcaosdbcli SYSTEM PUBLIC
${
CONAN_INCLUDE_DIRS
}
#
${CONAN_INCLUDE_DIRS}
)
#
)
target_link_libraries
(
cxxcaosdbcli
#
target_link_libraries(cxxcaosdbcli
${
LIBCAOSDB
}
#
${LIBCAOSDB}
grpc::grpc protobuf::protobuf boost::boost
#
dependencies
)
#
)
...
@@ -274,213 +304,213 @@ target_link_libraries(cxxcaosdbcli
...
@@ -274,213 +304,213 @@ target_link_libraries(cxxcaosdbcli
### LINTING with CLANG-TIDY and INCLUDE-WHAT-YOU-USE
### LINTING with CLANG-TIDY and INCLUDE-WHAT-YOU-USE
#######################################################
#######################################################
include
(
CheckCXXCompilerFlag
)
#
include(CheckCXXCompilerFlag)
include
(
CheckCCompilerFlag
)
#
include(CheckCCompilerFlag)
function
(
add_compiler_flag flag
)
#
function(add_compiler_flag flag)
string
(
FIND
"
${
CMAKE_CXX_FLAGS
}
"
"
${
flag
}
"
cxx_present
)
#
string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" cxx_present)
if
(
cxx_present EQUAL -1
)
#
if(cxx_present EQUAL -1)
check_cxx_compiler_flag
(
"
${
flag
}
"
flag_supported
)
#
check_cxx_compiler_flag("${flag}" flag_supported)
if
(
flag_supported
)
#
if(flag_supported)
set
(
PEDANTIC_CMAKE_CXX_FLAGS
"
${
PEDANTIC_CMAKE_CXX_FLAGS
}
${
flag
}
"
PARENT_SCOPE
)
#
set(PEDANTIC_CMAKE_CXX_FLAGS "${PEDANTIC_CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
endif
()
#
endif()
unset
(
flag_supported CACHE
)
#
unset(flag_supported CACHE)
endif
()
#
endif()
unset
(
cxx_present CACHE
)
#
unset(cxx_present CACHE)
string
(
FIND
"
${
CMAKE_C_FLAGS
}
"
"
${
flag
}
"
c_present
)
#
string(FIND "${CMAKE_C_FLAGS}" "${flag}" c_present)
if
(
c_present EQUAL -1
)
#
if(c_present EQUAL -1)
check_cxx_compiler_flag
(
"
${
flag
}
"
flag_supported
)
#
check_cxx_compiler_flag("${flag}" flag_supported)
if
(
flag_supported
)
#
if(flag_supported)
set
(
PEDANTIC_CMAKE_C_FLAGS
"
${
PEDANTIC_CMAKE_C_FLAGS
}
${
flag
}
"
PARENT_SCOPE
)
#
set(PEDANTIC_CMAKE_C_FLAGS "${PEDANTIC_CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
endif
()
#
endif()
unset
(
flag_supported CACHE
)
#
unset(flag_supported CACHE)
endif
()
#
endif()
unset
(
c_present CACHE
)
#
unset(c_present CACHE)
endfunction
()
#
endfunction()
option
(
LINTING
"Enable linting with clang-tidy and iwyu when in non-Debug build-type"
OFF
)
#
option(LINTING "Enable linting with clang-tidy and iwyu when in non-Debug build-type" OFF)
if
(
"
${
CMAKE_BUILD_TYPE
}
"
MATCHES
"Debug"
OR LINTING
)
#
if("${CMAKE_BUILD_TYPE}" MATCHES "Debug" OR LINTING)
set
(
_LINTING ON
)
#
set(_LINTING ON)
endif
()
#
endif()
option
(
SKIP_LINTING
"Skip linting even when in Debug build-type"
OFF
)
#
option(SKIP_LINTING "Skip linting even when in Debug build-type" OFF)
if
(
"
${
CMAKE_BUILD_TYPE
}
"
MATCHES
"Debug"
AND SKIP_LINTING
)
#
if("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND SKIP_LINTING)
message
(
WARNING
"Skipping linting due to SKIP_LINTING option"
)
#
message(WARNING "Skipping linting due to SKIP_LINTING option")
set
(
_LINTING OFF
)
#
set(_LINTING OFF)
endif
()
#
endif()
if
(
_LINTING
)
#
if(_LINTING)
### set paranoid compiler flags
#
### set paranoid compiler flags
add_compiler_flag
(
"-Wall"
)
#
add_compiler_flag("-Wall")
add_compiler_flag
(
"-Wextra"
)
#
add_compiler_flag("-Wextra")
add_compiler_flag
(
"-pedantic"
)
#
add_compiler_flag("-pedantic")
# add_compiler_flag("-Werror") # removed until issue #71 is resolved
#
# add_compiler_flag("-Werror") # removed until issue #71 is resolved
message
(
STATUS
"PEDANTIC_CMAKE_CXX_FLAGS: [
${
PEDANTIC_CMAKE_CXX_FLAGS
}
]"
)
#
message(STATUS "PEDANTIC_CMAKE_CXX_FLAGS: [${PEDANTIC_CMAKE_CXX_FLAGS}]")
set
(
TARGET_CAOSDB_COMPILE_FLAGS
"
${
TARGET_CAOSDB_COMPILE_FLAGS
}
${
PEDANTIC_CMAKE_CXX_FLAGS
}
"
)
#
set(TARGET_CAOSDB_COMPILE_FLAGS "${TARGET_CAOSDB_COMPILE_FLAGS} ${PEDANTIC_CMAKE_CXX_FLAGS}")
set
(
TARGET_CCAOSDB_COMPILE_FLAGS
"
${
TARGET_CCAOSDB_COMPILE_FLAGS
}
${
PEDANTIC_CMAKE_C_FLAGS
}
"
)
#
set(TARGET_CCAOSDB_COMPILE_FLAGS "${TARGET_CCAOSDB_COMPILE_FLAGS} ${PEDANTIC_CMAKE_C_FLAGS}")
set
(
TARGET_CXXCAOSDBCLI_COMPILE_FLAGS
"
${
TARGET_CXXCAOSDBCLI_COMPILE_FLAGS
}
${
PEDANTIC_CMAKE_CXX_FLAGS
}
"
)
#
set(TARGET_CXXCAOSDBCLI_COMPILE_FLAGS "${TARGET_CXXCAOSDBCLI_COMPILE_FLAGS} ${PEDANTIC_CMAKE_CXX_FLAGS}")
set
(
TARGET_CCAOSDBCLI_COMPILE_FLAGS
"
${
TARGET_CCAOSDBCLI_COMPILE_FLAGS
}
${
PEDANTIC_CMAKE_C_FLAGS
}
"
)
#
set(TARGET_CCAOSDBCLI_COMPILE_FLAGS "${TARGET_CCAOSDBCLI_COMPILE_FLAGS} ${PEDANTIC_CMAKE_C_FLAGS}")
set_target_properties
(
caosdb PROPERTIES
#
set_target_properties(caosdb PROPERTIES
COMPILE_FLAGS
"
${
TARGET_CAOSDB_COMPILE_FLAGS
}
"
)
#
COMPILE_FLAGS "${TARGET_CAOSDB_COMPILE_FLAGS}")
set_target_properties
(
ccaosdb PROPERTIES
#
set_target_properties(ccaosdb PROPERTIES
COMPILE_FLAGS
"
${
TARGET_CCAOSDB_COMPILE_FLAGS
}
"
)
#
COMPILE_FLAGS "${TARGET_CCAOSDB_COMPILE_FLAGS}")
set_target_properties
(
cxxcaosdbcli PROPERTIES
#
set_target_properties(cxxcaosdbcli PROPERTIES
COMPILE_FLAGS
"
${
TARGET_CXXCAOSDBCLI_COMPILE_FLAGS
}
"
)
#
COMPILE_FLAGS "${TARGET_CXXCAOSDBCLI_COMPILE_FLAGS}")
set_target_properties
(
ccaosdbcli PROPERTIES
#
set_target_properties(ccaosdbcli PROPERTIES
COMPILE_FLAGS
"
${
TARGET_CCAOSDBCLI_COMPILE_FLAGS
}
"
)
#
COMPILE_FLAGS "${TARGET_CCAOSDBCLI_COMPILE_FLAGS}")
find_program
(
iwyu
#
find_program(iwyu
NAMES include-what-you-use iwyu
#
NAMES include-what-you-use iwyu
PATHS
${
CMAKE_SOURCE_DIR
}
/tools/include-what-you-use/
${
iwyu_os
}
/bin
)
#
PATHS ${CMAKE_SOURCE_DIR}/tools/include-what-you-use/${iwyu_os}/bin)
if
(
NOT iwyu
)
#
if(NOT iwyu)
message
(
WARNING
"include-what-you-use: Not found"
)
#
message(WARNING "include-what-you-use: Not found")
else
()
#
else()
message
(
STATUS
"include-what-you-use:
${
iwyu
}
"
)
#
message(STATUS "include-what-you-use: ${iwyu}")
set
(
_CMAKE_CXX_INCLUDE_WHAT_YOU_USE
${
iwyu
}
#
set(_CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${iwyu}
"-Xiwyu"
"--cxx17ns"
"-Xiwyu"
"--no_fwd_decls"
)
#
"-Xiwyu" "--cxx17ns" "-Xiwyu" "--no_fwd_decls")
set_target_properties
(
caosdb PROPERTIES
#
set_target_properties(caosdb PROPERTIES
CXX_INCLUDE_WHAT_YOU_USE
"
${
_CMAKE_CXX_INCLUDE_WHAT_YOU_USE
}
"
#
CXX_INCLUDE_WHAT_YOU_USE "${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}"
)
#
)
set_target_properties
(
cxxcaosdbcli PROPERTIES
#
set_target_properties(cxxcaosdbcli PROPERTIES
CXX_INCLUDE_WHAT_YOU_USE
"
${
_CMAKE_CXX_INCLUDE_WHAT_YOU_USE
}
"
#
CXX_INCLUDE_WHAT_YOU_USE "${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}"
)
#
)
set_target_properties
(
ccaosdbcli PROPERTIES
#
set_target_properties(ccaosdbcli PROPERTIES
C_INCLUDE_WHAT_YOU_USE
"
${
_CMAKE_CXX_INCLUDE_WHAT_YOU_USE
}
"
#
C_INCLUDE_WHAT_YOU_USE "${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}"
)
#
)
endif
()
#
endif()
find_program
(
clang_tidy NAMES clang-tidy clang-tidy-11
)
#
find_program(clang_tidy NAMES clang-tidy clang-tidy-11)
if
(
NOT clang_tidy
)
#
if(NOT clang_tidy)
message
(
WARNING
"clang-tidy: Not found"
)
#
message(WARNING "clang-tidy: Not found")
else
()
#
else()
message
(
STATUS
"clang-tidy:
${
clang_tidy
}
"
)
#
message(STATUS "clang-tidy: ${clang_tidy}")
set
(
_CMAKE_CXX_CLANG_TIDY_CHECKS
#
set(_CMAKE_CXX_CLANG_TIDY_CHECKS
"--checks=*,-fuchsia-*,-llvmlibc-*,-readability-convert-member-functions-to-static,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-llvm-else-after-return,-readability-else-after-return,-modernize-use-trailing-return-type,-bugprone-branch-clone,-altera-*,-misc-include-cleaner,-readability-identifier-*,-llvm-include-order,-misc-const-correctness"
)
#
"--checks=*,-fuchsia-*,-llvmlibc-*,-readability-convert-member-functions-to-static,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-llvm-else-after-return,-readability-else-after-return,-modernize-use-trailing-return-type,-bugprone-branch-clone,-altera-*,-misc-include-cleaner,-readability-identifier-*,-llvm-include-order,-misc-const-correctness")
set
(
_CMAKE_C_CLANG_TIDY_CHECKS
"
${
_CMAKE_CXX_CLANG_TIDY_CHECKS
}
"
)
#
set(_CMAKE_C_CLANG_TIDY_CHECKS "${_CMAKE_CXX_CLANG_TIDY_CHECKS}")
set
(
_CMAKE_CXX_CLANG_TIDY
"
${
clang_tidy
}
"
#
set(_CMAKE_CXX_CLANG_TIDY "${clang_tidy}"
"--header-filter=caosdb/.*[^
\(
\.pb\.h
\)
]$"
)
#
"--header-filter=caosdb/.*[^\(\.pb\.h\)]$")
# "--warnings-as-errors=*")
#
# "--warnings-as-errors=*")
set
(
_CMAKE_C_CLANG_TIDY
"
${
_CMAKE_CXX_CLANG_TIDY
}
"
)
#
set(_CMAKE_C_CLANG_TIDY "${_CMAKE_CXX_CLANG_TIDY}")
option
(
AUTO_FIX_LINTING
"Append --fix option to clang-tidy"
OFF
)
#
option(AUTO_FIX_LINTING "Append --fix option to clang-tidy" OFF)
if
(
AUTO_FIX_LINTING
)
#
if(AUTO_FIX_LINTING)
set
(
_CMAKE_CXX_CLANG_TIDY
"
${
_CMAKE_CXX_CLANG_TIDY
}
;--fix"
)
#
set(_CMAKE_CXX_CLANG_TIDY "${_CMAKE_CXX_CLANG_TIDY};--fix")
endif
()
#
endif()
message
(
STATUS
"Using clang-tidy with
#
message(STATUS "Using clang-tidy with
'
${
_CMAKE_CXX_CLANG_TIDY
}
;
${
_CMAKE_CXX_CLANG_TIDY_CHECKS
}
'"
)
#
'${_CMAKE_CXX_CLANG_TIDY};${_CMAKE_CXX_CLANG_TIDY_CHECKS}'")
set_target_properties
(
caosdb PROPERTIES
#
set_target_properties(caosdb PROPERTIES
CXX_CLANG_TIDY
"
${
_CMAKE_CXX_CLANG_TIDY
}
;
${
_CMAKE_CXX_CLANG_TIDY_CHECKS
}
"
#
CXX_CLANG_TIDY "${_CMAKE_CXX_CLANG_TIDY};${_CMAKE_CXX_CLANG_TIDY_CHECKS}"
)
#
)
set_target_properties
(
cxxcaosdbcli PROPERTIES
#
set_target_properties(cxxcaosdbcli PROPERTIES
CXX_CLANG_TIDY
"
${
_CMAKE_CXX_CLANG_TIDY
}
;
${
_CMAKE_CXX_CLANG_TIDY_CHECKS
}
"
#
CXX_CLANG_TIDY "${_CMAKE_CXX_CLANG_TIDY};${_CMAKE_CXX_CLANG_TIDY_CHECKS}"
)
#
)
set_target_properties
(
ccaosdb PROPERTIES
#
set_target_properties(ccaosdb PROPERTIES
C_CLANG_TIDY
"
${
_CMAKE_C_CLANG_TIDY
}
;
${
_CMAKE_C_CLANG_TIDY_CHECKS
}
"
#
C_CLANG_TIDY "${_CMAKE_C_CLANG_TIDY};${_CMAKE_C_CLANG_TIDY_CHECKS}"
)
#
)
set_target_properties
(
ccaosdbcli PROPERTIES
#
set_target_properties(ccaosdbcli PROPERTIES
C_CLANG_TIDY
"
${
_CMAKE_C_CLANG_TIDY
}
;
${
_CMAKE_C_CLANG_TIDY_CHECKS
}
"
#
C_CLANG_TIDY "${_CMAKE_C_CLANG_TIDY};${_CMAKE_C_CLANG_TIDY_CHECKS}"
)
#
)
endif
()
#
endif()
endif
()
#
endif()
#######################################################
#
#######################################################
### UNIT TEST
#
### UNIT TEST
#######################################################
#
#######################################################
if
(
"
${
CMAKE_BUILD_TYPE
}
"
MATCHES
"Debug"
)
#
if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
enable_testing
()
#
enable_testing()
add_subdirectory
(
test
)
#
add_subdirectory(test)
endif
()
#
endif()
# ###############################################
#
#
###############################################
# ############ INSTALLATION #####################
#
#
############ INSTALLATION #####################
# ###############################################
#
#
###############################################
set
(
libcaosdb_INCLUDE_DEST
"include/caosdb"
)
#
set(libcaosdb_INCLUDE_DEST "include/caosdb")
set
(
libcaosdb_LIB_DEST
"lib"
)
#
set(libcaosdb_LIB_DEST "lib")
set
(
CMAKE_INSTALL_PREFIX
"$ENV{HOME}/.local/"
)
#
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local/")
install
(
#
install(
# targets to install
#
# targets to install
TARGETS
${
LIBCAOSDB
}
ccaosdb
#
TARGETS ${LIBCAOSDB} ccaosdb
# name of the CMake "export group" containing the targets we want to install
#
# name of the CMake "export group" containing the targets we want to install
EXPORT caosdbTargets
#
EXPORT caosdbTargets
# Dynamic, static library and include destination locations after running
#
# Dynamic, static library and include destination locations after running
# "make install"
#
# "make install"
LIBRARY DESTINATION
${
libcaosdb_LIB_DEST
}
#
LIBRARY DESTINATION ${libcaosdb_LIB_DEST}
ARCHIVE DESTINATION
${
libcaosdb_LIB_DEST
}
#
ARCHIVE DESTINATION ${libcaosdb_LIB_DEST}
INCLUDES DESTINATION
${
libcaosdb_INCLUDE_DEST
}
#
INCLUDES DESTINATION ${libcaosdb_INCLUDE_DEST}
)
#
)
set
(
libcaosdb_CMAKE_DEST
"
${
libcaosdb_LIB_DEST
}
/cmake/caosdb"
)
#
set(libcaosdb_CMAKE_DEST "${libcaosdb_LIB_DEST}/cmake/caosdb")
install
(
#
install(
# The export we want to save (matches name defined above containing the
#
# The export we want to save (matches name defined above containing the
# install targets)
#
# install targets)
EXPORT caosdbTargets
#
EXPORT caosdbTargets
# CMake file in which to store the export's information
#
# CMake file in which to store the export's information
FILE caosdbTargets.cmake
#
FILE caosdbTargets.cmake
# Namespace prepends all targets in the export (when we import later, we
#
# Namespace prepends all targets in the export (when we import later, we
# will use caosdb::caosdb)
#
# will use caosdb::caosdb)
NAMESPACE caosdb::
#
NAMESPACE caosdb::
# where to place the resulting file (here, we're putting it with the library)
#
# where to place the resulting file (here, we're putting it with the library)
DESTINATION
${
libcaosdb_CMAKE_DEST
}
#
DESTINATION ${libcaosdb_CMAKE_DEST}
)
#
)
install
(
FILES
${
libcaosdb_INCL
}
${
PROJECT_SOURCE_DIR
}
/include/ccaosdb.h DESTINATION
${
libcaosdb_INCLUDE_DEST
}
)
#
install(FILES ${libcaosdb_INCL} ${PROJECT_SOURCE_DIR}/include/ccaosdb.h DESTINATION ${libcaosdb_INCLUDE_DEST})
foreach
(
i RANGE
"
${
len_proto_files
}
"
)
#
foreach(i RANGE "${len_proto_files}")
list
(
GET PROTO_FILES
${
i
}
next_proto_file
)
#
list(GET PROTO_FILES ${i} next_proto_file)
# strip away the prefix path and the ".proto" suffix
#
# strip away the prefix path and the ".proto" suffix
string
(
REPLACE
#
string(REPLACE
"
${
PROJECT_SOURCE_DIR
}
/proto/proto/caosdb/"
#
"${PROJECT_SOURCE_DIR}/proto/proto/caosdb/"
""
#
""
next_proto_module
#
next_proto_module
"
${
next_proto_file
}
"
)
#
"${next_proto_file}")
string
(
REPLACE
#
string(REPLACE
"/main.proto"
#
"/main.proto"
""
#
""
next_proto_module
#
next_proto_module
"
${
next_proto_module
}
"
)
#
"${next_proto_module}")
set
(
next_proto_hdr
#
set(next_proto_hdr
"
${
CMAKE_CURRENT_BINARY_DIR
}
/include/caosdb/
${
next_proto_module
}
/main.pb.h"
)
#
"${CMAKE_CURRENT_BINARY_DIR}/include/caosdb/${next_proto_module}/main.pb.h")
set
(
next_grpc_hdr
#
set(next_grpc_hdr
"
${
CMAKE_CURRENT_BINARY_DIR
}
/include/caosdb/
${
next_proto_module
}
/main.grpc.pb.h"
)
#
"${CMAKE_CURRENT_BINARY_DIR}/include/caosdb/${next_proto_module}/main.grpc.pb.h")
install
(
FILES
${
next_proto_hdr
}
${
next_grpc_hdr
}
DESTINATION
#
install(FILES ${next_proto_hdr} ${next_grpc_hdr} DESTINATION
${
libcaosdb_INCLUDE_DEST
}
/
${
next_proto_module
}
)
#
${libcaosdb_INCLUDE_DEST}/${next_proto_module})
endforeach
()
#
endforeach()
install
(
FILES
${
PROJECT_SOURCE_DIR
}
/caosdbConfig.cmake
#
install(FILES ${PROJECT_SOURCE_DIR}/caosdbConfig.cmake
DESTINATION
${
libcaosdb_CMAKE_DEST
}
)
#
DESTINATION ${libcaosdb_CMAKE_DEST})
#set_property(TARGET caosdb PROPERTY VERSION ${libcaosdb_VERSION})
#
#set_property(TARGET caosdb PROPERTY VERSION ${libcaosdb_VERSION})
include
(
CMakePackageConfigHelpers
)
#
include(CMakePackageConfigHelpers)
write_basic_package_version_file
(
#
write_basic_package_version_file(
"
${
PROJECT_SOURCE_DIR
}
/caosdbConfigVersion.cmake"
#
"${PROJECT_SOURCE_DIR}/caosdbConfigVersion.cmake"
VERSION
${
libcaosdb_VERSION
}
#
VERSION ${libcaosdb_VERSION}
COMPATIBILITY AnyNewerVersion
#
COMPATIBILITY AnyNewerVersion
)
#
)
install
(
FILES
${
PROJECT_SOURCE_DIR
}
/caosdbConfigVersion.cmake
#
install(FILES ${PROJECT_SOURCE_DIR}/caosdbConfigVersion.cmake
DESTINATION
${
libcaosdb_CMAKE_DEST
}
)
#
DESTINATION ${libcaosdb_CMAKE_DEST})
#######################################################
#
#######################################################
### code formatting with clang-format
#
### code formatting with clang-format
#######################################################
#
#######################################################
option
(
AUTOFORMATTING
"call clang-format at configure time"
ON
)
#
option(AUTOFORMATTING "call clang-format at configure time" ON)
if
(
AUTOFORMATTING AND NOT SKIP_LINTING
)
#
if(AUTOFORMATTING AND NOT SKIP_LINTING)
find_program
(
clang_format NAMES clang-format-11 clang-format
)
#
find_program(clang_format NAMES clang-format-11 clang-format)
file
(
GLOB format_test_sources test/*.cpp test/*.h test/*.h.in
)
#
file(GLOB format_test_sources test/*.cpp test/*.h test/*.h.in)
execute_process
(
COMMAND
${
clang_format
}
-i --verbose
${
libcaosdb_INCL
}
#
execute_process(COMMAND ${clang_format} -i --verbose ${libcaosdb_INCL}
${
libcaosdb_SRC
}
${
libcaosdb_TEST_SRC
}
#
${libcaosdb_SRC} ${libcaosdb_TEST_SRC}
${
PROJECT_SOURCE_DIR
}
/src/cxxcaosdbcli.cpp
#
${PROJECT_SOURCE_DIR}/src/cxxcaosdbcli.cpp
${
PROJECT_SOURCE_DIR
}
/src/ccaosdbcli.c
#
${PROJECT_SOURCE_DIR}/src/ccaosdbcli.c
${
PROJECT_SOURCE_DIR
}
/src/ccaosdb.cpp
#
${PROJECT_SOURCE_DIR}/src/ccaosdb.cpp
${
PROJECT_SOURCE_DIR
}
/include/ccaosdb.h
#
${PROJECT_SOURCE_DIR}/include/ccaosdb.h
${
format_test_sources
}
#
${format_test_sources}
WORKING_DIRECTORY
${
PROJECT_SOURCE_DIR
}
)
#
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif
()
#
endif()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment