Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] refine CMake files #52

Merged
merged 8 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,8 @@ if(NOT "${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wfatal-errors -Wno-missing-braces")

# Defines for mbedtls
set(MBEDTLS_USER_CONFIG ${PROJECT_SOURCE_DIR}/third_party/mbedtls/mbedtls_user_config.h)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMBEDTLS_USER_CONFIG_FILE='<${MBEDTLS_USER_CONFIG}>'")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMBEDTLS_USER_CONFIG_FILE='<${MBEDTLS_USER_CONFIG}>'")
set(CMAKE_CXX_EXTENSIONS OFF)

add_subdirectory(src)

Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ if (CMAKE_BUILD_TYPE AND OT_COMM_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU
add_link_options(--coverage)
endif()

## We don't use target-based functions for enforcing any targets
## under this directory be compiled with the options.
add_compile_options(-Wall -Wextra -Werror -Wfatal-errors -Wno-missing-braces)

if (OT_COMM_APP)
add_subdirectory(app)
endif()
Expand Down
38 changes: 26 additions & 12 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,42 @@
# POSSIBILITY OF SUCH DAMAGE.
#

add_library(commissioner-app
commissioner_app.cpp
json.cpp)
add_library(commissioner-app)

target_link_libraries(commissioner-app PUBLIC
commissioner
commissioner-common)
target_sources(commissioner-app
PRIVATE
commissioner_app.cpp
commissioner_app.hpp
json.cpp
json.hpp
)

target_include_directories(commissioner-app PUBLIC
${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(commissioner-app
PUBLIC
commissioner
commissioner-common
)

target_include_directories(commissioner-app PRIVATE
${PROJECT_SOURCE_DIR}/third_party/json/repo/single_include)
target_include_directories(commissioner-app
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)

target_include_directories(commissioner-app
PRIVATE
${PROJECT_SOURCE_DIR}/third_party/json/repo/single_include
)
wgtdkp marked this conversation as resolved.
Show resolved Hide resolved

install(DIRECTORY etc/commissioner
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
DESTINATION etc)
DESTINATION etc
)

if (BUILD_SHARED_LIBS)
install(TARGETS commissioner-app
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
ARCHIVE DESTINATION lib
)
endif()

add_subdirectory(cli)
33 changes: 22 additions & 11 deletions src/app/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,29 @@
# POSSIBILITY OF SUCH DAMAGE.
#

add_executable(commissioner-cli
console.cpp
interpreter.cpp
main.cpp)
add_executable(commissioner-cli)

target_link_libraries(commissioner-cli PRIVATE
commissioner-app
readline
ncurses)
target_sources(commissioner-cli
PRIVATE
console.cpp
console.hpp
interpreter.cpp
interpreter.hpp
main.cpp
)

target_compile_definitions(commissioner-cli PUBLIC
OT_COMM_VERSION="${PROJECT_VERSION}")
target_link_libraries(commissioner-cli
PRIVATE
commissioner-app
readline
ncurses
)

target_compile_definitions(commissioner-cli
PUBLIC
OT_COMM_VERSION="${PROJECT_VERSION}"
)

install(TARGETS commissioner-cli
RUNTIME DESTINATION bin)
RUNTIME DESTINATION bin
)
23 changes: 16 additions & 7 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,25 @@
# POSSIBILITY OF SUCH DAMAGE.
#

add_library(commissioner-common
address.cpp
utils.cpp)
add_library(commissioner-common)

target_include_directories(commissioner-common PUBLIC
${PROJECT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR})
target_sources(commissioner-common
PRIVATE
address.cpp
address.hpp
utils.cpp
utils.hpp
)

target_include_directories(commissioner-common
PUBLIC
${PROJECT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}
)

if (BUILD_SHARED_LIBS)
install(TARGETS commissioner-common
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
ARCHIVE DESTINATION lib
)
endif()
146 changes: 73 additions & 73 deletions src/library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,89 +26,87 @@
# POSSIBILITY OF SUCH DAMAGE.
#

add_library(commissioner
openthread/bloom_filter.cpp
openthread/bloom_filter.hpp
openthread/crc16.cpp
openthread/crc16.hpp
openthread/pbkdf2_cmac.cpp
openthread/pbkdf2_cmac.hpp
openthread/random.cpp
openthread/random.hpp
openthread/README.md
openthread/sha256.cpp
openthread/sha256.hpp
cbor.cpp
cbor.hpp
coap.cpp
coap.hpp
coap_secure.hpp
commissioner_impl.cpp
commissioner_impl.hpp
commissioner_safe.cpp
commissioner_safe.hpp
commissioning_session.cpp
commissioning_session.hpp
cose.cpp
cose.hpp
cwt.hpp
dtls.cpp
dtls.hpp
endpoint.hpp
error.cpp
event.hpp
logging.cpp
logging.hpp
multicast_dns.cpp
multicast_dns.hpp
network_data.cpp
openthread
socket.cpp
socket.hpp
time.hpp
timer.hpp
tlv.cpp
tlv.hpp
token_manager.cpp
token_manager.hpp
udp_proxy.cpp
udp_proxy.hpp
uri.hpp
${PROJECT_SOURCE_DIR}/include/commissioner/border_agent.hpp
${PROJECT_SOURCE_DIR}/include/commissioner/commissioner.hpp
${PROJECT_SOURCE_DIR}/include/commissioner/network_data.hpp
${PROJECT_SOURCE_DIR}/include/commissioner/error.hpp
${PROJECT_SOURCE_DIR}/include/commissioner/defines.hpp)
add_library(commissioner)

target_link_libraries(commissioner PRIVATE
cn-cbor
cose
mdns
mbedtls
mbedx509
mbedcrypto
fmt::fmt
event_core
event_pthreads
commissioner-common)
target_sources(commissioner
PRIVATE
cbor.cpp
cbor.hpp
coap.cpp
coap.hpp
coap_secure.hpp
commissioner_impl.cpp
commissioner_impl.hpp
commissioner_safe.cpp
commissioner_safe.hpp
commissioning_session.cpp
commissioning_session.hpp
cose.cpp
cose.hpp
cwt.hpp
dtls.cpp
dtls.hpp
endpoint.hpp
error.cpp
event.hpp
logging.cpp
logging.hpp
multicast_dns.cpp
multicast_dns.hpp
network_data.cpp
openthread/bloom_filter.cpp
openthread/bloom_filter.hpp
openthread/crc16.cpp
openthread/crc16.hpp
openthread/pbkdf2_cmac.cpp
openthread/pbkdf2_cmac.hpp
openthread/random.cpp
openthread/random.hpp
openthread/sha256.cpp
openthread/sha256.hpp
socket.cpp
socket.hpp
time.hpp
timer.hpp
tlv.cpp
tlv.hpp
token_manager.cpp
token_manager.hpp
udp_proxy.cpp
udp_proxy.hpp
uri.hpp
)

target_include_directories(commissioner PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_include_directories(commissioner PRIVATE
${PROJECT_SOURCE_DIR}/third_party/mbedtls/repo/include
${PROJECT_SOURCE_DIR}/third_party/libevent/repo/include
${PROJECT_BINARY_DIR}/third_party/libevent/repo/include)
target_link_libraries(commissioner
PRIVATE
cn-cbor
cose
mdns
mbedtls
mbedx509
mbedcrypto
fmt::fmt
event_core
event_pthreads
commissioner-common
)

target_include_directories(commissioner
PUBLIC ${PROJECT_SOURCE_DIR}/include
)
wgtdkp marked this conversation as resolved.
Show resolved Hide resolved

install(TARGETS commissioner
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
ARCHIVE DESTINATION lib
)

## Install third-party shared libraries. We need to install
## those shared libraries to enable commissioner-cli.
##
## We here install the built .so files directly
## because those third-party libraries are included
## as EXCLUDE_FROM_ALL, which means `install()` is
## not disabled for them (intended).
## disabled for them (intended).
if (BUILD_SHARED_LIBS)
install(FILES
$<TARGET_FILE:cn-cbor>
Expand All @@ -120,11 +118,13 @@ if (BUILD_SHARED_LIBS)
$<TARGET_FILE:fmt::fmt>
$<TARGET_FILE:event_core_shared>
$<TARGET_FILE:event_pthreads_shared>
DESTINATION lib)
DESTINATION lib
)

## Update ldconfig links and caches.
install(CODE "execute_process(COMMAND sudo ldconfig)")
endif()

install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/commissioner
DESTINATION include)
DESTINATION include
)
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ if (CMAKE_BUILD_TYPE AND OT_COMM_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU
add_link_options(--coverage)
endif()

## We don't use target-based functions for enforcing any targets
## under this directory be compiled with the options.
add_compile_options(-Wall -Wextra -Werror -Wfatal-errors -Wno-missing-braces)

add_subdirectory(unit)
Loading