cnml.cmake 1.8 KB
Newer Older
1 2 3 4 5 6 7
find_library(
  CNML_LIBRARY
  NAMES libcnml.so
  PATHS ${ALTER_LD_LIBRARY_PATHS} "$ENV{NEUWARE_HOME}/lib64" ${CMAKE_INSTALL_PREFIX}
  HINTS ${ALTER_LIBRARY_PATHS}
  PATH_SUFFIXES lib lib64
  DOC "CNML library.")
8 9

if(CNML_LIBRARY STREQUAL "CNML_LIBRARY-NOTFOUND")
10
  message(FATAL_ERROR "Can not find CNML Library")
11 12
endif()

13
get_filename_component(__found_cnml_root "${CNML_LIBRARY}/../.." REALPATH)
14 15 16 17 18 19
find_path(
  CNML_INCLUDE_DIR
  NAMES cnml.h
  HINTS "$ENV{NEUWARE_HOME}/include" ${__found_cnml_root}
  PATH_SUFFIXES include
  DOC "Path to CNML include directory.")
20 21

if(CNML_INCLUDE_DIR STREQUAL "CNML_INCLUDE_DIR-NOTFOUND")
22
  message(FATAL_ERROR "Can not find CNML Library")
23 24
endif()

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
file(STRINGS "${CNML_INCLUDE_DIR}/cnml.h" CNML_MAJOR
     REGEX "^#define CNML_MAJOR_VERSION [0-9]+.*$")
file(STRINGS "${CNML_INCLUDE_DIR}/cnml.h" CNML_MINOR
     REGEX "^#define CNML_MINOR_VERSION [0-9]+.*$")
file(STRINGS "${CNML_INCLUDE_DIR}/cnml.h" CNML_PATCH
     REGEX "^#define CNML_PATCH_VERSION [0-9]+.*$")

string(REGEX REPLACE "^#define CNML_MAJOR_VERSION ([0-9]+).*$" "\\1" CNML_VERSION_MAJOR
                     "${CNML_MAJOR}")
string(REGEX REPLACE "^#define CNML_MINOR_VERSION ([0-9]+).*$" "\\1" CNML_VERSION_MINOR
                     "${CNML_MINOR}")
string(REGEX REPLACE "^#define CNML_PATCH_VERSION ([0-9]+).*$" "\\1" CNML_VERSION_PATCH
                     "${CNML_PATCH}")
set(CNML_VERSION_STRING
    "${CNML_VERSION_MAJOR}.${CNML_VERSION_MINOR}.${CNML_VERSION_PATCH}")
40 41 42

add_library(libcnml SHARED IMPORTED)

43 44 45
set_target_properties(
  libcnml PROPERTIES IMPORTED_LOCATION ${CNML_LIBRARY} INTERFACE_INCLUDE_DIRECTORIES
                                                       ${CNML_INCLUDE_DIR})
46

47 48
message(
  STATUS "Found CNML: ${__found_cnml_root} (found version: ${CNML_VERSION_STRING})")