[CMake] Include directory issue ... -I are not separated?

Ateljevich, Eli eli at water.ca.gov
Thu Jun 21 19:25:11 EDT 2012


Thanks, Eric. 

I had plans for adding find_library. I have seen a fair amount about how this is more idiomatic but little about what the disadvantages are in the short run of using an environment variable directly while building up the system.  Perhaps I chose a wrong incremental pathway to getting the project up and running. 

Eli


-----Original Message-----
From: Eric Noulard [mailto:eric.noulard at gmail.com] 
Sent: Wednesday, June 20, 2012 11:36 PM
To: Ateljevich, Eli
Cc: cmake at cmake.org
Subject: Re: [CMake] Include directory issue ... -I are not separated?

2012/6/21 Ateljevich, Eli <eli at water.ca.gov>:
> Eric
> I have improved my envvar usage a bit further, I hope, by saying
> include_directories( $ENV{NETCDF_INC} )
> rather than
> include_directories( ${NETCDF_INC} )

This is not the way CMake is supposed to work.
Normally you use

find_library, file_path, etc... in order to discover the path, lib etc...
you need then you use CMake variable (and not env var) in your CMakeLists.txt

The process of searching third party library and tools is usually bundled in
a separate cmake file call a "FindXXX.cmake" file.

This file can then be loaded using the find_package CMake command.

If you search the web a little bit you'll soon discover that others already
crafted a FindNetCDF.cmake script.

Here is the first I get with my search:
http://gmtrac.soest.hawaii.edu/projects/gmt/repository/revisions/10027/entry/trunk/cmake/modules/FindNETCDF.cmake

I suggest you chose a CMake tutorial:
http://www.cmake.org/Wiki/CMake#Tutorials

and read it thoroughly.
No offense but your questions and answers indicates you lack some
basic CMake knowlegde
that may lead you to misuse CMake and/or get unexpected behavior/error
due to misunderstanding.

Taking the time to read at least one tutorial will save you time in the future.
-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org



More information about the CMake mailing list