[CMake] Add -lrt at the end of link.txt

Jakub Zakrzewski jzakrzewski at e2e.ch
Wed Jan 8 02:42:00 EST 2014


Hello,
I recommend reading some kind of CMake tutorial to get at least the basic concepts. In the mean time:

--- CMakeLists.txt ---
cmake_minimum_required(VERSION 2.8.6)
project(oci_object_test)

set(ORCLIB_HOME /home/jzakrzewski/local/ocilib/usr/local)

include_directories(${ORCLIB_HOME}/include)
link_directories(${ORCLIB_HOME}/lib64)

link_directories(/usr/lib/oracle/11.2/client64/lib)

set(SOURCES
	main.cpp
)

add_executable(demo ${SOURCES})
target_link_libraries(demo clntsh ocilib)
--- CMakeLists.txt ---

In this example I have only one target "demo" - created on the second-to-last line.
On the last line I link it with two libraries. This will add -lclntsh and -locilib to linker command.

Note, that normally one would use some automation like FindXXX to discover location of linked libraries. I intend to run this quick test program only on my machine, so hardcoding paths is ok for me.


-----Original Message-----
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of Cedric Doucet
Sent: Dienstag, 7. Januar 2014 16:39
To: Rolf Eike Beer
Cc: cmake at cmake.org
Subject: Re: [CMake] Add -lrt at the end of link.txt


Thank you very much for your answer.
I am sorry I am a beginner in cmake.
What does target represent and where can I find it in CMakeLists.txt?
Best regards,
Cédric Doucet


----- Mail original -----
> De: "Rolf Eike Beer" <eike at sf-mail.de>
> À: cmake at cmake.org
> Envoyé: Mardi 7 Janvier 2014 16:18:47
> Objet: Re: [CMake] Add -lrt at the end of link.txt
> 
> Am 07.01.2014 12:56, schrieb Cedric Doucet:
> > He llo,
> > 
> > I would like to know how to add "-lrt" at the end of link.txt.
> > I tried to do that by modifying CMakeLists.txt.
> > I added the following lines:
> > --------------------------------------------------------------------
> > --------------------------------------------
> > list(APPEND CMAKE_CXX_FLAGS "-lrt")
> > list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS) string(REPLACE ";" " " 
> > CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS 
> > "${CMAKE_CXX_FLAGS}")
> > --------------------------------------------------------------------
> > --------------------------------------------
> > However, it does not work.
> > 
> > Anybody have an idea?
> 
> target_link_libraries(my_target_that_needs_rt rt)
> 
> HTH,
> 
> Eike
> --
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Kitware offers various services to support the CMake community. For 
> more information on each offering, please visit:
> 
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
> 
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
> 
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list