[CMake] link_libraries

Ranjeet Kuruvilla ranjeet.kuruvilla at yahoo.com
Sat Apr 21 01:41:59 EDT 2018


I have read that link_libraries command has gotten deprecated for version 3.10 and instead one needs to use link_librariestarget_link_libraries has one major disadvantage, in that it is required to put that statement after add_executable.
I have here a CMake file for many different projects with the same folder structure, that scans a subfolder for files ending with .cmake. Those .cmake files can contain extra includes, definitions and libraries.
With link_libraries I can put all statements inside one .cmake file. With target_link_libraries statement however I need 2 .cmake files, one before add_executable and one after for all the libraries.
So I ask you to keep link_libraries alive!
cmake_minimum_required( VERSION 3.10.0 )

project( ${PROJ_NAME} ${CXX} )enable_language(CXX)
set( CMAKE_VERBOSE_MAKEFILE ON)

set( OPTIMIZING_FLAGS -O2)

set( CUSTOMBUILD "customBuild" )
...include_directories( BEFORE "/usr/local/include/x86_64-linux-gnu")
link_directories( BEFORE "/usr/lib")link_directories( BEFORE "/usr/lib/boost" ...
IF(EXISTS ${ CUSTOMBUILD})    message("Found custom cmake to build")    file( GLOB_RECURSE CMAKE_ITEMS LIST_DIRECTORIES false ${CONST_BASE_PATH_CUSTOMBUILD}*${CMAKE_SUFFIX})    foreach(CMAKE_ITEM ${CMAKE_ITEMS})        message("Add cmake file " ${CMAKE_ITEM})        include(${CMAKE_ITEM})    endforeach(CMAKE_ITEM)endif()...link_libraries( -lqpidclient -lqpidmessaging)
link_libraries( -ljsoncpp)link_libraries( -lpistache)link_libraries( -lboost_system -lboost_thread -lboost_regex -lboost_filesystem -lboost_random -lboost_date_time -lboost_log -lboost_program_options -lboost_signals)link_libraries( -lpulse-simple -lpulse)link_libraries( -lcrypto -lpthread -lcurl)link_libraries( -lgstreamer-1.0 -lgstrtp-1.0 -lgstrtsp-1.0 -lgstsdp-1.0 -lgstbase-1.0 )link_libraries( -lgobject-2.0 -lsigc-2.0)link_libraries( -lssl -levent_openssl)link_libraries( -lcassandra)link_libraries( -lwebsockets)link_libraries( -levent -levent_pthreads -lcrypto -lcrypto++ )link_libraries( -lm -lrt -lz -ldl -lva -lX11 -lm)link_libraries( ${SEASTAR_DIR_LIBS})
add_executable( ${PROJ_NAME} ${SOURCES} )



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180421/cb22a57e/attachment.html>


More information about the CMake mailing list