java 本地文件搜索_如何通过CMake查找特定/本地文件

我有一个本地安装的库的问题 . 在我的项目中有xmlrpc 0.7库:

myproject/

+-- xmlrpc++0.7/

+-- src/

如果没有找到,我希望CMake使用本地xmlrpc 0.7目录进行回退 . 两个问题,第一个,find_path()或find_library()不适用于本地目录 . 我使用了一种变通方法来测试find_xxx()处理的变量是否为空 . 如果为空,我手动设置它们 . cmake现在生成Makefile而没有错误 . 但是如果我想通过make编译项目,则c编译器返回“错误:XmlRpc.h:找不到文件” . 文件XmlRpc.h位于myproject / xmlrpc 0.7 / src中,如果我手动编译它们就可以了 .

这是我的CMakeLists.txt . 如果有人能指出在上述条件下使用cmake的正确解决方案,我感到非常高兴 .

--- CMakeLists.txt ---

project(webservice_tesseract)

cmake_minimum_required(VERSION 2.6)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

# find tesseract

find_path(TESSERACT_INCLUDE_DIR tesseract/tesseractmain.h

/opt/local/include

/usr/local/include

/usr/include

)

find_library(TESSERACT_LIBRARY_DIR

NAMES tesseract_main

PATHS

/opt/local/lib/

/usr/local/lib/

/usr/lib

)

message(STATUS "looked for tesseract library.")

message(STATUS "Include file detected: [${TESSERACT_INCLUDE_DIR}].")

message(STATUS "Lib file detected: [${TESSERACT_LIBRARY_DIR}].")

add_library(tesseract STATIC IMPORTED)

set_property(TARGET tesseract PROPERTY IMPORTED_LOCATION

${TESSERACT_LIBRARY_DIR}/libtesseractmain.a

)

#find xmlrpc++

message(STATUS "cmake home dir: [${CMAKE_HOME_DIRECTORY}].")

set(LOCAL_XMLRPCPLUSPLUS ${CMAKE_HOME_DIRECTORY}/xmlrpc0.7++/)

message(STATUS "xmlrpc++ local dir: [${LOCAL_XMLRPCPLUSPLUS}].")

find_path(XMLRPCPLUSPLUS_INCLUDE_DIR XmlRpcServer.h

${LOCAL_XMLRPCPLUSPLUS}src

/opt/local/include

/usr/local/include

/usr/include

)

find_library(XMLRPCPLUSPLUS_LIBRARY_DIR

NAMES XmlRpc

PATHS

${LOCAL_XMLRPCPLUSPLUS}

/opt/local/lib/

/usr/local/lib/

/usr/lib/

)

# next lines are an ugly workaround because cmake find_xxx() does not find local stuff

if (XMLRPCPLUSPLUS_INCLUDE_DIR)

else (XMLRPCPLUSPLUS_INCLUDE_DIR)

set(XMLRPCPLUSPLUS_INCLUDE_DIR ${LOCAL_XMLRPCPLUSPLUS}src)

endif (XMLRPCPLUSPLUS_INCLUDE_DIR)

if (XMLRPCPLUSPLUS_LIBRARY_DIR)

else (XMLRPCPLUSPLUS_LIBRARY_DIR)

set(XMLRPCPLUSPLUS_LIBRARY_DIR ${LOCAL_XMLRPCPLUSPLUS})

endif (XMLRPCPLUSPLUS_LIBRARY_DIR)

message(STATUS "looked for xmlrpc++ library.")

message(STATUS "Include file detected: [${XMLRPCPLUSPLUS_INCLUDE_DIR}].")

message(STATUS "Lib file detected: [${XMLRPCPLUSPLUS_LIBRARY_DIR}].")

add_library(xmlrpc STATIC IMPORTED)

set_property(TARGET xmlrpc PROPERTY IMPORTED_LOCATION

${XMLRPCPLUSPLUS_LIBRARY_DIR}/libXmlRpc.a

)

#### link together

include_directories(${XMLRPCPLUSPLUS_INCLUDE_DIR} ${TESSERACT_INCLUDE_DIR})

link_directories(${XMLRPCPLUSPLUS_LIBRARY_DIR} ${TESSERACT_LIBRARY_DIR})

add_library(simpleocr STATIC simple_ocr.cpp)

add_executable(webservice_tesseract webservice.cpp)

target_link_libraries(webservice_tesseract xmlrpc tesseract simpleocr)

你可能感兴趣的:(java,本地文件搜索)