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

Ateljevich, Eli eli at water.ca.gov
Tue Jun 19 19:00:44 EDT 2012


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?

Very grateful,
Eli 

========= /src
cmake_minimum_required (VERSION 2.6) 
project(MYPROJ)
enable_language (Fortran)

# Recurse into module libraries
add_subdirectory( Hydro )

========= /src/Hydro
dd_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 ) 
add_executable ( mymain mymain.F90 )

# Link the executable to the Hydro library.
target_link_libraries (mymain Hydro $(NETCDF_INC) )





More information about the CMake mailing list