LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-06-2009, 05:51 PM   #1
yfaye
LQ Newbie
 
Registered: Apr 2009
Posts: 12

Rep: Reputation: 0
cmake question


I am trying to write a CMakeList.txt for a project (A). The project needs to use the library of another project (B). For gcc, using -L <path> -ldl works. How can I convert that into cmake file?

I tried include_directories, that doesn't seem to work

ThX
 
Old 04-06-2009, 06:00 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
If it's not something external like SDL, OpenGL, or Boost, you can use TARGET_LINK_LIBRARIES. I can't really help you without details (like the CMakeLists.txt you've already written).
 
Old 04-06-2009, 06:48 PM   #3
yfaye
LQ Newbie
 
Registered: Apr 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Can't log in to my work machine now. will post the CMakeLists.txt tomorrow.

If use TARGET_LINK_LIBRARIES, do I need to specific all the binaries or just including the dir name is fine?

For example, project B has a binary dir contating lib, bin, share... Each of the dir have multiple files. Can I just say

TARGET_LINK_LIBRARIES(A, /binary_path/B)?

Quote:
Originally Posted by tuxdev View Post
If it's not something external like SDL, OpenGL, or Boost, you can use TARGET_LINK_LIBRARIES. I can't really help you without details (like the CMakeLists.txt you've already written).

Last edited by yfaye; 04-06-2009 at 06:49 PM.
 
Old 04-09-2009, 09:24 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Here are the links I suggested in your other post:

Here's an example from one of the links:
Quote:
# Make sure the compiler can find include files from our Hello library.
include_directories (${HELLO_SOURCE_DIR}/Hello)

# Make sure the linker can find the Hello library once it is built.
link_directories (${HELLO_BINARY_DIR}/Hello)

# Add executable called "helloDemo" that is built from the source files
# "demo.cxx" and "demo_b.cxx". The extensions are automatically found.
add_executable (helloDemo demo.cxx demo_b.cxx)

# Link the executable to the Hello library.
target_link_libraries (helloDemo Hello)
And here's the same example, showing the equivalent "C/Make" syntax you're used to:
Quote:
# -I$(HELLO_SOURCE_DIR)/Hello
include_directories (${HELLO_SOURCE_DIR}/Hello)

# -L$(HELLO_BINARY_DIR)/Hello
link_directories (${HELLO_BINARY_DIR}/Hello)

# -lhelloDemo -lHello
target_link_libraries (helloDemo Hello)
'Hope that helps .. PSM

Last edited by paulsm4; 04-09-2009 at 09:26 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
could use some help with cmake,lmms-extras rixtr66 Slackware 5 11-20-2008 09:45 AM
PBuilder error after cmake Patrick793 Linux - Software 0 10-13-2008 05:11 PM
CMake can't load a file guille4ty Linux - Software 2 08-10-2008 05:35 AM
LXer: Using eCos with CMake LXer Syndicated Linux News 0 11-28-2006 01:24 AM
installation of 'cmake' software soupy Linux - Newbie 2 08-01-2005 01:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration