2012/6/20 Ateljevich, Eli <[email protected]>:
> Hi everone. I am getting a funny include flag and I wonder if anyone can
> help. The project is in Fortran (though I don't think this matters) and the
> structure can be distilled to:
>
> /myproj
> /build
> /src
> /Hydro
>
> I do the build in /build in linux using "cmake -DCMAKE_Fortran_COMPILER
> ../src".
>
> The /src and /src/Hydro CMakeLists.txt are given below and I try to include
> and link to the external netcdf library which is where I say it is -- I use
> the same envvar in a GNU makefile system. The library includes are actually
> needed in only the third file sflux_9c.F90, and it is on this file that the
> build fails:
>
> cd /home/myproj_cmake/build/Hydro &&
> /usr/local/dms/pkg/openmpi/1.4.3-intel12.0/bin/mpif90 -o
> CMakeFiles/Hydro.dir/sflux_9c.F90.o
> -I/home/myproj_cmake/src/Hydro/-I/usr/local/dms/pkg/netcdf/4.1.3-intel12.0-parallel/include
> -c /home/myproj_cmake/src/Hydro/sflux_9c.F90
>
> Could it be because the two -I includes are glued together? Come to think of
> it, I did nothing to request the -I/home/myproj_cmake/src/Hydro/ part though
> I don't object to it. Can someone explain what I am doing wrong or give me a
> workaround?
I think you misuse some CMake directive, keep reading...
>
> Very grateful,
> Eli
>
> ========= /src
> cmake_minimum_required (VERSION 2.6)
> project(MYPROJ)
> enable_language (Fortran)
>
> # Recurse into module libraries
> add_subdirectory( Hydro )
>
> ========= /src/Hydro
> add_library(Hydro file1.F90 file2.F90 sflux_9c.F90)
>
>
> # Make sure the compiler can find include files from our Hydro library.
> include_directories ( $(NETCDF_INC) )
>
> # Make sure the linker can find the Hydro library once it is built.
> link_directories ( ${SELFE_BINARY_DIR}/Hydro )
This previous one is wrong, link_directories is seldom used for your
own library.
The forthcoming
target_link_libraries (mymain Hydro)
is enough for CMake to find how to link "mymain" to "Hydro" lib.
Try removing this "link_directories" line.
> add_executable ( mymain mymain.F90 )
>
> # Link the executable to the Hydro library.
> target_link_libraries (mymain Hydro $(NETCDF_INC) )
This statement looks wrong as well
NETCDF_INC must a path to an include directory not a path
to a library?
What you probably need is
target_link_libraries (mymain Hydro $(NETCDF_LIBRARY) )
with NETCDF_LIBRARY being the full path to the NETCDF library.
--
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake