force cmake FIND_LIBRARY to look in custom directory

前端 未结 1 652
谎友^
谎友^ 2020-12-31 01:05

cmake version 2.8.4

I have the following apache portable runtime libraries that I have compiled myself and want my application to link against.

My project di

相关标签:
1条回答
  • 2020-12-31 01:47

    You can specify the search order using one or more of NO_DEFAULT_PATH, NO_CMAKE_ENVIRONMENT_PATH , NO_CMAKE_PATH, NO_SYSTEM_ENVIRONMENT_PATH, NO_CMAKE_SYSTEM_PATH, CMAKE_FIND_ROOT_PATH_BOTH, ONLY_CMAKE_FIND_ROOT_PATH, orNO_CMAKE_FIND_ROOT_PATH.

    From the docs for find_library:

    The default search order is designed to be most-specific to least-specific for common use cases. Projects may override the order by simply calling the command multiple times and using the NO_* options:

    find_library(<VAR> NAMES name PATHS paths... NO_DEFAULT_PATH)
    find_library(<VAR> NAMES name)
    

    Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.

    So in your case, you can do

    FIND_LIBRARY(APRUTIL NAMES "aprutil-1"
      PATHS ${PROJECT_SOURCE_DIR}/tools/apr/libs NO_DEFAULT_PATH)
    
    0 讨论(0)
提交回复
热议问题