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

Eric Noulard eric.noulard at gmail.com
Thu Jun 21 02:36:04 EDT 2012


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