This repository was archived by the owner on Mar 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprotobuf-config.cmake
More file actions
103 lines (83 loc) · 3.45 KB
/
protobuf-config.cmake
File metadata and controls
103 lines (83 loc) · 3.45 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
##
## @code
## ___ _____ _ ___ _ _____ ___ ___ ___ ___
## / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
## \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
## |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
## embedded.connectivity.solutions.==============
## @endcode
##
## @file
## @copyright STACKFORCE GmbH, Heitersheim, Germany, http://www.stackforce.de
## @author STACKFORCE
## @brief STACKFORCE CMake Module for googeltest
##
## This file is part of the STACKFORCE CMake modules collection
## (below "sf cmake modules collection").
##
## sf cmake modules collection is free software: you can redistribute it
## and/or modify it under the terms of the GNU Affero General Public License
## as published by the Free Software Foundation, either version 3 of the
## License, or (at your option) any later version.
##
## sf cmake modules collection is distributed in the hope that it will be
## useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Affero General Public License for more details.
##
## You should have received a copy of the GNU Affero General Public License
## along with sf cmake modules collection.
## If not, see <http://www.gnu.org/licenses/>.
##
cmake_minimum_required (VERSION 2.8)
if(protobuf_FOUND)
MESSAGE(STATUS "protobuf found!")
else()
MESSAGE(STATUS "Make protobuf!")
# Enable ExternalProject CMake module
include(ExternalProject)
set(PROTOBUF_GIT_REPOSITORY https://github.com/google/protobuf)
set(PROTOBUF_GIT_TAG master)
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS "3.2")
message(STATUS "CMake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}")
message(STATUS "Retarded CMake distributor detected. Are you using ubuntu?")
ExternalProject_Add(protobuf # Name for custom target
GIT_REPOSITORY ${PROTOBUF_GIT_REPOSITORY}
GIT_TAG ${PROTOBUF_GIT_TAG}
CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=<INSTALL_DIR>
#--Build step-----------------
BUILD_COMMAND make && make check
BUILD_IN_SOURCE 1
BUILD_ALWAYS 0
PATCH_COMMAND ""
#--Install step-----------------
INSTALL_COMMAND make install
)
else()
message(STATUS "CMake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}")
ExternalProject_Add(protobuf # Name for custom target
GIT_REPOSITORY ${PROTOBUF_GIT_REPOSITORY}
GIT_TAG ${PROTOBUF_GIT_TAG}
CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=<INSTALL_DIR>
#--Build step-----------------
BUILD_COMMAND make && make check
BUILD_IN_SOURCE 1
BUILD_ALWAYS 0
# Never update automatically from the remote repository
UPDATE_DISCONNECTED 1
PATCH_COMMAND ""
#--Install step-----------------
INSTALL_COMMAND make install
)
endif()
add_library(libprotobuf IMPORTED STATIC GLOBAL)
add_dependencies(libprotobuf protobuf)
# Set gmock properties
ExternalProject_Get_Property(protobuf source_dir binary_dir install_dir )
set_target_properties(libprotobuf PROPERTIES
"IMPORTED_LOCATION" "${install_dir}/lib/libprotobuf.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
# "INTERFACE_INCLUDE_DIRECTORIES" "${source_dir}/include"
)
include_directories("${install_dir}/include")
endif()