﻿# NOTICE CMAKE HAS THREE VARIANT
# HELLO_INCLUDE_DIR -- <NAME>_INCLUDE_DIR
# HELLO_LIBRARY     -- <NAME>_LIBRARY
# HELLO_FOUND	    -- <NAME>_FOUND

#  惯例需要定义这3个变量，命名规则如上，以便与cmake预定义的cmake模块中的变量名统一

# FIND_PATH AND FIND_LIBRARY,一定要是.h文件和lib文件所在的当前目录，否则找不到
FIND_PATH(HELLO_INCLUDE_DIR HELLO.H ../../T3/LIB_HELLO)
#find_path(HELLO_INCLUDE_DIR NAMES ../../T3/LIB_HELLO/HELLO.H)
MESSAGE(STATUS "HELLO_INCLUDE_DIR:" ${HELLO_INCLUDE_DIR})

# 切换下列命令，需要清除cache，否则无效
#FIND_LIBRARY(HELLO_LIBRARY HELLO ../../T3/LIB)  #动态链接
FIND_LIBRARY(HELLO_LIBRARY  HELLO_static.lib   ../../t3/lib)
MESSAGE(STATUS "HELLO_LIBRARY:" ${HELLO_LIBRARY})

IF(HELLO_INCLUDE_DIR)
MESSAGE(STATUS "HELLO_INCLUDE_DIR FONND:" ${HELLO_INCLUDE_DIR})
ENDIF(HELLO_INCLUDE_DIR)

IF(HELLO_LIBRARY)
 MESSAGE(STATUS "HELLO_LIBRARY FOUND:" ${HELLO_LIBRARY})
ENDIF(HELLO_LIBRARY)

IF(HELLO_INCLUDE_DIR AND HELLO_LIBRARY)
MESSAGE(STATUS "HELLO FIND 1___________________")
 SET(HELLO_FOUND TRUE)
ENDIF(HELLO_INCLUDE_DIR AND HELLO_LIBRARY)

IF(HELLO_FOUND)
MESSAGE(STATUS "HELLO FIND 2___________________")
ENDIF(HELLO_FOUND)


Message(STATUS "cmake_include_apth: ${CMAKE_INCLUDE_PATH}")
Message(STATUS "cmake_library_apth: ${CMAKE_LIBRARY_PATH}")
Message(STATUS "cmake_module_apth: ${CMAKE_MODULE_PATH}")
Message(STATUS " lib: ${HELLO_LIBRARIES}")
IF(HELLO_FOUND)
# IF FIND_PACKAGE CMD NOT USE "QUIET" PARAM ,USE BELOW:
   IF(NOT HELLO_FIND_QUIETLY)
	MESSAGE(STATUS "FOUND HELLO: ${HELLO_LIBRARY}")

   ENDIF(NOT HELLO_FIND_QUIETLY)
ELSE(HELLO_FOUND)
   # 如果FIND_PACKAGE命令指定了REQUIRED参数，说明这个库是此Project必须的
   # 对应下面的HELLO_FIND_REQUIRED变量
 IF (HELLO_FIND_REQUIRED)
        MESSAGE(FATAL_ERROR "Could not find hello library")
    ENDIF (HELLO_FIND_REQUIRED)
ENDIF (HELLO_FOUND)
