cnrt.cmake 1.6 KB
Newer Older
1 2
find_library(CNRT_LIBRARY 
    NAMES libcnrt.so
3 4
    PATHS ${ALTER_LD_LIBRARY_PATHS} "$ENV{NEUWARE_HOME}/lib64" ${CMAKE_INSTALL_PREFIX}
    HINTS ${ALTER_LIBRARY_PATHS}
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
    PATH_SUFFIXES lib lib64
    DOC "CNRT library." )

if(CNRT_LIBRARY STREQUAL "CNRT_LIBRARY-NOTFOUND")
    message(FATAL_ERROR "Can not find CNRT Library")
endif()

get_filename_component(__found_cnrt_root "${CNRT_LIBRARY}/../include" REALPATH)
find_path(CNRT_INCLUDE_DIR 
    NAMES cnrt.h
    HINTS "$ENV{NEUWARE_HOME}/include" ${__found_cnrt_root}
    PATH_SUFFIXES include 
    DOC "Path to CNRT include directory." )

if(CNRT_INCLUDE_DIR STREQUAL "CNRT_INCLUDE_DIR-NOTFOUND")
    message(FATAL_ERROR "Can not find CNRT Library")
endif()

file(STRINGS "${CNRT_INCLUDE_DIR}/cnrt.h" CNRT_MAJOR REGEX "^#define CNRT_MAJOR_VERSION [0-9]+.*$")
file(STRINGS "${CNRT_INCLUDE_DIR}/cnrt.h" CNRT_MINOR REGEX "^#define CNRT_MINOR_VERSION [0-9]+.*$")
file(STRINGS "${CNRT_INCLUDE_DIR}/cnrt.h" CNRT_PATCH REGEX "^#define CNRT_PATCH_VERSION [0-9]+.*$")

string(REGEX REPLACE "^#define CNRT_MAJOR_VERSION ([0-9]+).*$" "\\1" CNRT_VERSION_MAJOR "${CNRT_MAJOR}")
string(REGEX REPLACE "^#define CNRT_MINOR_VERSION ([0-9]+).*$" "\\1" CNRT_VERSION_MINOR "${CNRT_MINOR}")
string(REGEX REPLACE "^#define CNRT_PATCH_VERSION ([0-9]+).*$" "\\1" CNRT_VERSION_PATCH "${CNRT_PATCH}")
set(CNRT_VERSION_STRING "${CNRT_VERSION_MAJOR}.${CNRT_VERSION_MINOR}.${CNRT_VERSION_PATCH}")

add_library(libcnrt SHARED IMPORTED)

set_target_properties(libcnrt PROPERTIES
    IMPORTED_LOCATION ${CNRT_LIBRARY}
    INTERFACE_INCLUDE_DIRECTORIES ${CNRT_INCLUDE_DIR}
)

39
message(STATUS "Found CNRT: ${__found_cnrt_root} (found version: ${CNRT_VERSION_STRING})")
40