From d7d95e7219887100cb98821ca031b726853c712b Mon Sep 17 00:00:00 2001 From: David Stoup Date: Mon, 28 Oct 2019 14:26:55 -0400 Subject: [PATCH 1/5] Update protobuf3 and use CMake --- CMake/External_Protobuf.cmake | 90 +++++++++++++++++++++++------------ CMake/fletch-tarballs.cmake | 10 ++-- 2 files changed, 64 insertions(+), 36 deletions(-) diff --git a/CMake/External_Protobuf.cmake b/CMake/External_Protobuf.cmake index e98eff06..80e238ea 100644 --- a/CMake/External_Protobuf.cmake +++ b/CMake/External_Protobuf.cmake @@ -1,43 +1,71 @@ -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") +if (Protobuf_SELECT_VERSION STREQUAL "3.9.0") + # Check that python and protobuf versions are compatible + if(fletch_BUILD_WITH_PYTHON) + # Note the python protobuf wrapper is not installed here. + # Instead it must be installed via `pip install protobuf` + if (fletch_PYTHON_MAJOR_VERSION MATCHES "^2.*") + message(ERROR " Must use Python >= 3.x with Protobuf 3.x") + endif() endif() -endif() + ExternalProject_Add(Protobuf +# PREFIX protobuf + URL ${Protobuf_url} + URL_MD5 ${Protobuf_md5} + SOURCE_SUBDIR ./cmake + ${COMMON_EP_ARGS} + ${COMMON_CMAKE_EP_ARGS} +# UPDATE_COMMAND +# COMMAND ${CMAKE_COMMAND} -DPULSE_IL2CPP_PATCH=${PULSE_IL2CPP_PATCH} -Dprotobuf_source=${protobuf_SRC} -Dprotobuf_patch=${protobuf_Patch} -P ${protobuf_Patch}/Patch.cmake + CMAKE_ARGS + ${COMMON_CMAKE_ARGS} + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -Dprotobuf_BUILD_TESTS:BOOL=OFF + -Dprotobuf_BUILD_EXAMPLES:BOOL=OFF + -Dprotobuf_BUILD_SHARED_LIBS:BOOL=OFF + -Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=OFF#Don't change MSVC runtime settings (/MD or /MT) + -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() + # 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 " You must use Protobuf >= 3.x with Python 3.x") + 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) diff --git a/CMake/fletch-tarballs.cmake b/CMake/fletch-tarballs.cmake index 92da2bb1..6672b3a2 100644 --- a/CMake/fletch-tarballs.cmake +++ b/CMake/fletch-tarballs.cmake @@ -492,8 +492,8 @@ 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") + 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() set(Protobuf_version ${Protobuf_SELECT_VERSION}) @@ -501,9 +501,9 @@ if(NOT WIN32) 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 VERSION_EQUAL 3.9.0) + set(Protobuf_url "https://github.com/protocolbuffers/protobuf/releases/download/v${Protobuf_version}/protobuf-all-${Protobuf_version}.zip") + set(Protobuf_md5 "4f042c8b46823a69db3dcbc7381b73f4" ) elseif(Protobuf_version) message(ERROR "Protobuf Version ${Protobuf_version} Not Supported") endif() From d8801bdc2ba858a8ba7522b8f57ea75ce27dd2c7 Mon Sep 17 00:00:00 2001 From: David Stoup Date: Tue, 29 Oct 2019 15:12:39 -0400 Subject: [PATCH 2/5] Fix the build_shared flag to use protobuf custom flag --- CMake/External_Protobuf.cmake | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/CMake/External_Protobuf.cmake b/CMake/External_Protobuf.cmake index 80e238ea..7f39ed8f 100644 --- a/CMake/External_Protobuf.cmake +++ b/CMake/External_Protobuf.cmake @@ -1,15 +1,5 @@ if (Protobuf_SELECT_VERSION STREQUAL "3.9.0") - # Check that python and protobuf versions are compatible - if(fletch_BUILD_WITH_PYTHON) - # Note the python protobuf wrapper is not installed here. - # Instead it must be installed via `pip install protobuf` - if (fletch_PYTHON_MAJOR_VERSION MATCHES "^2.*") - message(ERROR " Must use Python >= 3.x with Protobuf 3.x") - endif() - endif() - - ExternalProject_Add(Protobuf # PREFIX protobuf URL ${Protobuf_url} @@ -21,24 +11,13 @@ if (Protobuf_SELECT_VERSION STREQUAL "3.9.0") # COMMAND ${CMAKE_COMMAND} -DPULSE_IL2CPP_PATCH=${PULSE_IL2CPP_PATCH} -Dprotobuf_source=${protobuf_SRC} -Dprotobuf_patch=${protobuf_Patch} -P ${protobuf_Patch}/Patch.cmake CMAKE_ARGS ${COMMON_CMAKE_ARGS} - -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} -Dprotobuf_BUILD_TESTS:BOOL=OFF -Dprotobuf_BUILD_EXAMPLES:BOOL=OFF - -Dprotobuf_BUILD_SHARED_LIBS:BOOL=OFF + -Dprotobuf_BUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} -Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=OFF#Don't change MSVC runtime settings (/MD or /MT) -Dprotobuf_WITH_ZLIB:BOOL=OFF ) elseif (NOT WIN32) - - # 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 " You must use Protobuf >= 3.x with Python 3.x") - 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} From 80fcb9e46c9783af5b64a2718cbe03fff262a944 Mon Sep 17 00:00:00 2001 From: David Stoup Date: Wed, 30 Oct 2019 09:18:04 -0400 Subject: [PATCH 3/5] Open up Protofuf 3 build for WIN32 --- CMake/fletch-tarballs.cmake | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/CMake/fletch-tarballs.cmake b/CMake/fletch-tarballs.cmake index 6672b3a2..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 "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() - - 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.9.0) - set(Protobuf_url "https://github.com/protocolbuffers/protobuf/releases/download/v${Protobuf_version}/protobuf-all-${Protobuf_version}.zip") - set(Protobuf_md5 "4f042c8b46823a69db3dcbc7381b73f4" ) - 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) From 7c0f237435b032d4f0c1aa85cd1d76c63927e769 Mon Sep 17 00:00:00 2001 From: David Stoup Date: Fri, 15 Nov 2019 09:54:01 -0500 Subject: [PATCH 4/5] Remove unnecessary patch. --- CMake/External_Protobuf.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMake/External_Protobuf.cmake b/CMake/External_Protobuf.cmake index 7f39ed8f..1264ec44 100644 --- a/CMake/External_Protobuf.cmake +++ b/CMake/External_Protobuf.cmake @@ -7,8 +7,6 @@ if (Protobuf_SELECT_VERSION STREQUAL "3.9.0") SOURCE_SUBDIR ./cmake ${COMMON_EP_ARGS} ${COMMON_CMAKE_EP_ARGS} -# UPDATE_COMMAND -# COMMAND ${CMAKE_COMMAND} -DPULSE_IL2CPP_PATCH=${PULSE_IL2CPP_PATCH} -Dprotobuf_source=${protobuf_SRC} -Dprotobuf_patch=${protobuf_Patch} -P ${protobuf_Patch}/Patch.cmake CMAKE_ARGS ${COMMON_CMAKE_ARGS} -Dprotobuf_BUILD_TESTS:BOOL=OFF From cafb37ec7e9364e0a645047d48b559cf2372fed6 Mon Sep 17 00:00:00 2001 From: David Stoup Date: Mon, 18 Nov 2019 09:27:05 -0500 Subject: [PATCH 5/5] Build protobuf statically. --- CMake/External_Caffe.cmake | 39 +++++++++++------------------ CMake/External_Caffe_Segnet.cmake | 41 +++++++++++-------------------- CMake/External_Protobuf.cmake | 31 +++++++++++++++++++++-- 3 files changed, 59 insertions(+), 52 deletions(-) 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 1264ec44..7bcc0601 100644 --- a/CMake/External_Protobuf.cmake +++ b/CMake/External_Protobuf.cmake @@ -1,4 +1,5 @@ +set(protobuf_BUILD_SHARED_LIBS "OFF") if (Protobuf_SELECT_VERSION STREQUAL "3.9.0") ExternalProject_Add(Protobuf # PREFIX protobuf @@ -10,9 +11,10 @@ if (Protobuf_SELECT_VERSION STREQUAL "3.9.0") CMAKE_ARGS ${COMMON_CMAKE_ARGS} -Dprotobuf_BUILD_TESTS:BOOL=OFF - -Dprotobuf_BUILD_EXAMPLES:BOOL=OFF - -Dprotobuf_BUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -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) @@ -48,10 +50,35 @@ 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}) ")