diff --git a/CMake/External_Caffe.cmake b/CMake/External_Caffe.cmake index d74aa5a3..9488898f 100644 --- a/CMake/External_Caffe.cmake +++ b/CMake/External_Caffe.cmake @@ -75,33 +75,24 @@ endif() set( CAFFE_PROTOBUF_ARGS ) if(fletch_ENABLE_Protobuf) - get_system_library_name( protobuf protobuf_libname ) - get_system_library_name( protobuf-lite protobuf-lite_libname ) - get_system_library_name( protoc protoc_libname ) - - set( CAFFE_PROTOBUF_ARGS - -DPROTOBUF_INCLUDE_DIR:PATH=${fletch_BUILD_INSTALL_PREFIX}/include - -DPROTOBUF_LIBRARY:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protobuf_libname} - -DPROTOBUF_LIBRARY_DEBUG:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protobuf_libname} - -DPROTOBUF_LITE_LIBRARY:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protobuf-lite_libname} - -DPROTOBUF_LITE_LIBRARY_DEBUG:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protobuf-lite_libname} - -DPROTOBUF_PROTOC_EXECUTABLE:PATH=${fletch_BUILD_INSTALL_PREFIX}/bin/protoc - -DPROTOBUF_PROTOC_LIBRARY:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protoc_libname} - -DPROTOBUF_PROTOC_LIBRARY_DEBUG:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protoc_libname} - ) + set(protobuf_include ${fletch_BUILD_INSTALL_PREFIX}/include) + set(protobuf_exe ${fletch_BUILD_INSTALL_PREFIX}/bin/protoc) else() - set( CAFFE_PROTOBUF_ARGS - -DPROTOBUF_INCLUDE_DIR:PATH=${PROTOBUF_INCLUDE_DIR} - -DPROTOBUF_LIBRARY:PATH=${PROTOBUF_LIBRARY} - -DPROTOBUF_LIBRARY_DEBUG:PATH=${PROTOBUF_LIBRARY_DEBUG} - -DPROTOBUF_LITE_LIBRARY:PATH=${PROTOBUF_LITE_LIBRARY} - -DPROTOBUF_LITE_LIBRARY_DEBUG:PATH=${PROTOBUF_LITE_LIBRARY_DEBUG} - -DPROTOBUF_PROTOC_EXECUTABLE:PATH=${PROTOBUF_PROTOC_EXECUTABLE} - -DPROTOBUF_PROTOC_LIBRARY:PATH=${PROTOBUF_PROTOC_LIBRARY} - -DPROTOBUF_PROTOC_LIBRARY_DEBUG:PATH=${PROTOBUF_PROTOC_LIBRARY_DEBUG} - ) + set(protobuf_include ${PROTOBUF_INCLUDE_DIR}) + set(protobuf_exe ${PROTOBUF_PROTOC_EXECUTABLE}) endif() +set( CAFFE_PROTOBUF_ARGS + -DPROTOBUF_INCLUDE_DIR:PATH=${protobuf_include} + -DPROTOBUF_LIBRARY:PATH=${PROTOBUF_LIBRARY} + -DPROTOBUF_LIBRARY_DEBUG:PATH=${PROTOBUF_LIBRARY} + -DPROTOBUF_LITE_LIBRARY:PATH=${PROTOBUF_LITE_LIBRARY} + -DPROTOBUF_LITE_LIBRARY_DEBUG:PATH=${PROTOBUF_LITE_LIBRARY} + -DPROTOBUF_PROTOC_EXECUTABLE:PATH=${protobuf_exe} + -DPROTOBUF_PROTOC_LIBRARY:PATH=${PROTOBUF_PROTOC_LIBRARY}/ + -DPROTOBUF_PROTOC_LIBRARY_DEBUG:PATH=${PROTOBUF_PROTOC_LIBRARY} + ) + if(fletch_ENABLE_OpenCV) set( CAFFE_OPENCV_ARGS -DOpenCV_DIR:PATH=${fletch_BUILD_PREFIX}/src/OpenCV-build diff --git a/CMake/External_Caffe_Segnet.cmake b/CMake/External_Caffe_Segnet.cmake index 1437a6cf..c8bc7640 100644 --- a/CMake/External_Caffe_Segnet.cmake +++ b/CMake/External_Caffe_Segnet.cmake @@ -76,33 +76,24 @@ endif() set( CAFFE_SEGNET_PROTOBUF_ARGS ) if(fletch_ENABLE_Protobuf) - get_system_library_name( protobuf protobuf_libname ) - get_system_library_name( protobuf-lite protobuf-lite_libname ) - get_system_library_name( protoc protoc_libname ) - - set( CAFFE_SEGNET_PROTOBUF_ARGS - -DPROTOBUF_INCLUDE_DIR:PATH=${fletch_BUILD_INSTALL_PREFIX}/include - -DPROTOBUF_LIBRARY:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protobuf_libname} - -DPROTOBUF_LIBRARY_DEBUG:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protobuf_libname} - -DPROTOBUF_LITE_LIBRARY:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protobuf-lite_libname} - -DPROTOBUF_LITE_LIBRARY_DEBUG:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protobuf-lite_libname} - -DPROTOBUF_PROTOC_EXECUTABLE:PATH=${fletch_BUILD_INSTALL_PREFIX}/bin/protoc - -DPROTOBUF_PROTOC_LIBRARY:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protoc_libname} - -DPROTOBUF_PROTOC_LIBRARY_DEBUG:PATH=${fletch_BUILD_INSTALL_PREFIX}/lib/${protoc_libname} - ) + set(protobuf_include ${fletch_BUILD_INSTALL_PREFIX}/include) + set(protobuf_exe ${fletch_BUILD_INSTALL_PREFIX}/bin/protoc) else() - set( CAFFE_SEGNET_PROTOBUF_ARGS - -DPROTOBUF_INCLUDE_DIR:PATH=${PROTOBUF_INCLUDE_DIR} - -DPROTOBUF_LIBRARY:PATH=${PROTOBUF_LIBRARY} - -DPROTOBUF_LIBRARY_DEBUG:PATH=${PROTOBUF_LIBRARY_DEBUG} - -DPROTOBUF_LITE_LIBRARY:PATH=${PROTOBUF_LITE_LIBRARY} - -DPROTOBUF_LITE_LIBRARY_DEBUG:PATH=${PROTOBUF_LITE_LIBRARY_DEBUG} - -DPROTOBUF_PROTOC_EXECUTABLE:PATH=${PROTOBUF_PROTOC_EXECUTABLE} - -DPROTOBUF_PROTOC_LIBRARY:PATH=${PROTOBUF_PROTOC_LIBRARY} - -DPROTOBUF_PROTOC_LIBRARY_DEBUG:PATH=${PROTOBUF_PROTOC_LIBRARY_DEBUG} - ) + set(protobuf_include ${PROTOBUF_INCLUDE_DIR}) + set(protobuf_exe ${PROTOBUF_PROTOC_EXECUTABLE}) endif() +set( CAFFE_SEGNET_PROTOBUF_ARGS + -DPROTOBUF_INCLUDE_DIR:PATH=${protobuf_include} + -DPROTOBUF_LIBRARY:PATH=${PROTOBUF_LIBRARY} + -DPROTOBUF_LIBRARY_DEBUG:PATH=${PROTOBUF_LIBRARY} + -DPROTOBUF_LITE_LIBRARY:PATH=${PROTOBUF_LITE_LIBRARY} + -DPROTOBUF_LITE_LIBRARY_DEBUG:PATH=${PROTOBUF_LITE_LIBRARY} + -DPROTOBUF_PROTOC_EXECUTABLE:PATH=${protobuf_exe} + -DPROTOBUF_PROTOC_LIBRARY:PATH=${PROTOBUF_PROTOC_LIBRARY}/ + -DPROTOBUF_PROTOC_LIBRARY_DEBUG:PATH=${PROTOBUF_PROTOC_LIBRARY} + ) + if(fletch_ENABLE_OpenCV) set( CAFFE_SEGNET_OPENCV_ARGS -DOpenCV_DIR:PATH=${fletch_BUILD_PREFIX}/src/OpenCV-build @@ -176,7 +167,6 @@ if(fletch_ENABLE_HDF5) get_system_library_name( hdf5_cpp_debug hdf5_cpp_libname ) get_system_library_name( hdf5_hl_cpp_debug hdf5_hl_cpp_libname ) - else() get_system_library_name( hdf5 hdf5_libname ) @@ -270,7 +260,6 @@ else() ) endif() - set (Caffe_Segnet_PATCH_DIR "${fletch_SOURCE_DIR}/Patches/Caffe_Segnet/${Caffe_Segnet_version}") if (EXISTS ${Caffe_Segnet_PATCH_DIR}) set( diff --git a/CMake/External_Protobuf.cmake b/CMake/External_Protobuf.cmake index e98eff06..7bcc0601 100644 --- a/CMake/External_Protobuf.cmake +++ b/CMake/External_Protobuf.cmake @@ -1,52 +1,84 @@ -if (WIN32) - # Build option for windows not yet generated - message( FATAL_ERROR "Protobuf on windows not yet supported" ) -endif() -# Check that python and protobuf versions are compatible -if(fletch_BUILD_WITH_PYTHON AND fletch_ENABLE_Protobuf) - # Note the python protobuf wrapper is not installed here. - # Instead it must be installed via `pip install protobuf` - if (${Protobuf_version} LESS 3.0 AND fletch_PYTHON_MAJOR_VERSION MATCHES "^3.*") - message(ERROR " Must use Protobuf >= 3.x with Python 3.x") +set(protobuf_BUILD_SHARED_LIBS "OFF") +if (Protobuf_SELECT_VERSION STREQUAL "3.9.0") + ExternalProject_Add(Protobuf +# PREFIX protobuf + URL ${Protobuf_url} + URL_MD5 ${Protobuf_md5} + SOURCE_SUBDIR ./cmake + ${COMMON_EP_ARGS} + ${COMMON_CMAKE_EP_ARGS} + CMAKE_ARGS + ${COMMON_CMAKE_ARGS} + -Dprotobuf_BUILD_TESTS:BOOL=OFF + -Dprotobuf_BUILD_EXAMPLES:BOOL=${protobuf_BUILD_SHARED_LIBS} + -Dprotobuf_BUILD_SHARED_LIBS:BOOL=OFF + -Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=OFF#Don't change MSVC runtime settings (/MD or /MT) + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=TRUE + -Dprotobuf_WITH_ZLIB:BOOL=OFF + ) +elseif (NOT WIN32) + set (Protobuf_PATCH_DIR ${fletch_SOURCE_DIR}/Patches/Protobuf/${Protobuf_SELECT_VERSION}) + if (EXISTS ${Protobuf_PATCH_DIR}) + set(Protobuf_PATCH_COMMAND ${CMAKE_COMMAND} + -DProtobuf_PATCH_DIR=${Protobuf_PATCH_DIR} + -DProtobuf_SOURCE_DIR=${fletch_BUILD_PREFIX}/src/Protobuf + -P ${Protobuf_PATCH_DIR}/Patch.cmake) + else() + set(Protobuf_PATCH_COMMAND "") endif() -endif() - - - -set (Protobuf_PATCH_DIR ${fletch_SOURCE_DIR}/Patches/Protobuf/${Protobuf_SELECT_VERSION}) -if (EXISTS ${Protobuf_PATCH_DIR}) - set(Protobuf_PATCH_COMMAND ${CMAKE_COMMAND} - -DProtobuf_PATCH_DIR=${Protobuf_PATCH_DIR} - -DProtobuf_SOURCE_DIR=${fletch_BUILD_PREFIX}/src/Protobuf - -P ${Protobuf_PATCH_DIR}/Patch.cmake) -else() - set(Protobuf_PATCH_COMMAND "") -endif() - -Fletch_Require_Make() -ExternalProject_Add(Protobuf - URL ${Protobuf_url} - URL_MD5 ${Protobuf_md5} - ${COMMON_EP_ARGS} - PATCH_COMMAND ${CMAKE_COMMAND} + Fletch_Require_Make() + ExternalProject_Add(Protobuf + URL ${Protobuf_url} + URL_MD5 ${Protobuf_md5} + ${COMMON_EP_ARGS} + PATCH_COMMAND ${CMAKE_COMMAND} ${Protobuf_PATCH_COMMAND} - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND ./configure + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./configure --prefix=${fletch_BUILD_INSTALL_PREFIX} - BUILD_COMMAND ${MAKE_EXECUTABLE} - INSTALL_COMMAND ${MAKE_EXECUTABLE} install -) + BUILD_COMMAND ${MAKE_EXECUTABLE} + INSTALL_COMMAND ${MAKE_EXECUTABLE} install + ) +else() + # Build option for windows not yet generated + message( FATAL_ERROR "Protobuf 2 not yet supported on windows" ) +endif() fletch_external_project_force_install(PACKAGE Protobuf) set(Protobuf_ROOT ${fletch_BUILD_INSTALL_PREFIX} CACHE PATH "") +if(NOT protobuf_BUILD_SHARED_LIBS) + if(WIN32) + set(PROTOBUF_LIBRARY "${Protobuf_ROOT}/lib/libprotobuf.lib") + set(PROTOBUF_LITE_LIBRARY "${Protobuf_ROOT}/lib/libprotobuf-lite.lib") + set(PROTOBUF_PROTOC_LIBRARY "${Protobuf_ROOT}/lib/libprotc.lib") + else() + set(PROTOBUF_LIBRARY "${Protobuf_ROOT}/lib/libprotobuf.a") + set(PROTOBUF_LITE_LIBRARY "${Protobuf_ROOT}/lib/libprotobuf-lite.a") + set(PROTOBUF_PROTOC_LIBRARY "${Protobuf_ROOT}/lib/libprotc.a") + endif() +else() + if(WIN32) + set(PROTOBUF_LIBRARY "${Protobuf_ROOT}/lib/libprotobuf.lib") + set(PROTOBUF_LITE_LIBRARY "${Protobuf_ROOT}/lib/libprotobuf-lite.lib") + set(PROTOBUF_PROTOC_LIBRARY "${Protobuf_ROOT}/lib/libprotc.lib") + else() + set(PROTOBUF_LIBRARY "${Protobuf_ROOT}/lib/libprotobuf.so") + set(PROTOBUF_LITE_LIBRARY "${Protobuf_ROOT}/lib/libprotobuf-lite.so") + set(PROTOBUF_PROTOC_LIBRARY "${Protobuf_ROOT}/lib/libprotc.so") + endif() +endif() + file(APPEND ${fletch_CONFIG_INPUT} " ####################################### # Google Protobuf ####################################### set(Protobuf_ROOT \${fletch_ROOT}) +set(PROTOBUF_LIBRARY \${PROTOBUF_LIBRARY}) +set(PROTOBUF_LITE_LIBRARY \${PROTOBUF_LITE_LIBRARY}) +set(PROTOBUF_PROTOC_LIBRARY \${PROTOBUF_PROTOC_LIBRARY}) ") diff --git a/CMake/fletch-tarballs.cmake b/CMake/fletch-tarballs.cmake index 92da2bb1..8dd34b13 100644 --- a/CMake/fletch-tarballs.cmake +++ b/CMake/fletch-tarballs.cmake @@ -490,25 +490,22 @@ if(NOT WIN32) endif() # Protobuf -if(NOT WIN32) - if (fletch_ENABLE_Protobuf OR fletch_ENABLE_ALL_PACKAGES OR AUTO_ENABLE_CAFFE_DEPENDENCY) - set(Protobuf_SELECT_VERSION "2.5.0" CACHE STRING "Select the version of ProtoBuf to build.") - set_property(CACHE Protobuf_SELECT_VERSION PROPERTY STRINGS "2.5.0" "3.4.1") - endif() - - set(Protobuf_version ${Protobuf_SELECT_VERSION}) +# WIN32 only supports the CMake version, 3.9.0 +if (WIN32) + set(Protobuf_SELECT_VERSION "3.9.0" CACHE STRING "Select the version of ProtoBuf to build.") +else() + set(Protobuf_SELECT_VERSION "3.9.0" CACHE STRING "Select the version of ProtoBuf to build.") + set_property(CACHE Protobuf_SELECT_VERSION PROPERTY STRINGS "2.5.0" "3.9.0") +endif() - if (Protobuf_version VERSION_EQUAL 2.5.0) - set(Protobuf_url "https://github.com/google/protobuf/releases/download/v${Protobuf_version}/protobuf-${Protobuf_version}.tar.bz2" ) - set(Protobuf_md5 "a72001a9067a4c2c4e0e836d0f92ece4" ) - elseif (Protobuf_version VERSION_EQUAL 3.4.1) - set(Protobuf_url "https://github.com/google/protobuf/releases/download/v${Protobuf_version}/protobuf-cpp-${Protobuf_version}.tar.gz" ) - set(Protobuf_md5 "74446d310ce79cf20bab3ffd0e8f8f8f" ) - elseif(Protobuf_version) - message(ERROR "Protobuf Version ${Protobuf_version} Not Supported") - endif() - list(APPEND fletch_external_sources Protobuf ) +if (Protobuf_SELECT_VERSION VERSION_EQUAL 2.5.0) + set(Protobuf_url "https://github.com/google/protobuf/releases/download/v${Protobuf_SELECT_VERSION}/protobuf-${Protobuf_SELECT_VERSION}.tar.bz2" ) + set(Protobuf_md5 "a72001a9067a4c2c4e0e836d0f92ece4" ) +elseif (Protobuf_SELECT_VERSION VERSION_EQUAL 3.9.0) + set(Protobuf_url "https://github.com/protocolbuffers/protobuf/releases/download/v${Protobuf_SELECT_VERSION}/protobuf-all-${Protobuf_SELECT_VERSION}.zip") + set(Protobuf_md5 "4f042c8b46823a69db3dcbc7381b73f4" ) endif() +list(APPEND fletch_external_sources Protobuf ) # Caffe set(InternalCaffe True)