1*4882a593SmuzhiyunFrom 5448ca9d92f7fa197060323a82a5f060ce7c31e7 Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Pierre-Jean Texier <pjtexier@koncepto.io>
3*4882a593SmuzhiyunDate: Wed, 22 May 2019 10:26:27 +0200
4*4882a593SmuzhiyunSubject: [PATCH] src/CMakeLists.txt: do not force the build of a shared
5*4882a593Smuzhiyun library
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunBy definition, projects using CMake which can build either static or shared
8*4882a593Smuzhiyunlibraries use a BUILD_SHARED_LIBS flag to allow selecting between both.
9*4882a593SmuzhiyunSo, let CMake rely on the standard BUILD_SHARED_LIBS variable to decide
10*4882a593Smuzhiyunwhether a static or shared library should be built.
11*4882a593Smuzhiyun
12*4882a593Smuzhiyunhowever, we can control the behaviour as follows:
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun   $. cmake -DBUILD_SHARED_LIBS=OFF ...
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun   $. cmake -DBUILS_SHARED_LIBS=ON ...
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunWith Yocto/OE, just add the following option into the libubootenv recipe :
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunEXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON"
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunSigned-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
23*4882a593Smuzhiyun[Upstream status: http://patchwork.ozlabs.org/patch/1103437/]
24*4882a593Smuzhiyun---
25*4882a593Smuzhiyun src/CMakeLists.txt | 6 ++----
26*4882a593Smuzhiyun 1 file changed, 2 insertions(+), 4 deletions(-)
27*4882a593Smuzhiyun
28*4882a593Smuzhiyundiff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
29*4882a593Smuzhiyunindex 4b71bc5..0b515f4 100644
30*4882a593Smuzhiyun--- a/src/CMakeLists.txt
31*4882a593Smuzhiyun+++ b/src/CMakeLists.txt
32*4882a593Smuzhiyun@@ -12,18 +12,16 @@ SET(include_HEADERS
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun include(GNUInstallDirs) # for the CMAKE_INSTALL_LIBDIR variable
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun-add_library(ubootenv SHARED ${libubootenv_SOURCES} ${include_HEADERS})
37*4882a593Smuzhiyun+add_library(ubootenv ${libubootenv_SOURCES} ${include_HEADERS})
38*4882a593Smuzhiyun SET_TARGET_PROPERTIES(ubootenv PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION})
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun-ADD_LIBRARY(ubootenv_static STATIC ${libubootenv_SOURCES} ${include_HEADERS})
41*4882a593Smuzhiyun-SET_TARGET_PROPERTIES(ubootenv_static PROPERTIES OUTPUT_NAME ubootenv)
42*4882a593Smuzhiyun add_executable(fw_printenv fw_printenv.c)
43*4882a593Smuzhiyun add_executable(fw_setenv fw_setenv.c)
44*4882a593Smuzhiyun target_link_libraries(ubootenv z)
45*4882a593Smuzhiyun target_link_libraries(fw_printenv ubootenv)
46*4882a593Smuzhiyun target_link_libraries(fw_setenv ubootenv)
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun-install (TARGETS ubootenv ubootenv_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
49*4882a593Smuzhiyun+install (TARGETS ubootenv DESTINATION ${CMAKE_INSTALL_LIBDIR})
50*4882a593Smuzhiyun install (FILES libuboot.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
51*4882a593Smuzhiyun install (TARGETS fw_printenv DESTINATION ${CMAKE_INSTALL_BINDIR})
52*4882a593Smuzhiyun install (TARGETS fw_setenv DESTINATION ${CMAKE_INSTALL_BINDIR})
53*4882a593Smuzhiyun--
54*4882a593Smuzhiyun2.30.2
55*4882a593Smuzhiyun
56