FindCGNS.cmake
Go to the documentation of this file.
1 #
2 # Find the native CGNS includes and library
3 #
4 # CGNS_INCLUDE_DIR - where to find cgns.h, etc.
5 # CGNS_LIBRARIES - List of fully qualified libraries to link against when using CGNS.
6 # CGNS_FOUND - Do not attempt to use CGNS if "no" or undefined.
7 
8 find_path(CGNS_INCLUDE_DIR
9  NAMES
10  cgnslib.h
11  PATHS
12  /usr/local/include
13  /usr/include
14  DOC "CGNS include directory")
15 mark_as_advanced(CGNS_INCLUDE_DIR)
16 
17 find_library(CGNS_LIBRARY
18  NAMES
19  cgns
20  DOC "CGNS library")
21 mark_as_advanced(CGNS_LIBRARY)
22 
23 if (CGNS_INCLUDE_DIR)
24  file(STRINGS "${CGNS_INCLUDE_DIR}/cgnslib.h" version
25  REGEX "CGNS_DOTVERS")
26  string(REGEX REPLACE ".*CGNS_DOTVERS *\([0-9.]*\).*" "\\1" CGNS_VERSION "${version}")
27  unset(version)
28 else ()
29  set(CGNS_VERSION CGNS_VERSION-NOTFOUND)
30 endif ()
31 
32 # handle the QUIETLY and REQUIRED arguments and set CGNS_FOUND to TRUE if
33 # all listed variables are TRUE
34 include(FindPackageHandleStandardArgs)
35 find_package_handle_standard_args(CGNS
36  REQUIRED_VARS CGNS_INCLUDE_DIR CGNS_LIBRARY
37  VERSION_VAR CGNS_VERSION)
38 
39 if (CGNS_FOUND)
40  set(CGNS_LIBRARIES "${CGNS_LIBRARY}")
41  set(CGNS_INCLUDE_DIRS "${CGNS_INCLUDE_DIR}")
42  if (NOT TARGET CGNS::CGNS)
43  add_library(CGNS::CGNS UNKNOWN IMPORTED)
44  set_target_properties(CGNS::CGNS PROPERTIES
45  IMPORTED_LOCATION "${CGNS_LIBRARY}"
46  INTERFACE_INCLUDE_DIRECTORIES "${CGNS_INCLUDE_DIR}")
47  endif ()
48 endif ()
string