From 39d13c7740c3daee53f446aeaf270e369d115014 Mon Sep 17 00:00:00 2001 From: kangping Date: Sun, 18 Apr 2021 15:14:01 +0800 Subject: [PATCH] [cmake] split commissioner-common to headers and objects --- src/app/CMakeLists.txt | 4 ++-- src/common/CMakeLists.txt | 41 +++++++++++++++++++------------------- src/java/CMakeLists.txt | 1 - src/library/CMakeLists.txt | 7 ++----- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 5cc4272ab..0d2080978 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -42,9 +42,9 @@ add_library(commissioner-app target_link_libraries(commissioner-app PUBLIC commissioner - commissioner-common + commissioner-common-headers PRIVATE - fmt::fmt + fmt::fmt-header-only mdns nlohmann_json::nlohmann_json ) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index f6222b4f5..72460c757 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -26,7 +26,19 @@ # POSSIBILITY OF SUCH DAMAGE. # -add_library(commissioner-common +add_library(commissioner-common-headers INTERFACE) + +target_link_libraries(commissioner-common-headers + INTERFACE fmt::fmt-header-only +) + +target_include_directories(commissioner-common-headers + INTERFACE + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_SOURCE_DIR}/src +) + +add_library(commissioner-common-objects OBJECT address.cpp address.hpp error.cpp @@ -37,23 +49,10 @@ add_library(commissioner-common utils.hpp ) -target_link_libraries(commissioner-common - PUBLIC fmt::fmt -) - -target_include_directories(commissioner-common - PRIVATE - ${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/src +target_link_libraries(commissioner-common-objects + PUBLIC commissioner-common-headers ) -if (BUILD_SHARED_LIBS) - install(TARGETS commissioner-common - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - ) -endif() - if (OT_COMM_TEST) add_library(commissioner-common-test OBJECT address.hpp @@ -62,11 +61,11 @@ if (OT_COMM_TEST) utils_test.cpp ) + target_link_libraries(commissioner-common-test + PUBLIC commissioner-common-headers + ) + target_include_directories(commissioner-common-test - PRIVATE - ${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/src - ${PROJECT_SOURCE_DIR}/third_party/Catch2/repo/single_include - ${PROJECT_SOURCE_DIR}/third_party/fmtlib/repo/include + PRIVATE ${PROJECT_SOURCE_DIR}/third_party/Catch2/repo/single_include ) endif() diff --git a/src/java/CMakeLists.txt b/src/java/CMakeLists.txt index 57c9edf39..96341087a 100644 --- a/src/java/CMakeLists.txt +++ b/src/java/CMakeLists.txt @@ -57,7 +57,6 @@ swig_add_library(commissioner-java swig_link_libraries(commissioner-java commissioner - commissioner-common ) ## GCC is too strict on this in optimization mode, see http://www.swig.org/Doc3.0/Java.html#Java_compiling_dynamic diff --git a/src/library/CMakeLists.txt b/src/library/CMakeLists.txt index 9087a154c..33483efff 100644 --- a/src/library/CMakeLists.txt +++ b/src/library/CMakeLists.txt @@ -80,11 +80,11 @@ target_link_libraries(commissioner mbedtls mbedx509 mbedcrypto - fmt::fmt + fmt::fmt-header-only event_core event_pthreads $<$>:pthread> - commissioner-common + $ ) target_compile_definitions(commissioner @@ -121,7 +121,6 @@ if (BUILD_SHARED_LIBS) $ $ $ - $ $ $ DESTINATION lib @@ -165,12 +164,10 @@ if (OT_COMM_TEST) mbedtls mbedx509 mbedcrypto - fmt::fmt event_core event_pthreads commissioner $<$:commissioner-app> - commissioner-common ) target_compile_definitions(commissioner-test