Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ubuntu 是否有生成find<;的方法>;。软件包系统提供的库的cmake文件?_Ubuntu_Cmake - Fatal编程技术网

Ubuntu 是否有生成find<;的方法>;。软件包系统提供的库的cmake文件?

Ubuntu 是否有生成find<;的方法>;。软件包系统提供的库的cmake文件?,ubuntu,cmake,Ubuntu,Cmake,理论上,如果尚未内置到cmake中,那么它应该是简单的。毕竟,apt或rpm知道头文件和目标文件的位置,所以它应该是可行的 我知道cmake应该是跨平台的。但有时它用于只在Linux上运行的项目 我可以将/usr/include硬编码为include,将/usr/lib/x86_64-linux-gnu硬编码为library目录,但在Ubuntu系统上至少还有两个“标准”位置可以包含这些文件,更不用说非标准路径,比如/opt中的路径,我发现了以下cmake文件。到目前为止,它对我有效 #####

理论上,如果尚未内置到cmake中,那么它应该是简单的。毕竟,
apt
rpm
知道头文件和目标文件的位置,所以它应该是可行的

我知道cmake应该是跨平台的。但有时它用于只在Linux上运行的项目


我可以将
/usr/include
硬编码为include,将
/usr/lib/x86_64-linux-gnu
硬编码为library目录,但在Ubuntu系统上至少还有两个“标准”位置可以包含这些文件,更不用说非标准路径,比如
/opt
中的路径,我发现了以下cmake文件。到目前为止,它对我有效

#######################################################################
#
#  This is a basic, generic find_package function intended to find
#  any package with the following conditions:
#
#  (1) The package has a CMake variable associated with it
#      that is a path directory pointing to the installation directory
#      of the package.  It is assumed that the libraries and include
#      files are either contiained within this directory or the
#      sub-directories lib/ or include/, respectively.
#
#  (2) The name(s) of the required library file(s) will be given to
#      the macro as a string list argument, and each will be tested in 
#      sequence.
#
#  (3) The name(s) of the required include file(s) will be given to 
#      the macro as a string list argument, and each will be tested in 
#      sequence.
#
#  (4) For a package with associated environment variable VAR, this
#      macro will define the variables:
#
#        VAR_FOUND - Boolean indicating if all files/libraries were found
#        VAR_INCLUDE_DIRS - Directory path(s) to include files
#        VAR_LIBRARIES - Full path(s) to each libraries
#
# AUTHOR:  Kevin Paul <kpaul@ucar.edu>
# DATE:    11 Feb 2014
#   
#######################################################################

function(BASIC_FIND PCKG REQ_INCS REQ_LIBS)

#If environment variable ${PCKG}_DIR is specified, 
# it has same effect as local ${PCKG}_DIR
if( (NOT ${PCKG}_DIR) AND DEFINED ENV{${PCKG}_DIR} )
  set( ${PCKG}_DIR "$ENV{${PCKG}_DIR}" )
  message(STATUS " ${PCKG}_DIR is set from environment: ${${PCKG}_DIR}")
endif()

if (NOT ${PCKG}_DIR)
  if(!${PCKG}_FIND_QUIETLY)
    message (WARNING " Option ${PCKG}_DIR not set.")
  endif ()
else (NOT ${PCKG}_DIR)
  message (STATUS " ${PCKG}_DIR set to ${${PCKG}_DIR}")
endif (NOT ${PCKG}_DIR)

message (STATUS " Searching for package ${PCKG}...")
set (${PCKG}_FOUND FALSE PARENT_SCOPE)

# Look for each required include file
foreach(INC_FILE ${REQ_INCS})
  message (STATUS " Searching for include file: ${INC_FILE}")
  set (INC_DIR ${INC_FILE}-NOTFOUND)
  find_path(INC_DIR ${INC_FILE}
    HINTS ${${PCKG}_DIR} ${${PCKG}_DIR}/include)
  if (EXISTS ${INC_DIR}/${INC_FILE})
    message (STATUS " Found include file ${INC_FILE} in ${INC_DIR} required by ${PCKG}")
    set (${PCKG}_INCLUDE_DIRS ${${PCKG}_INCLUDE_DIRS} ${INC_DIR} PARENT_SCOPE)
  elseif(!${PCKG}_FIND_QUIETLY)
    message (WARNING " Failed to find include file ${INC_FILE} required by ${PCKG}")
  endif ()
endforeach()
# Look for each required library
foreach(LIB_NAME ${REQ_LIBS})
  message (STATUS " Searching for library: ${LIB_NAME}")
  set (LIB ${LIB_NAME}-NOTFOUND)
  find_library(LIB NAMES "lib${LIB_NAME}.a" "${LIB_NAME}"
    HINTS ${${PCKG}_DIR} ${${PCKG}_DIR}/lib)
  if (EXISTS ${LIB})
    message (STATUS " Found library at ${LIB} required by ${PCKG}")
    set (${PCKG}_LIBRARIES ${${PCKG}_LIBRARIES} ${LIB} PARENT_SCOPE)
    set (${PCKG}_FOUND TRUE PARENT_SCOPE)
    set (${PCKG}_FOUND TRUE )
  else ()
    set (${PCKG}_FOUND FALSE PARENT_SCOPE)
    set (${PCKG}_FOUND FALSE )
  endif ()
endforeach()

# If we made it this far, then we call the package "FOUND"
if(${PCKG}_FOUND)
  message (STATUS "All required include files and libraries found.")
else()
  if(!${PCKG}_FIND_QUIETLY)
    message ("WARNING! ${PCKG} not found.")
  else()
    message ("${PCKG} not found (Optional, Not Required).")
  endif()
endif()

endfunction(BASIC_FIND)
include(basicFind)
BASIC_FIND (PNETCDF "pnetcdf.h" "pnetcdf")