Skip to content

Commit da57340

Browse files
jasonpcarrollczjaso
andauthored
Add CMakeLists.txt for coreHTTP library (#197)
* Add CMakeLists.txt for coreHTTP library * Fix formatting. * Update core_http target to link to transport interface. * Fix INTERFACE library link --------- Co-authored-by: czjaso <czjaso@amazon.com>
1 parent 3273dd7 commit da57340

2 files changed

Lines changed: 41 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(coreHTTP LANGUAGES C)
4+
5+
# ------------------------------------------------------------------------------
6+
# Includes
7+
# ------------------------------------------------------------------------------
8+
9+
include(${CMAKE_CURRENT_LIST_DIR}/httpFilePaths.cmake)
10+
11+
# ------------------------------------------------------------------------------
12+
# Library targets
13+
# ------------------------------------------------------------------------------
14+
15+
add_library(core_http INTERFACE)
16+
17+
target_sources(core_http INTERFACE ${HTTP_SOURCES})
18+
19+
target_include_directories(core_http
20+
INTERFACE ${HTTP_INCLUDE_NO_INTERFACE_PUBLIC_DIRS})
21+
22+
# Separate transport interface library to prevent conflicts with coreMQTT
23+
if(NOT TARGET coremqtt_corehttp_transport_interface)
24+
add_library(coremqtt_corehttp_transport_interface INTERFACE)
25+
26+
target_include_directories(coremqtt_corehttp_transport_interface
27+
INTERFACE ${HTTP_TRANSPORT_INTERFACE_INCLUDE_DIRS})
28+
endif()
29+
30+
target_link_libraries(core_http INTERFACE coremqtt_corehttp_transport_interface)

httpFilePaths.cmake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ set( HTTP_SOURCES
1212
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/src/llhttp.c
1313
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/src/http.c )
1414

15-
# HTTP library public include directories.
16-
set( HTTP_INCLUDE_PUBLIC_DIRS
15+
# HTTP library public include directories without transport interface.
16+
set( HTTP_INCLUDE_NO_INTERFACE_PUBLIC_DIRS
1717
${CMAKE_CURRENT_LIST_DIR}/source/include
18-
${CMAKE_CURRENT_LIST_DIR}/source/interface
1918
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/include )
19+
20+
# Transport interface include directory.
21+
set( HTTP_TRANSPORT_INTERFACE_INCLUDE_DIRS
22+
${CMAKE_CURRENT_LIST_DIR}/source/interface )
23+
24+
# HTTP library public include directories.
25+
set( HTTP_INCLUDE_PUBLIC_DIRS
26+
${HTTP_INCLUDE_NO_INTERFACE_PUBLIC_DIRS}
27+
${HTTP_TRANSPORT_INTERFACE_INCLUDE_DIRS} )

0 commit comments

Comments
 (0)