Skip to content

Commit ab9ea49

Browse files
authored
Allow static and shared libs to be mixed (#479)
Allow static or shared lib to be used. If both are installed, choose based on BUILD_SHARED_LIBS.
1 parent 647d297 commit ab9ea49

File tree

11 files changed

+156
-25
lines changed

11 files changed

+156
-25
lines changed

devicedefender/cmake/iotdevicedefender-cpp-config.cmake

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,22 @@ include(CMakeFindDependencyMacro)
33
find_dependency(aws-crt-cpp)
44
find_dependency(aws-c-iot)
55

6+
macro(aws_load_targets type)
7+
include(${CMAKE_CURRENT_LIST_DIR}/${type}/@[email protected])
8+
endmacro()
9+
10+
# Allow static or shared lib to be used.
11+
# If both are installed, choose based on BUILD_SHARED_LIBS.
612
if (BUILD_SHARED_LIBS)
7-
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
13+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/shared")
14+
aws_load_targets(shared)
15+
else()
16+
aws_load_targets(static)
17+
endif()
818
else()
9-
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
10-
endif()
19+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/static")
20+
aws_load_targets(static)
21+
else()
22+
aws_load_targets(shared)
23+
endif()
24+
endif()

discovery/cmake/discovery-cpp-config.cmake

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@ include(CMakeFindDependencyMacro)
22

33
find_dependency(aws-crt-cpp)
44

5+
macro(aws_load_targets type)
6+
include(${CMAKE_CURRENT_LIST_DIR}/${type}/@[email protected])
7+
endmacro()
8+
9+
# Allow static or shared lib to be used.
10+
# If both are installed, choose based on BUILD_SHARED_LIBS.
511
if (BUILD_SHARED_LIBS)
6-
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
7-
else ()
8-
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
12+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/shared")
13+
aws_load_targets(shared)
14+
else()
15+
aws_load_targets(static)
16+
endif()
17+
else()
18+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/static")
19+
aws_load_targets(static)
20+
else()
21+
aws_load_targets(shared)
22+
endif()
923
endif()

eventstream_rpc/cmake/eventstreamrpc-cpp-config.cmake

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@ include(CMakeFindDependencyMacro)
22

33
find_dependency(aws-crt-cpp)
44

5+
macro(aws_load_targets type)
6+
include(${CMAKE_CURRENT_LIST_DIR}/${type}/@[email protected])
7+
endmacro()
8+
9+
# Allow static or shared lib to be used.
10+
# If both are installed, choose based on BUILD_SHARED_LIBS.
511
if (BUILD_SHARED_LIBS)
6-
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
12+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/shared")
13+
aws_load_targets(shared)
14+
else()
15+
aws_load_targets(static)
16+
endif()
717
else()
8-
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
18+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/static")
19+
aws_load_targets(static)
20+
else()
21+
aws_load_targets(shared)
22+
endif()
923
endif()

greengrass_ipc/cmake/greengrassipc-cpp-config.cmake

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,22 @@ include(CMakeFindDependencyMacro)
33
find_dependency(aws-crt-cpp)
44
find_dependency(EventstreamRpc-cpp)
55

6+
macro(aws_load_targets type)
7+
include(${CMAKE_CURRENT_LIST_DIR}/${type}/@[email protected])
8+
endmacro()
9+
10+
# Allow static or shared lib to be used.
11+
# If both are installed, choose based on BUILD_SHARED_LIBS.
612
if (BUILD_SHARED_LIBS)
7-
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
13+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/shared")
14+
aws_load_targets(shared)
15+
else()
16+
aws_load_targets(static)
17+
endif()
818
else()
9-
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
19+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/static")
20+
aws_load_targets(static)
21+
else()
22+
aws_load_targets(shared)
23+
endif()
1024
endif()

identity/cmake/iotidentity-cpp-config.cmake

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@ include(CMakeFindDependencyMacro)
22

33
find_dependency(aws-crt-cpp)
44

5+
macro(aws_load_targets type)
6+
include(${CMAKE_CURRENT_LIST_DIR}/${type}/@[email protected])
7+
endmacro()
8+
9+
# Allow static or shared lib to be used.
10+
# If both are installed, choose based on BUILD_SHARED_LIBS.
511
if (BUILD_SHARED_LIBS)
6-
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
12+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/shared")
13+
aws_load_targets(shared)
14+
else()
15+
aws_load_targets(static)
16+
endif()
717
else()
8-
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
18+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/static")
19+
aws_load_targets(static)
20+
else()
21+
aws_load_targets(shared)
22+
endif()
923
endif()

iotdevicecommon/cmake/iotdevicecommon-cpp-config.cmake

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,22 @@ include(CMakeFindDependencyMacro)
33
find_dependency(aws-crt-cpp)
44
find_dependency(aws-c-iot)
55

6+
macro(aws_load_targets type)
7+
include(${CMAKE_CURRENT_LIST_DIR}/${type}/@[email protected])
8+
endmacro()
9+
10+
# Allow static or shared lib to be used.
11+
# If both are installed, choose based on BUILD_SHARED_LIBS.
612
if (BUILD_SHARED_LIBS)
7-
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
13+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/shared")
14+
aws_load_targets(shared)
15+
else()
16+
aws_load_targets(static)
17+
endif()
818
else()
9-
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
10-
endif()
19+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/static")
20+
aws_load_targets(static)
21+
else()
22+
aws_load_targets(shared)
23+
endif()
24+
endif()

jobs/cmake/iotjobs-cpp-config.cmake

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@ include(CMakeFindDependencyMacro)
22

33
find_dependency(aws-crt-cpp)
44

5+
macro(aws_load_targets type)
6+
include(${CMAKE_CURRENT_LIST_DIR}/${type}/@[email protected])
7+
endmacro()
8+
9+
# Allow static or shared lib to be used.
10+
# If both are installed, choose based on BUILD_SHARED_LIBS.
511
if (BUILD_SHARED_LIBS)
6-
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
12+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/shared")
13+
aws_load_targets(shared)
14+
else()
15+
aws_load_targets(static)
16+
endif()
717
else()
8-
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
18+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/static")
19+
aws_load_targets(static)
20+
else()
21+
aws_load_targets(shared)
22+
endif()
923
endif()

secure_tunneling/cmake/iotsecuretunneling-cpp-config.cmake

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,22 @@ include(CMakeFindDependencyMacro)
33
find_dependency(aws-crt-cpp)
44
find_dependency(aws-c-iot)
55

6+
macro(aws_load_targets type)
7+
include(${CMAKE_CURRENT_LIST_DIR}/${type}/@[email protected])
8+
endmacro()
9+
10+
# Allow static or shared lib to be used.
11+
# If both are installed, choose based on BUILD_SHARED_LIBS.
612
if (BUILD_SHARED_LIBS)
7-
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
13+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/shared")
14+
aws_load_targets(shared)
15+
else()
16+
aws_load_targets(static)
17+
endif()
818
else()
9-
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
10-
endif()
19+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/static")
20+
aws_load_targets(static)
21+
else()
22+
aws_load_targets(shared)
23+
endif()
24+
endif()

shadow/cmake/iotshadow-cpp-config.cmake

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@ include(CMakeFindDependencyMacro)
22

33
find_dependency(aws-crt-cpp)
44

5+
macro(aws_load_targets type)
6+
include(${CMAKE_CURRENT_LIST_DIR}/${type}/@[email protected])
7+
endmacro()
8+
9+
# Allow static or shared lib to be used.
10+
# If both are installed, choose based on BUILD_SHARED_LIBS.
511
if (BUILD_SHARED_LIBS)
6-
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
12+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/shared")
13+
aws_load_targets(shared)
14+
else()
15+
aws_load_targets(static)
16+
endif()
717
else()
8-
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
18+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/static")
19+
aws_load_targets(static)
20+
else()
21+
aws_load_targets(shared)
22+
endif()
923
endif()

0 commit comments

Comments
 (0)