Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
more CMakeLists.txt cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Miaofei <miaofei@amazon.com>
  • Loading branch information
mm318 committed May 23, 2019
1 parent 4b72957 commit 0069375
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 44 deletions.
46 changes: 22 additions & 24 deletions cloudwatch_logs_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ set(CLOUDWATCH_LOGS_COMMON_VERSION 1.0.0)

# Default to C11
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD 11)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 14)
endif()

find_package(aws_common REQUIRED)

if(AWSSDK_FOUND)
set(SERVICE logs)
AWSSDK_DETERMINE_LIBS_TO_LINK(SERVICE OUTPUT)
Expand All @@ -25,8 +24,8 @@ add_library(${PROJECT_NAME} SHARED ${ALL_SRC_FILES})
target_link_libraries(${PROJECT_NAME} ${OUTPUT})
target_include_directories(${PROJECT_NAME} PRIVATE ${AWSSDK_INCLUDE_DIRS} include ${aws_common_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)


#############
Expand Down Expand Up @@ -61,22 +60,21 @@ INSTALL(EXPORT ${PROJECT_NAME}-targets DESTINATION share/${PROJECT_NAME}/cmake)

enable_testing()
find_common_test_packages()
if(GMOCK_LIBRARIES)
add_executable(test_cloudwatch_logs_common
test/main_test.cpp
test/shared_object_test.cpp
test/log_manager_test.cpp
test/log_publisher_test.cpp
test/cloudwatch_facade_test.cpp)
target_include_directories(test_cloudwatch_logs_common
PRIVATE include
PRIVATE ${aws_common_INCLUDE_DIRS}
PUBLIC ${PROJECT_SOURCE_DIR}/test/include
)
target_link_libraries(test_cloudwatch_logs_common
${GTEST_LIBRARIES}
pthread
libgmock
${PROJECT_NAME})
add_test(NAME test_cloudwatch_logs_common COMMAND test_cloudwatch_logs_common --gtest_output=xml:test_results/)
endif()
add_common_gtest(test_cloudwatch_logs_common
test/main_test.cpp
test/shared_object_test.cpp
test/log_manager_test.cpp
test/log_publisher_test.cpp
test/cloudwatch_facade_test.cpp
)
target_include_directories(test_cloudwatch_logs_common PRIVATE
include
${aws_common_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/test/include
)
target_link_libraries(test_cloudwatch_logs_common
${PROJECT_NAME}
${aws_common_LIBRARIES}
${GMOCK_LIBRARY}
pthread
)
5 changes: 3 additions & 2 deletions cloudwatch_logs_common/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

<license>Apache 2.0</license>

<depend>aws_common</depend>
<buildtool_depend>cmake</buildtool_depend>


<depend>aws_common</depend>

<test_depend condition="$ROS_VERSION == 1">gtest</test_depend>
<test_depend condition="$ROS_VERSION == 1">google-mock</test_depend>
<test_depend condition="$ROS_VERSION == 2">ament_cmake_gtest</test_depend>
Expand Down
39 changes: 22 additions & 17 deletions cloudwatch_metrics_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ cmake_minimum_required(VERSION 2.8.3)
project(cloudwatch_metrics_common)
set(CLOUDWATCH_METRICS_COMMON_VERSION 1.0.0)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++14 ")
# Default to C11
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 11)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

find_package(aws_common REQUIRED)
if(AWSSDK_FOUND)
Expand All @@ -13,7 +20,7 @@ endif()

set(ALL_SRC_FILES src/utils/cloudwatch_facade.cpp src/metric_manager.cpp src/metric_manager_factory.cpp src/metric_publisher.cpp)

add_library(${PROJECT_NAME} ${ALL_SRC_FILES})
add_library(${PROJECT_NAME} SHARED ${ALL_SRC_FILES})
target_link_libraries(${PROJECT_NAME} ${OUTPUT})
target_include_directories(${PROJECT_NAME} PRIVATE ${aws_common_INCLUDE_DIRS} ${AWSSDK_INCLUDE_DIR})
target_include_directories(${PROJECT_NAME} PUBLIC
Expand All @@ -27,21 +34,19 @@ target_include_directories(${PROJECT_NAME} PUBLIC

enable_testing()
find_common_test_packages()
if(GMOCK_LIBRARIES)
add_executable(test_cloudwatch_metrics_common
test/main_test.cpp
test/shared_object_test.cpp
test/metric_manager_test.cpp
test/metric_publisher_test.cpp)
target_include_directories(test_cloudwatch_metrics_common PRIVATE ${aws_common_INCLUDE_DIRS} ${AWSSDK_INCLUDE_DIR})
target_link_libraries(test_cloudwatch_metrics_common
${GTEST_LIBRARIES}
pthread
${aws_common_LIBRARIES}
${PROJECT_NAME}
${rclcpp_LIBRARIES})
add_test(NAME test_cloudwatch_metrics_common COMMAND test_cloudwatch_metrics_common --gtest_output=xml:test_results/)
endif()
add_common_gtest(test_cloudwatch_metrics_common
test/main_test.cpp
test/shared_object_test.cpp
test/metric_manager_test.cpp
test/metric_publisher_test.cpp
)
target_link_libraries(test_cloudwatch_metrics_common
${PROJECT_NAME}
${aws_common_LIBRARIES}
${GMOCK_LIBRARY}
pthread
)


#############
## Install ##
Expand Down
3 changes: 2 additions & 1 deletion cloudwatch_metrics_common/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
<license>Apache 2.0</license>

<buildtool_depend>cmake</buildtool_depend>

<depend>aws_common</depend>

<test_depend condition="$ROS_VERSION == 1">gtest</test_depend>
<test_depend condition="$ROS_VERSION == 1">google-mock</test_depend>
<test_depend condition="$ROS_VERSION == 2">ament_cmake_gtest</test_depend>
Expand Down

0 comments on commit 0069375

Please sign in to comment.