Libraries and dependencies in C++ Ubuntu - c++

Hi recently i got invited to a school project, for that i installed WSM with ubuntu on my computer, after that i git cloned the project and tried to build it with cmake, the problem occurs after i try to make, libraries that should be included in c++ packages that i already installed are always missing, some of those libraries are: vector; algorithm; ETC.
The type of errors that i get are:
/home/bruno/projetos/MISEN/ImageSearch/src/rbisen/SseIee.cpp:4:10: fatal error: algorithm: No such file or directory
4 | #include <algorithm>
The same errors occurs with vector and a bunch of other libraries.
What could i be missing in my instalation that is causing this problem.
Thanks in advance
CMAKE:
# sgx vars
if (NOT DEFINED ENV{SGX_SDK})
set(SGX_SDK "/opt/intel/sgxsdk")
else()
set(SGX_SDK $ENV{SGX_SDK})
endif ()
# include paths for the sgx versions of standard libs
set(SGX_INCLUDE_PATHS ${SGX_SDK}/include ${SGX_SDK}/include/libcxx ${SGX_SDK}/include/tlibc)
# flags
set(DEBUG_FLAGS "-g -O0")
if (SIMULATED_MODE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DEBUG_FLAGS} -Wno-pointer-arith -c -Wall -fPIC -Wall -m64 -fvisibility=hidden -fpie -fstack-protector")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DEBUG_FLAGS} -Wno-pointer-arith -c -Wall -fPIC -Wall -m64 -fvisibility=hidden -fpie -fstack-protector -fno-builtin-function -nostdinc++")
endif ()
set(CMAKE_CXX_STANDARD 11)
set(KMEANS_DIR ${EXTERN_DIR}/src/training/seq-kmeans)
# sources
set(KMEANS_SRCS ${KMEANS_DIR}/kmeans.cpp)
set(UTIL_SRCS ${EXTERN_DIR}/src/parallel.cpp ${EXTERN_DIR}/src/scoring.cpp ${EXTERN_DIR}/src/img_processing.cpp ${EXTERN_DIR}/src/util.cpp ${EXTERN_DIR}/src/training/lsh/lsh.cpp)
# define target library
add_library(${EXTERN_LIB_NAME}
${EXTERN_DIR}/src/rbisen/util/IeeUtils.cpp ${EXTERN_DIR}/src/rbisen/util/vec_int.cpp ${EXTERN_DIR}/src/rbisen/util/vec_token.cpp
${EXTERN_DIR}/src/rbisen/QueryEvaluator.cpp ${EXTERN_DIR}/src/rbisen/SseIee.cpp
${EXTERN_DIR}/src/trusted.cpp
${EXTERN_DIR}/src/untrusted.cpp
${EXTERN_DIR}/src/training.cpp
${EXTERN_DIR}/src/repository.cpp
${EXTERN_DIR}/src/training/bagofwords.cpp
${EXTERN_DIR}/src/training/util.cpp
${UTIL_SRCS} ${KMEANS_SRCS})
if (SIMULATED_MODE)
target_link_libraries(${EXTERN_LIB_NAME} trusted_util)
else()
target_link_libraries(${EXTERN_LIB_NAME})
endif ()
if (SIMULATED_MODE)
target_include_directories(${EXTERN_LIB_NAME} PRIVATE ${EXTERN_DIR} ${EXTERN_DIR}/src ${KMEANS_DIR} ${FRAMEWORK_INCLUDE_DIR} ${EXTERN_DIR}/src/rbisen ${EXTERN_DIR}/src/rbisen/util)
else()
target_include_directories(${EXTERN_LIB_NAME} PRIVATE ${EXTERN_DIR} ${EXTERN_DIR}/src ${KMEANS_DIR} ${FRAMEWORK_INCLUDE_DIR} ${SGX_INCLUDE_PATHS} ${EXTERN_DIR}/src/rbisen ${EXTERN_DIR}/src/rbisen/util)
endif ()
This is the cmake relative to this part of the project

Related

C++: Problem with M1 architecture in cmake: how do I change the architecture?

I am trying to run cmake command in the new environment.
Upon running cmake . . I get clang: error: the clang compiler does not support '-march=core2' error. I tried to run it with cmake '-DCMAKE_CXX_FLAGS='-march=x86-64'' flag, and it changed the march for a while but only in CLion IDE and only when I was doing that continuously. I can't seem to make it work in the terminal while reading different makefile.
Full error when I run either cmake or ```cmake '-DCMAKE_CXX_FLAGS='-march=x86-64'':
Determining if the C compiler works failed with the following output:
Change Dir: /Users/marcin/CLionProjects/pythontest5/CMakeFiles/CMakeTmp
Run Build Command(s):/Library/Developer/CommandLineTools/usr/bin/make -f Makefile cmTC_925c1/fast && /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_925c1.dir/build.make CMakeFiles/cmTC_925c1.dir/build
Building C object CMakeFiles/cmTC_925c1.dir/testCCompiler.c.o
/Library/Developer/CommandLineTools/usr/bin/gcc -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /opt/homebrew/anaconda3/include -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -MD -MT CMakeFiles/cmTC_925c1.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_925c1.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_925c1.dir/testCCompiler.c.o -c /Users/marcin/CLionProjects/pythontest5/CMakeFiles/CMakeTmp/testCCompiler.c
clang: error: the clang compiler does not support '-march=core2'
make[1]: *** [CMakeFiles/cmTC_925c1.dir/testCCompiler.c.o] Error 1
make: *** [cmTC_925c1/fast] Error 2
My CMakeLists.txt
cmake_minimum_required(VERSION 3.1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
project(automobile VERSION 0.1.0)
# Include dir
include_directories(/usr/local/include)
# Src
AUX_SOURCE_DIRECTORY(src SRC_FILES)
# Headers
set(PROJECT_SOURCE_DIR "src")
set(PROJECT_INCLUDE_DIR "include/automobile_bits")
# Source files
set(SOURCE_FILES
${PROJECT_INCLUDE_DIR}/motorcycle.hpp
${PROJECT_SOURCE_DIR}/motorcycle.cpp
)
# Set up such that XCode organizes the files correctly
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE_FILES})
# Add library
add_library(automobile SHARED ${SOURCE_FILES})
# Include directories
target_include_directories(automobile PRIVATE include/automobile_bits)
# Install
install(TARGETS automobile DESTINATION lib)
# Install the headers
install(FILES include/automobile DESTINATION include)
# Create base directory
install(DIRECTORY include/automobile_bits DESTINATION include)
It's unclear where cmake gets -march=core2 from. Try to remove CMakeCache.txt then re-run cmake ..
If it does not help, try to remove CMakeCache.txt and run cmake . -DCMAKE_OSX_ARCHITECTURES=arm64.

CMake setup with crosscompilation, modules and libs

I am trying to write a proper CMake script for building an embedded project(STM32). Our project structure looks like this:
App/
....Module1/
....Module2/
Core/
....OwnFramework/
........CoreModule1/
........CoreModule2/
....CubeMXGeneratedCode/
........Core/ (there are more files and dirs, but they are not relevant)
...........Src/main.c (only important info is that main is here)
........Drivers/
....Libs/
........Lib1/ (for example ETL)
Right now there is one CMakeLists.txt file in root project dir, but this seems like a bad solution. I've tried adding CMakeLists into App/ and App/Module but then I would get linking errors (while looking at compile_commands I've seen that they were compiled with almost no flags).
./CMakeLists.txt (removed some non-important parts, like set variables that are obvious, so it's little bit shorter)
set(APP_INCLUDE_DIRECTORIES
${APP_DIR}/Module1
${APP_DIR}/Module2
)
set(CORE_INCLUDE_DIRECTORIES
${Core_DIR}/CoreModule1
${Core_DIR}/CoreModule2
)
set(FLAGS
"-Wl,--gc-sections")
set(CPP_FLAGS
"-fno-rtti -fno-exceptions -fno-threadsafe-statics")
set(CPU_PARAMETERS
-mcpu=cortex-m4
-mthumb
-mfpu=fpv4-sp-d16
-mfloat-abi=hard)
set(STARTUP_SCRIPT ${CUBEMX_DIR}/startup_stm32fxxxxx.s)
set(MCU_LINKER_SCRIPT ${CUBEMX_DIR}/STM32Fxxxxxxx_FLASH.ld)
set(CUBEMX_INCLUDE_DIRECTORIES
${CUBEMX_DIR}/Core/Inc
... and some more Inc dirs
set(PROJECT_INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}
${APP_INCLUDE_DIRECTORIES}
${CORE_INCLUDE_DIRECTORIES})
file(GLOB_RECURSE STM32CUBEMX_SOURCES
${CUBEMX_DIR}/Core/*.c
${CUBEMX_DIR}/Drivers/*.c
${CUBEMX_DIR}/Middlewares/Third_Party/FreeRTOS/Source/*.c)
file(GLOB_RECURSE PROJECT_SOURCES FOLLOW_SYMLINKS
${APP_DIR}/*.cpp
${APP_DIR}/*.c
${CORE_DIR}/*.cpp
${CORE_DIR}/*.c)
add_executable(${EXECUTABLE}
${STM32CUBEMX_SOURCES}
${PROJECT_SOURCES}
${STARTUP_SCRIPT})
target_compile_definitions(${EXECUTABLE} PRIVATE
${MCU_MODEL}
USE_HAL_DRIVER)
target_include_directories(${EXECUTABLE} PRIVATE
${CUBEMX_INCLUDE_DIRECTORIES}
${PROJECT_INCLUDE_DIRECTORIES})
target_compile_options(${EXECUTABLE} PRIVATE
${CPU_PARAMETERS}
${FLAGS}
-Wall
-Wextra
-Wpedantic
-Wno-unused-parameter
$<$<COMPILE_LANGUAGE:CXX>:
${CPP_FLAGS}
-Wno-volatile
-Wold-style-cast
-Wuseless-cast
-Wsuggest-override>
$<$<CONFIG:Debug>:-Og -g3 -ggdb>
$<$<CONFIG:Release>:-Og -g0>)
target_link_options(${EXECUTABLE} PRIVATE
-T${MCU_LINKER_SCRIPT}
${CPU_PARAMETERS}
-Wl,-Map=${CMAKE_PROJECT_NAME}.map
--specs=nosys.specs
-Wl,--start-group
-lc
-lm
-lstdc++
-lsupc++
-Wl,--end-group
-Wl,--print-memory-usage)
add_custom_command(TARGET ${EXECUTABLE} POST_BUILD
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${EXECUTABLE}>)
add_custom_command(TARGET ${EXECUTABLE} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O ihex $<TARGET_FILE:${EXECUTABLE}>
${EXECUTABLE}.hex
COMMAND ${CMAKE_OBJCOPY} -O binary $<TARGET_FILE:${EXECUTABLE}>
${EXECUTABLE}.bin)
There is also toolchain file:
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(TOOLCHAIN_PREFIX arm-none-eabi-)
set(FLAGS
"-fdata-sections -ffunction-sections \
--specs=nano.specs -Wl,--gc-sections")
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc ${FLAGS})
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++ ${FLAGS})
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size)
set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
I am building everything with this command:
cmake -B${workspaceFolder}/build -DCMAKE_TOOLCHAIN_FILE=gcc-arm-none-eabi.cmake -DCMAKE_BUILD_TYPE=Debug
And this setup works, but I have a feeling that this is a vary bad way of doing it. When I tried adding subdirectories in App and each module, I've got linking erros due to problems with compile flags (arm none eabi elf uses VFP register arguments linking error).
I am also not sure how well will it work when I start adding libs like Embedded Template Library.
So my question is, how do I add subdirectories so they compile the same way my root CMakeLists does? I've tried doing this following multiple guides and examples like this one: https://github.com/rgujju/STM32_Base_Project/blob/master/modules/simple_module/CMakeLists.txt.
But when I've put this in my App/Module/CMakeLists.txt
set(MODULE_NAME simple_module)
file(GLOB SOURCES ./*.c)
add_library(${MODULE_NAME} STATIC
${SOURCES}
)
target_include_directories(${MODULE_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
${PROJECT_SOURCE_DIR}/include
)
And added add_subdirectory(App) to main, my generated commands for modules where without most of my flags and didn't link.
If anyone has experience with dividing CMake project into modules, libs and subdirectories, I would gladly accept any help.

ld cannot find -latomic or -lstdc++

When trying to compile my project using the toolchain provided by the manufacturer of the hardware I'm developing for, compilation succeeds, however linking fails with the following error messages:
/media/xxx/Data/toolchains/sysroots/x86_64-xxx-linux/usr/bin/arm-xxx-linux-gnueabi/../../libexec/arm-xxx-linux-gnueabi/gcc/arm-xxx-linux-gnueabi/4.8.4/ld: cannot find -latomic
/media/xxx/Data/toolchains/sysroots/x86_64-xxx-linux/usr/bin/arm-xxx-linux-gnueabi/../../libexec/arm-xxx-linux-gnueabi/gcc/arm-xxx-linux-gnueabi/4.8.4/ld: cannot find -lstdc++
However, when building a small test program using the same compiler and linker, everything works.
Below is an excerpt of the important parts of my CMake toolchain file:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
###
# Get $CROSS
###
if (NOT $ENV{CROSS_COMPILE} STREQUAL "")
set(cross $ENV{CROSS_COMPILE}) # WARNING: Ends with a - (minus)
else()
set(cross "arm-xxx-linux-gnueabi-")
endif()
###
# Set CMake sysroot
###
set(CMAKE_SYSROOT $ENV{SDKTARGETSYSROOT})
set(CMAKE_SYSROOT_LINK $ENV{SDKTARGETSYSROOT})
set(CMAKE_SYSROOT_COMPILE $ENV{SDKTARGETSYSROOT})
set(CMAKE_C_COMPILER $ENV{TOOLCHAIN_TOOLSDIR}/${cross}gcc)
set(CMAKE_CXX_COMPILER $ENV{TOOLCHAIN_TOOLSDIR}/${cross}g++)
set(CMAKE_LD $ENV{TOOLCHAIN_TOOLSDIR}/${cross}ld)
set(CMAKE_STRIP $ENV{TOOLCHAIN_TOOLSDIR}/${cross}strip)
set(CMAKE_AR $ENV{TOOLCHAIN_TOOLSDIR}/${cross}ar)
include_directories($ENV{SDKTARGETSYSROOT}/usr/include)
I'm not at liberty to disclose source code, but the source code isn't the issue here as it compiles correctly.
Here's another MWE of the CMakeLists.txt file:
cmake_minimum_required(VERSION 3.10)
project(xxx LANGUAGES CXX VERSION 2.0.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(TARGET_NAME xxx.bin)
include_directories(
include/
${INCLUDE_DIRS}
)
file(GLOB_RECURSE FILES ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)
if (xxx_DEBUG)
add_compile_options(
-Wpedantic
-DDDC_STUB
-fabi-version=6
-Wno-format-security
-Wno-reorder
-ggdb3
-O0
-fpermissive # Test
-fPIC
#-static-libstdc++ # with or without, doesn't change the behaviour
#-static-libgcc # with or without, doesn't change the behaviour
)
else()
add_compile_options(
-Wpedantic
-fabi-version=6
-Wno-format-security
-Wno-reorder
-O3
-fpermissive # Test
-fPIC
#-static-libstdc++ # with or without, doesn't change the behaviour
#-static-libgcc # with or without, doesn't change the behaviour
)
endif()
add_executable(${TARGET_NAME} ${FILES} ${MEMWATCH_FILES})
I've tried setting the sysroot-argument for ld, I've tried manually specifying the link (search) path -L$ENV{SDKTARGETSYSROOT}/usr/lib/.debug, and I've also tried hard-wiring the path to the library in question: $ENV{SDKTARGETSYSROOT}/usr/lib/.debug/libatomic.so.1.0.0
Is there another way I can tell ld what libraries to use?
This works perfectly with standard toolchains!
EDIT:
I've now also tried brute-forcing it by creating a symlink from the .debug/libatomic to usr/lib/libatomic. That also hasn't had the desired effect.

How to fix: 'can not be used when making a shared object; recompile with -fPIC' using Cmake. Using plain g++ works

I get a message 'can not be used when making a shared object; recompile with -fPIC'
I have try other examples and the issue is the same.
I have try
changing from MODULE to SHARED
cmake .. -DCMAKE_CXX_FLAGS=-fPIC
and other variations
this works:
c++ -c -fPIC -I/usr/include/python3.6m ../account.cpp
c++ -shared -Wall -Werror -Wl,--export-dynamic account.o -L/usr/local/lib -lboost_python36 -o account.so
Here is the basic cmake
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(Test)
find_package(PythonInterp REQUIRED)
find_package(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} EXACT REQUIRED)
find_package(Boost 1.70.0 COMPONENTS python REQUIRED)
add_library(account SHARED account.cpp)
target_link_libraries(account Boost::python)
target_include_directories(account PRIVATE ${PYTHON_INCLUDE_DIRS})
set_target_properties(account PROPERTIES PREFIX "")
Using: make VERBOSE=1 the output commands are:
c++ -DBOOST_ALL_NO_LIB -Daccount_EXPORTS -I/usr/include/python3.6m -isystem /usr/local/include -fPIC -o CMakeFiles/account.dir/account.cpp.o -c /src/boost_python_example/account.cpp
c++ -fPIC -shared -Wl,-soname,account.so -o account.so CMakeFiles/account.dir/account.cpp.o /usr/local/lib/libboost_python36.a
So the cmake is not getting the same paths and flags, I am learning cmake so Im trying to understand this problem. Clearly the problem is not on actual libs but telling cmake where to find the proper ones.
The solution was quite simple. Comparing both commands what was missing on the cmake command was: --export-dynamic
So I solved using option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON) interesting enough the comment is needed.
Working solution:
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(Test)
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)
find_package(PythonInterp REQUIRED)
find_package(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} EXACT REQUIRED)
find_package(Boost 1.70.0 COMPONENTS python REQUIRED)
add_library(account SHARED account.cpp)
target_link_libraries(account Boost::python)
target_include_directories(account PRIVATE ${PYTHON_INCLUDE_DIRS})
set_target_properties(account PROPERTIES PREFIX "")
Thanks everyone for the comments they lead me to a solution

Linking with thrift

I'm getting undefined reference to 'typeinfo for apache::thrift::transport::TTransportException' (and other symbols) when trying to link my executable with my library which uses thrift. I'm using GCC 7.3.0 on Ubuntu 18.04, building with CMake in CLion
I'm stuck after spending a day googling about this problem and after visiting this, that and this links.
The CMake command looks as following
For my shared object:
TARGET_LINK_LIBRARIES(server INTERFACE
etcdclient
TopologyProtocols
event
${THRIFT_LIBRARIES}
${Boost_LIBRARIES}
lzo2
sqlite3
zmq
${SPDK_LIBS}
${DPDK_LIBS}
grpc
grpc++
gtest
gmock
xml2
stdc++fs
bfd
-l:libisal.so.2
sgutils2
pthread
uuid
rt
)
The executable CMake command:
TARGET_LINK_LIBRARIES(kserver
server
${THRIFT_LIBRARIES}
)
Linker command generated by CMake:
cmake_link_script CMakeFiles/kserver.dir/link.txt --verbose=1
/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/kserver.dir/main.cpp.o -o kserver -L/server/ext/spdk/build/lib -L/server/ext/spdk/dpdk/build/lib -L/server/ext/isal/lib -Wl,-rpath,/server/ext/spdk/build/lib:/server/ext/spdk/dpdk/build/lib:/server/ext/isal/lib:/server/cmake-build-release/lib/proj:/usr/local/lib:/server/cmake-build-release/ext/etcd:/server/cmake-build-release/protocols ../../lib/proj/libproj.so /usr/local/lib/libthrift.so /usr/local/lib/libthriftnb.so ../../ext/etcd/libetcdclient.so ../../protocols/libTopologyProtocols.so /home/user/vcpkg/installed/x64-linux/lib/libprotobuf.a -levent /usr/local/lib/libthrift.so /usr/local/lib/libthriftnb.so /home/user/vcpkg/installed/x64-linux/lib/libboost_system.a -llzo2 /home/user/vcpkg/installed/x64-linux/lib/libsqlite3.a -lpthread -ldl -lzmq -lspdk -ldpdk -lgrpc -lgrpc++ -lgtest -lgmock -lxml2 -lstdc++fs -lbfd -l:libisal.so.2 -lsgutils2 -lpthread -luuid -lrt
The command looks perfectly fine, it links with thrift, thriftnb and event
As of compiler and general projects settings, here a content of root CMakeList.txt in the source root
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/cmake")
SET(CMAKE_CXX_STANDARD 17)
#SET(ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build/lib")
#SET(LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build/lib")
#SET(RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build/bin")
ADD_COMPILE_OPTIONS(
-include server.h
# -Wall
# -pedantic
-march=native
)
ADD_COMPILE_DEFINITIONS(
BOOST_COROUTINES_NO_DEPRECATION_WARNING
GTEST_LINKED_AS_SHARED_LIBRARY
)
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/lib/include/server
${CMAKE_SOURCE_DIR}/lib/include
)
LINK_DIRECTORIES(
${CMAKE_SOURCE_DIR}/ext/spdk/build/lib
${CMAKE_SOURCE_DIR}/ext/spdk/dpdk/build/lib
${CMAKE_SOURCE_DIR}/ext/isal/lib
)
FIND_PACKAGE(Boost REQUIRED COMPONENTS
system)
FIND_PACKAGE(Protobuf REQUIRED)
FIND_PACKAGE(GRPC REQUIRED)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/cmake/FindGRPC.cmake)
FIND_PACKAGE(LZO REQUIRED)
FIND_PACKAGE(sqlite3 REQUIRED)
FIND_PACKAGE(ZeroMQ CONFIG REQUIRED)
FIND_PACKAGE(GTest REQUIRED)
FIND_PACKAGE(Thrift REQUIRED)
ADD_SUBDIRECTORY(lib/server)
ADD_SUBDIRECTORY(ext/etcd)
ADD_SUBDIRECTORY(protocols)
ADD_SUBDIRECTORY(proc/kserver)
Sample compilation command
/usr/bin/c++ -DBOOST_COROUTINES_NO_DEPRECATION_WARNING -DGTEST_LINKED_AS_SHARED_LIBRARY -Dserver_EXPORTS -I/home/user/sourcelib/include/server -I/home/user/sourcelib/include -I/home/user/sourceext/spdk/include -I/home/user/sourcecmake-build-release/ext/etcd -I/home/user/sourcecmake-build-release/protocols -I/home/user/vcpkg/installed/x64-linux/include -O3 -DNDEBUG -fPIC -include server.h -march=native -std=gnu++1z -o CMakeFiles/server.dir/misc/ServerHost.cpp.o -c /home/user/sourcelib/server/misc/ServerHost.cpp
What I'm doing wrong?
It took two days to figure out that there was some esoteric version installed on my machine and the package manager was not aware of it, after removing it manually and using version provided by vcpkg everything linked as expected.