Skip to content

Commit 370639a

Browse files
Alexis Lopez ZubietaTheAssassin
authored andcommitted
Offer proper static and shared libraries
Both are built with -fPIC to allow for any linking scenarios.
1 parent 70371c4 commit 370639a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
cmake_minimum_required(VERSION 3.0)
22

3+
# required to be able to link libraries into shared libraries or PIEs
4+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
5+
36
file(GLOB HEADERS ${PROJECT_SOURCE_DIR}/include/linuxdeploy/desktopfile/*.h)
47

5-
add_library(linuxdeploy_desktopfile STATIC
8+
add_library(_linuxdeploy_desktopfile_objs OBJECT
69
desktopfile.cpp
710
desktopfileentry.cpp
811
desktopfilereader.cpp
@@ -13,4 +16,11 @@ add_library(linuxdeploy_desktopfile STATIC
1316
${HEADERS}
1417
)
1518

16-
target_include_directories(linuxdeploy_desktopfile PUBLIC ${PROJECT_SOURCE_DIR}/include)
19+
add_library(linuxdeploy_desktopfile SHARED $<TARGET_OBJECTS:_linuxdeploy_desktopfile_objs>)
20+
21+
add_library(linuxdeploy_desktopfile_static STATIC $<TARGET_OBJECTS:_linuxdeploy_desktopfile_objs>)
22+
23+
# needs to be included in all three targets
24+
foreach(target linuxdeploy_desktopfile linuxdeploy_desktopfile_static _linuxdeploy_desktopfile_objs)
25+
target_include_directories(${target} PUBLIC ${PROJECT_SOURCE_DIR}/include)
26+
endforeach()

0 commit comments

Comments
 (0)