Re: [CMake] Why is XXX_INCLUDE_DIRS plural and should it be deep?

2012-12-13 Thread Lori A. Pritchett-Sheats
My $0.02..I just completed a CMake system for a code project that 
required several TPLs (third party libraries) two of which were the 
NetCDF and HDF5.  I struggled with the same problems you mention here. 
When I wrote my FindXXX modules, the standard I adopted was, 
XXX_INCLUDE_DIR only contained the path to the XXX include directory 
while XXX_INCLUDE_DIRS contained XXX include directory any other TPL 
include directory required to compile.   Parts of the code was calling 
NetCDF directly but not HDF5. I wanted the project CMakeLists.txt files 
to be as clean as possible and placed the logic to determine if NetCDF 
had HDF5 and adjusted the NetCDF_INCLUDE_DIRS if needed in our 
FindNetCDF module. This allowed the developers to simply put


find_package(NetCDF)
include_directories(NetCDF_INCLUDE_DIRS)

in their CMakeLists.txt files not worry about testing for HDF5, etc. 
This complicated the FindNetCDF module, but I think it improved the 
stability of our CMake system.


If you decide not to cascade, then you will need to provide a flag like 
you mention in (1) to help out whoever calls your module,  so they can 
call find_package(HDF5) when needed.


When NetCDF split the language APIs, I used  the FindMPI module as a 
template and created NetCDF_C_* NetCDF_CXX_* NetCDF_Fortran_* variables 
in the FindNetCDF module. You may what to look at how that module 
handles different language libraries and include directories  for 
inspiration.



Good luck!




On 12/12/12 17:35, esatel wrote:

Hi all,
I am trying to adapt an existing FindNetCDF.cmake file to work with NetCDF
4.2. I have read the Modules/Readme.txt but I am still a little unclear to
the best approach in my case.

In 4.2 the Fortran bindings and C bindings are not necessarily installed in
the same place. One motive for NetCDF_INCLUDE_DIRS to be plural is that
there might be a NetCDF_C_INCLUDE_DIR and a NetCDF_Fortran_INCLUDE_DIR that
together form NetCDF_INCLUDE_DIRS.

There is a second motive that I am less clear on. The FindNetCDF.cmake files
I have seen handle the HDF5 dependency differently:
1. One sets a variable NETCDF_HAS_HDF5 by querying a config executable but
does nothing else.
2. The other sets a similar variable but then does find_package on HDF5 and
loads the dependencies into NetCDF_INCLUDE_DIRS and NetCDF_LIBRARIES.

This design (2) cascades. FindHDF5.cmake represents a similar decision about
whether to find_package its dependencies like the zlib compression library.
I believe the one in the cmake distro doesn't do that.

What is the best practice here? To handle dual locations for the library at
hand or to accumulate or both? The first seems unavoidable ... the second
seems to be an unevenly applied standard.

Thanks
Eli



--
View this message in context: 
http://cmake.3232098.n2.nabble.com/Why-is-XXX-INCLUDE-DIRS-plural-and-should-it-be-deep-tp7582623.html
Sent from the CMake mailing list archive at Nabble.com.
--

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



--
Lori A. Pritchett-Sheats, PhD.
CCS-2, Computational Physics and Methods
Office: 505-665-6675
Fax: 505-665-4972

Los Alamos National Laboratory
P.O. Box 1663
MS D413
Los Alamos, NM 87544

--

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


Re: [CMake] How to use CMAKE_POLICY?

2012-12-13 Thread David Cole
You could use if(POLICY (if 2.6.2 supports that... I think it does, but it
was very long ago..) to avoid the call on older CMakes.


On Thu, Dec 13, 2012 at 6:31 AM, Marcel Loose  wrote:

> Hi all,
>
> I'm trying to figure out how to use the CMAKE_POLICY() command. I want to
> get rid of the warning on CMP0017. I've strategically placed
> "cmake_policy(PUSH)", "cmake_policy(SET CMP0017 OLD)", and
> "cmake_policy(POP)" which solves the problem when configuring with CMake
> 2.8.9.
>
> However, our project also needs to be compatible with CMake 2.6.2. The
> problem is that this older CMake now bails out with an error message:
>
> CMake Error at CMake/FindLAPACK.cmake:44 (cmake_policy):
>   Policy "CMP0017" is not known to this version of CMake.
>
> This sounds like a catch-22. I've fixed the warning for the new CMake, but
> get an error in return for the old CMake. What am I doing wrong??
>
> Best regards,
> Marcel Loose.
>
>
> --
>
> 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
>
--

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

[CMake] How to use CMAKE_POLICY?

2012-12-13 Thread Marcel Loose

Hi all,

I'm trying to figure out how to use the CMAKE_POLICY() command. I want 
to get rid of the warning on CMP0017. I've strategically placed 
"cmake_policy(PUSH)", "cmake_policy(SET CMP0017 OLD)", and 
"cmake_policy(POP)" which solves the problem when configuring with CMake 
2.8.9.


However, our project also needs to be compatible with CMake 2.6.2. The 
problem is that this older CMake now bails out with an error message:


CMake Error at CMake/FindLAPACK.cmake:44 (cmake_policy):
  Policy "CMP0017" is not known to this version of CMake.

This sounds like a catch-22. I've fixed the warning for the new CMake, 
but get an error in return for the old CMake. What am I doing wrong??


Best regards,
Marcel Loose.

<>--

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

[CMake] Linking library with custom target

2012-12-13 Thread Reza Housseini
Hello

I want to link a library to a custom target:

add_custom_command(
  OUTPUT ${FILE}
  DEPENDS ${SRC}
  COMMAND ${EXECUTABLE}
  ARGS ${SRC}
  COMMENT "Generating ${FILE}"
  VERBATIM)

add_custom_target(mytarget ALL
  DEPENDS ${FILE})

target_link_libraries(mytarget /usr/local/lib/libmylib.so)

But it don't seems to work instead I have to use:

add_custom_command(
  OUTPUT ${FILE}
  DEPENDS ${SRC}
  COMMAND ${EXECUTABLE}
  ARGS ${SRC}
  ARGS -I${CPPLIB_INCLUDE_DIR} -L${CPPLIB_DIR} -lmylib
  COMMENT "Generating ${FILE}"
  VERBATIM)

add_custom_target(mytarget ALL
  DEPENDS ${FILE})

Why is this so? Can't I use target_link_library with add_custom_target?

Thnaks for clarification!

Cheers Reza
--

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