cmakenewbie
cmakenewbie

Reputation: 3

Linking and Add Executable on CMAKE?

I am learning CMAKE and the example I have has both link_directories before and after add_executable. My question is: how does the process work? Which is supposed to go first and what is the purpose of one going before the other?

Upvotes: 0

Views: 115

Answers (1)

Marco
Marco

Reputation: 131

Not sure if this order matter. Probably not. "link_directories" will tell the compiler where to look for the libraries you desire to use. The names of the libraries you put in "target_link_libraries" command.

Actually, with CMake, "link_directories" is not used too often. Usually you use a module script to find your libraries with "find_package" (e.g., findCUDA, findJPEG, etc...) and pass to "target_link_libraries" the variables defined by these scripts containing the full path of each library.

Upvotes: 1

Related Questions