nixpkgs/pkgs/development/libraries/yajl/cmake-shared-static-fix.patch
Kiskae e8d14083e2 yajl: fix static compilation
Cherry-pick PR that separates compilation of shared and static libraries.
2023-10-02 10:59:49 +00:00

89 lines
3.2 KiB
Diff

From 768be8b9f98e30a8bd2d51576be9dfcf2cb838ea Mon Sep 17 00:00:00 2001
From: Kiskae <Kiskae@users.noreply.github.com>
Date: Tue, 26 Sep 2023 20:53:00 +0200
Subject: [PATCH] simplify compilation of static/shared with cmake
Signed-off-by: Kiskae <Kiskae@users.noreply.github.com>
---
CMakeLists.txt | 2 ++
example/CMakeLists.txt | 2 +-
perf/CMakeLists.txt | 2 +-
src/CMakeLists.txt | 7 ++-----
test/parsing/CMakeLists.txt | 2 +-
5 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 471eee13..9af25203 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,6 +16,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(YetAnotherJSONParser C)
+option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
+
SET (YAJL_MAJOR 2)
SET (YAJL_MINOR 1)
SET (YAJL_MICRO 1)
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index 0a7f6220..62ddf14c 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -20,4 +20,4 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
ADD_EXECUTABLE(parse_config ${SRCS})
-TARGET_LINK_LIBRARIES(parse_config yajl_s)
+TARGET_LINK_LIBRARIES(parse_config yajl)
diff --git a/perf/CMakeLists.txt b/perf/CMakeLists.txt
index b438d7a1..924a2681 100644
--- a/perf/CMakeLists.txt
+++ b/perf/CMakeLists.txt
@@ -20,4 +20,4 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
ADD_EXECUTABLE(perftest ${SRCS})
-TARGET_LINK_LIBRARIES(perftest yajl_s)
+TARGET_LINK_LIBRARIES(perftest yajl)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 789ddf99..78875032 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -35,9 +35,7 @@ SET (pkgconfigDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib/pkgconfig
# set the output path for libraries
SET(LIBRARY_OUTPUT_PATH ${libDir})
-ADD_LIBRARY(yajl_s STATIC ${SRCS} ${HDRS} ${PUB_HDRS})
-
-ADD_LIBRARY(yajl SHARED ${SRCS} ${HDRS} ${PUB_HDRS})
+ADD_LIBRARY(yajl ${SRCS} ${HDRS} ${PUB_HDRS})
#### setup shared library version number
SET_TARGET_PROPERTIES(yajl PROPERTIES
@@ -69,7 +67,7 @@ FOREACH (header ${PUB_HDRS})
EXEC_PROGRAM(${CMAKE_COMMAND} ARGS -E copy_if_different ${header} ${incDir})
- ADD_CUSTOM_COMMAND(TARGET yajl_s POST_BUILD
+ ADD_CUSTOM_COMMAND(TARGET yajl POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${header} ${incDir})
ENDFOREACH (header ${PUB_HDRS})
@@ -81,7 +79,6 @@ INSTALL(TARGETS yajl
RUNTIME DESTINATION lib${LIB_SUFFIX}
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX})
-INSTALL(TARGETS yajl_s ARCHIVE DESTINATION lib${LIB_SUFFIX})
INSTALL(FILES ${PUB_HDRS} DESTINATION include/yajl)
INSTALL(FILES ${incDir}/yajl_version.h DESTINATION include/yajl)
INSTALL(FILES ${pkgconfigDir}/yajl.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig)
diff --git a/test/parsing/CMakeLists.txt b/test/parsing/CMakeLists.txt
index c22a3887..f445920d 100644
--- a/test/parsing/CMakeLists.txt
+++ b/test/parsing/CMakeLists.txt
@@ -20,4 +20,4 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/lib)
ADD_EXECUTABLE(yajl_test ${SRCS})
-TARGET_LINK_LIBRARIES(yajl_test yajl_s)
+TARGET_LINK_LIBRARIES(yajl_test yajl)