2012-03-15 5 views
2

FindBoost와 관련하여 질문이 있습니다. HPC (redhat)의 1.49 배포본에서 부스트 구성 요소를 선택하려고합니다. HPC (redhat)에는 이미 기본 부스트 1.47이 사전 설치되어 있습니다. 광산을 독점적으로 사용하고 싶습니다. 그리고 BOOST_ROOT를 캐시 변수, 내부 캐시 변수 및 환경 변수 (ENV {BOOST_ROOT})를 사용하여 사용하려고 시도했지만 아무 것도 작동하지 않습니다. BOOST_ROOT가 올바로 설정되어 (1.49.0 버전을 가리킴), FindBoost에 의해 생성 된 라이브러리 경로에는 아무런 영향을 미치지 않습니다. 라이브러리는 모두 1.47.0 버전의 라이브러리를 가리 킵니다. 나는이 시도하고있다 : 당신이 나를 도울 수 있다면BOOST_ROOT를 사용하더라도 설치된 로컬 부스트 배포본을 찾을 수 없습니다.

# I give a chance to the user to set BOOST_PATH to the local boost distribution before calling FindBoost 
if(NOT DEFINED BOOST_PATH) 
    message(STATUS " Set BOOST_PATH to a specific Boost distribution if needed.") 
    set(BOOST_PATH "Default" CACHE PATH "Set the path to a specific Boost distribution if not default.") 

# On the second pass, I use BOOST_PATH to initialize BOOST_ROOT, hoping that FindBoost will use it to find my local version. 
else( NOT DEFINED BOOST_PATH) 
    if(NOT (BOOST_PATH MATCHES "Default")) 
     set(BOOST_ROOT ${BOOST_PATH} CACHE PATH "path to the preferred boost distribution.") 
    endif(NOT (BOOST_PATH MATCHES "Default")) 

    # I test to make sure the path in BOOST_ROOT is what I expect: it is on the console, as well as in the cache 
    message("BOOST_ROOT = ${BOOST_ROOT}") 

    set(Boost_USE_MULTITHREADED  ON) 
    set(Boost_USE_STATIC_LIBS  ON) 
    set(Boost_ADDITIONAL_VERSIONS "1.42" "1.42.0" 
          "1.43" "1.43.0" 
          "1.44" "1.44.0" 
          "1.45" "1.45.0" 
          "1.46" "1.46.0" "1.46.1" 
          "1.47" "1.47.0" 
          "1.48" "1.48.0" 
          "1.49" "1.49.0" 
          ${BOOST_ADDITIONAL_VERSION} 
    ) 
    set(Boost_DEBUG     TRUE) # Debugging info output for FindBoost 
    set(Boost_DETAILED_FAILURE_MSG TRUE) # Set to FALSE by default 


    # I invoke FindBoost here, but although BOOST_ROOT points to my local boost, all the paths of the 3 components points to the installed debug/release variants, not to my local distribution. 
    find_package(Boost COMPONENTS date_time filesystem system program_options) 

# unimportant code 
[...] 

endif( NOT DEFINED BOOST_PATH) 

내가 크게 감사하겠습니다. 대단히 감사드립니다.

니콜라스 FindBoost.cmake (CMake의 2.8.x)의 최신 버전에서

+0

아마도 BOOST_ADDITIONAL_VERSIONS 순서가 변경되어 1.49가 우선됩니까? –

+0

그리고 Boost_ADDITIONAL_VERSIONS를 BOOST_ADDITIONAL_VERSION 값으로 설정합니다 (참고 : 's'제외). –

+0

@Andre : 제안한대로 1.49.0이 가장 먼저 나올 정도로 버전을 재정렬하고 ... 작동했습니다! 하지만 걱정할 필요가 있습니다. Boost의 최신 버전 만 사용됩니다. 누군가 이전 버전을 사용해야하는 충분한 이유가 있다면 어떻게해야합니까? 어쨌든, 이제 작동합니다. 의견을 보내 주셔서 감사합니다. – nchaumont

답변

4

스크립트가 부스트를 찾고 검색 경로에 영향을 설정할 수있는 변수가있다.

으로 설정하면 시스템 위치에 설치된 라이브러리는 보지 않습니다.

두 개의 Boost 설치 라이브러리가 find_package() 스크립트에 의해 뒤섞어 져 있기 때문에 필자는 몇몇 프로젝트에서이 작업을 수행해야했습니다.

+0

팁 주셔서 감사! – nchaumont

관련 문제