Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
protobuf-c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
protobuf-c
Commits
0656a9ac
Commit
0656a9ac
authored
Nov 27, 2016
by
AlexMilich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Static build for Windows MSVC
parent
9c4c8f63
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
build-cmake/CMakeLists.txt
build-cmake/CMakeLists.txt
+17
-0
No files found.
build-cmake/CMakeLists.txt
View file @
0656a9ac
...
...
@@ -7,6 +7,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT
(
protobuf-c
)
#options
option
(
MSVC_STATIC_BUILD
"MSVC_STATIC_BUILD"
OFF
)
INCLUDE
(
TestBigEndian
)
TEST_BIG_ENDIAN
(
WORDS_BIGENDIAN
)
...
...
@@ -39,6 +42,20 @@ INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) # for generated files
FIND_PACKAGE
(
Protobuf REQUIRED
)
INCLUDE_DIRECTORIES
(
${
PROTOBUF_INCLUDE_DIR
}
)
if
(
MSVC AND MSVC_STATIC_BUILD
)
# In case we are building static libraries, link also the runtime library statically
# so that MSVCR*.DLL is not required at runtime.
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
# This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd
# http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
foreach
(
flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
if
(
${
flag_var
}
MATCHES
"/MD"
)
string
(
REGEX REPLACE
"/MD"
"/MT"
${
flag_var
}
"
${${
flag_var
}}
"
)
endif
(
${
flag_var
}
MATCHES
"/MD"
)
endforeach
(
flag_var
)
endif
(
MSVC AND MSVC_STATIC_BUILD
)
FILE
(
GLOB PROTOC_GEN_C_SRC
${
MAIN_DIR
}
/protoc-c/*.h
${
MAIN_DIR
}
/protoc-c/*.cc
)
ADD_EXECUTABLE
(
protoc-gen-c
${
PROTOC_GEN_C_SRC
}
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment