0

I am creating a static library and which in turns depends on other libraries. I am making this library on Windows platform. I am new to cmake but have tried like this:

set(Agent17_LIB Agent17Lib)
add_library(${Agent17_LIB} "${PROJECT_SOURCE_DIR}/Agent17Lib.cpp")


find_library(awscppiotsdklib aws-iot-sdk-cpp.lib ${PROJECT_SOURCE_DIR}/../Libs/aws-iot-device-sdk-cpp/build-64/archive/Debug)
MESSAGE( STATUS "awscppiotsdklib path:         " ${awscppiotsdklib} )

find_library(awscppsdkcorelib aws-cpp-sdk-core.lib ${PROJECT_SOURCE_DIR}/../Libs/aws-cpp-sdk-core/Debug)
MESSAGE( STATUS "awscppsdkcorelib path:         " ${awscppsdkcorelib} )

find_library(awscppsdks3lib aws-cpp-sdk-s3.lib ${PROJECT_SOURCE_DIR}/../Libs/aws-cpp-sdk-s3/Debug)
MESSAGE( STATUS "awscppsdks3lib path:         " ${awscppsdks3lib} )

find_library(awscppsdkstslib aws-cpp-sdk-sts.lib ${PROJECT_SOURCE_DIR}/../Libs/aws-cpp-sdk-sts/Debug)
MESSAGE( STATUS "awscppsdkstslib path:         " ${awscppsdkstslib} )

find_library(libcurllib libcurld.lib ${PROJECT_SOURCE_DIR}/../Libs/Curl)
MESSAGE( STATUS "libcurllib path:         " ${libcurllib} )

find_library(ssleay32MDlib ssleay32MD.lib ${PROJECT_SOURCE_DIR}/../Libs/OpenSSL-Win64/lib/VC)
MESSAGE( STATUS "ssleay32MDlib path:         " ${ssleay32MDlib} )

find_library(libeay32MDlib libeay32MD.lib ${PROJECT_SOURCE_DIR}/../Libs/OpenSSL-Win64/lib/VC)
MESSAGE( STATUS "libeay32MDlib path:         " ${libeay32MDlib} )

target_link_libraries (${Agent17_LIB} awscppiotsdklib awscppsdkcorelib awscppsdks3lib awscppsdkstslib libcurllib ssleay32MDlib libeay32MDlib)

But looks like my target library-Agent17_LIB is getting created without including the other libraries.

Any help appreciated. I am stuck at this point.

The output I got is:

$ cmake -G "Visual Studio 15 2017 Win64" ../.
-- The CXX compiler identification is MSVC 19.13.26131.1
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/bin/Hostx86/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/bin/Hostx86/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- awscppiotsdklib path: C:/Work/rits-git-working/Libs/aws-iot-device-sdk-cpp/build-64/archive/Debug/aws-iot-sdk-cpp.lib
-- awscppsdkcorelib path: C:/Work/rits-git-working/Libs/aws-cpp-sdk-core/Debug/aws-cpp-sdk-core.lib
-- awscppsdks3lib path: C:/Work/rits-git-working/Libs/aws-cpp-sdk-s3/Debug/aws-cpp-sdk-s3.lib
-- awscppsdkstslib path: C:/Work/rits-git-working/Libs/aws-cpp-sdk-sts/Debug/aws-cpp-sdk-sts.lib
-- libcurllib path: C:/Work/rits-git-working/Libs/Curl/libcurld.lib
-- ssleay32MDlib path: C:/Work/rits-git-working/Libs/OpenSSL-Win64/lib/VC/ssleay32MD.lib
-- libeay32MDlib path: C:/Work/rits-git-working/Libs/OpenSSL-Win64/lib/VC/libeay32MD.lib
-- CMAKE_BINARY_DIR path: C:/Work/rits-git-working/Agent17Lib/build
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Work/rits-git-working/Agent17Lib/build

Is there a way from cmake to update Librarian section of project properties for a visual studio project? If I update Librarian section manually then I am able to create the master library successfully, but I am not able to figure out how to update Librarian from cmake.

Ritesh
  • 91
  • 2
  • 10
  • 1
    Static libraries are not actually linked to other libraries (This is a compiler/linker feature, not a feature of CMake). If you want incorporate several static libraries into one, you should use specific tools. See e.g. [this question](https://stackoverflow.com/questions/5445023/c-can-you-build-one-static-library-into-another) and answers to it. – Tsyvarev May 15 '18 at 07:24
  • @Tsyvarev - I have created my master library using Visual studio and I am able to make use of master library (which has been linked with other libraries) from my test application. But now I want to do same using the cmake. – Ritesh May 15 '18 at 08:14
  • target_link_libraries() is not meant for linking other libraries into the target library? – Ritesh May 15 '18 at 08:15
  • In Visual studio I have updated project properties for Librarian tab and added the additional dependencies there. – Ritesh May 15 '18 at 08:25

0 Answers0