From 85e008d3db9d8115652c17657960f886cb310ffa Mon Sep 17 00:00:00 2001 From: Jonas Vautherin Date: Wed, 2 May 2018 05:08:32 +0200 Subject: [PATCH 1/2] build json11 as a static library --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 819c36f..ed6a08e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX /usr) endif() -add_library(json11 json11.cpp) +add_library(json11 STATIC json11.cpp) target_include_directories(json11 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_options(json11 PRIVATE -fPIC -fno-rtti -fno-exceptions -Wall) From 59c96259eee4f4f147128e9da418fe2aa5fd2144 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 17 May 2018 10:01:31 -0400 Subject: [PATCH 2/2] cmake: only install if plugin is built statically We only need to install json11 if we're building the plugin statically because in that case libjson11.a does not get included in the static plugin library. --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ed6a08e..2f1ba1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,11 @@ if (JSON11_BUILD_TESTS) target_link_libraries(json11_test json11) endif() -install(TARGETS json11 DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}) -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/json11.hpp" DESTINATION include/${CMAKE_LIBRARY_ARCHITECTURE}) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/json11.pc" DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig) +# We only need to install json11 if we're building the mission plugin +# statically because in that case libjson11.a does not get included in +# dronecore_mission.a. +if (PLUGIN_LIBRARY_TYPE STREQUAL "STATIC") + install(TARGETS json11 DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/json11.hpp" DESTINATION include/${CMAKE_LIBRARY_ARCHITECTURE}) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/json11.pc" DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig) +endif()