Windows에서 cmake와 함께 protobuf v2를 사용하고 프로젝트 설정으로 빌드하는 방법을 찾았습니다. 해당 작업을 수행하는 cmake-external-packages project 및 protobuf-v2 CMakeLists을 찾으십시오. 사실, ExternalProject_Add
이 잘못 되었기 때문에 작성했습니다. 왜냐하면 생성 단계 대신 빌드 단계에 물건이 있기 때문입니다.
이 CMakeLists.txt는 protobuf's github releases에서 protobuf를 다운로드하고, 추출하고, target_link_libraries
으로 참조를 추가해야하는 cmake 대상을 내 보냅니다.
git-subtree, git-submodule을 사용하거나이 저장소 내용을 저장소 하위 폴더로 복사하십시오.
그런 다음 add_subdiretory
과 함께 사용할 패키지를 추가하십시오. protobuf를 들어, 사용
add_subdirectory(path/to/cmake-external-packages/protobuf-v2)
Protobuf의는 path/to/cmake-external-packages/include
폴더로 복사됩니다 포함되어 있습니다. 당신은 당신의 최상위 CMakeLists에서 자신의 위치를 사용자 정의 할 수 있습니다
set (EXTERNAL_PACKAGES_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/third-party/include
CACHE STRING "Directory for third-party include files, where include folders will be copied")
include_directories(${EXTERNAL_PACKAGES_INCLUDE_DIR})
은 그냥 실행을위한 protobuf 참조 :이 도움이
add_executable(your_exe ${your_exe_sources})
target_link_libraries(your_exe libprotobuf libprotobuf-lite libprotoc)
희망을.
출처
2016-06-06 20:28:12
hal
감사합니다. find_library도 CMAKE_INCLUDE_PATH, CMAKE_INCLUDE_PATH 및 CMAKE_LIBRARY_PATH를 검색한다는 사실을 발견했습니다. –