Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nanopb
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
le
nanopb
Commits
9c7e958a
Unverified
Commit
9c7e958a
authored
6 years ago
by
Petteri Aimonen
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #352 from mrostecki/shared
cmake: Allow to build a shared library
parents
01097873
4c709326
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CMakeLists.txt
+40
-15
40 additions, 15 deletions
CMakeLists.txt
with
40 additions
and
15 deletions
CMakeLists.txt
+
40
−
15
View file @
9c7e958a
...
...
@@ -3,9 +3,13 @@ cmake_minimum_required(VERSION 2.8.12)
project
(
nanopb C
)
set
(
nanopb_VERSION_STRING nanopb-0.4.0-dev
)
set
(
nanopb_SOVERSION 0
)
string
(
REPLACE
"nanopb-"
""
nanopb_VERSION
${
nanopb_VERSION_STRING
}
)
option
(
BUILD_SHARED_LIBS
"Build shared libraries"
OFF
)
option
(
BUILD_STATIC_LIBS
"Build static libraries"
ON
)
option
(
nanopb_BUILD_RUNTIME
"Build the headers and libraries needed at runtime"
ON
)
option
(
nanopb_BUILD_GENERATOR
"Build the protoc plugin for code generation"
ON
)
option
(
nanopb_MSVC_STATIC_RUNTIME
"Link static runtime libraries"
ON
)
...
...
@@ -62,25 +66,46 @@ if(nanopb_BUILD_GENERATOR)
endif
()
if
(
nanopb_BUILD_RUNTIME
)
add_library
(
protobuf-nanopb STATIC
pb.h
pb_common.h
pb_common.c
pb_encode.h
pb_encode.c
pb_decode.h
pb_decode.c
)
target_include_directories
(
protobuf-nanopb INTERFACE
$<INSTALL_INTERFACE:
${
CMAKE_INSTALL_INCLUDEDIR
}
>
)
if
(
BUILD_SHARED_LIBS
)
add_library
(
protobuf-nanopb SHARED
pb.h
pb_common.h
pb_common.c
pb_encode.h
pb_encode.c
pb_decode.h
pb_decode.c
)
set_target_properties
(
protobuf-nanopb PROPERTIES
SOVERSION
${
nanopb_SOVERSION
}
)
install
(
TARGETS protobuf-nanopb EXPORT nanopb-targets
ARCHIVE DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
LIBRARY DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
)
target_include_directories
(
protobuf-nanopb INTERFACE
$<INSTALL_INTERFACE:
${
CMAKE_INSTALL_INCLUDEDIR
}
>
)
endif
()
if
(
BUILD_STATIC_LIBS
)
add_library
(
protobuf-nanopb-static STATIC
pb.h
pb_common.h
pb_common.c
pb_encode.h
pb_encode.c
pb_decode.h
pb_decode.c
)
set_target_properties
(
protobuf-nanopb-static PROPERTIES
OUTPUT_NAME protobuf-nanopb
)
install
(
TARGETS protobuf-nanopb-static EXPORT nanopb-targets
ARCHIVE DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
)
target_include_directories
(
protobuf-nanopb-static INTERFACE
$<INSTALL_INTERFACE:
${
CMAKE_INSTALL_INCLUDEDIR
}
>
)
endif
()
configure_file
(
extra/nanopb-config-version.cmake.in
nanopb-config-version.cmake @ONLY
)
install
(
TARGETS protobuf-nanopb EXPORT nanopb-targets
ARCHIVE DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
)
install
(
EXPORT nanopb-targets
DESTINATION
${
CMAKE_INSTALL_CMAKEDIR
}
NAMESPACE nanopb::
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment