-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathExternal_Protobuf.cmake
More file actions
84 lines (77 loc) · 2.89 KB
/
External_Protobuf.cmake
File metadata and controls
84 lines (77 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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()
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
--prefix=${fletch_BUILD_INSTALL_PREFIX}
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})
")