Skip to content

Commit

Permalink
[cmake] split commissioner-common to headers and objects
Browse files Browse the repository at this point in the history
  • Loading branch information
wgtdkp committed Apr 18, 2021
1 parent 1b5dd47 commit 39d13c7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
41 changes: 20 additions & 21 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()
1 change: 0 additions & 1 deletion src/java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions src/library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ target_link_libraries(commissioner
mbedtls
mbedx509
mbedcrypto
fmt::fmt
fmt::fmt-header-only
event_core
event_pthreads
$<$<NOT:$<BOOL:${OT_COMM_ANDROID}>>:pthread>
commissioner-common
$<TARGET_OBJECTS:commissioner-common-objects>
)

target_compile_definitions(commissioner
Expand Down Expand Up @@ -121,7 +121,6 @@ if (BUILD_SHARED_LIBS)
$<TARGET_FILE:mbedtls>
$<TARGET_FILE:mbedx509>
$<TARGET_FILE:mbedcrypto>
$<TARGET_FILE:fmt::fmt>
$<TARGET_FILE:event_core_shared>
$<TARGET_FILE:event_pthreads_shared>
DESTINATION lib
Expand Down Expand Up @@ -165,12 +164,10 @@ if (OT_COMM_TEST)
mbedtls
mbedx509
mbedcrypto
fmt::fmt
event_core
event_pthreads
commissioner
$<$<BOOL:${OT_COMM_APP}>:commissioner-app>
commissioner-common
)

target_compile_definitions(commissioner-test
Expand Down

0 comments on commit 39d13c7

Please sign in to comment.