Skip to content

Commit

Permalink
CPP: Cleanup makefiles (awsdocs#6139)
Browse files Browse the repository at this point in the history
  • Loading branch information
meyertst-aws authored and max-webster committed Mar 15, 2024
1 parent 8e7078d commit 0672205
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions cpp/example_code/lambda/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ if(NOT GTest_FOUND)
FetchContent_MakeAvailable(googletest)
endif()

# Use the MSVC variable to determine if this is a Windows build.
set(WINDOWS_BUILD ${MSVC})

# Set the location for Windows to find the installed libraries of the SDK.
if(MSVC)
if(WINDOWS_BUILD)
string(REPLACE ";" "/aws-cpp-sdk-all;" SYSTEM_MODULE_PATH "${CMAKE_SYSTEM_PREFIX_PATH}/aws-cpp-sdk-all")
list(APPEND CMAKE_PREFIX_PATH ${SYSTEM_MODULE_PATH})
endif()
Expand All @@ -48,24 +51,24 @@ add_executable(

# If the compiler is some version of Microsoft Visual C++, or another compiler simulating C++,
# and building as shared libraries, then dynamically link to those shared libraries.
if(MSVC AND BUILD_SHARED_LIBS)

set(CMAKE_BUILD_TYPE Debug) # Explicitly setting CMAKE_BUILD_TYPE is necessary in Windows to copy DLLs.
if(WINDOWS_BUILD)
# set(BIN_SUB_DIR "/Debug") # If you are building from the command line, you may need to uncomment this
# and set the proper subdirectory to the executables' location.

# Copy relevant AWS SDK for C++ libraries into the current binary directory for running and debugging.
AWSSDK_CPY_DYN_LIBS(
CURRENT_TARGET_AWS_DEPENDENCIES
""
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
CURRENT_TARGET_AWS_DEPENDENCIES
""
${CMAKE_CURRENT_BINARY_DIR}${BIN_SUB_DIR}
)

add_custom_command(
TARGET
${CURRENT_TARGET}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/${CMAKE_BUILD_TYPE}/gtest.dll
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
TARGET
${CURRENT_TARGET}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}${BIN_SUB_DIR}/gtest.dll
${CMAKE_CURRENT_BINARY_DIR}${BIN_SUB_DIR}
)
endif()

Expand All @@ -79,19 +82,8 @@ if (NOT DEFINED GTEST_SOURCE_FILES)
)
endif()

# Check whether the target system is Windows, including Win64.
if(WIN32)
list(FILTER GTEST_SOURCE_FILES EXCLUDE REGEX "/gtest_list_buckets_disabling_dns_cache.cpp$") # Not supported in windows, see file for details

# Check whether the compiler is some version of Microsoft Visual C++, or another compiler simulating C++.
if(MSVC)
source_group("Source Files" FILES ${GTEST_SOURCE_FILES})
endif(MSVC)
endif()

enable_testing()


foreach(TEST_FILE ${GTEST_SOURCE_FILES})
string(REPLACE "gtest_" "../" SOURCE_FILE ${TEST_FILE})
if (EXISTS ${SOURCE_FILE})
Expand Down

0 comments on commit 0672205

Please sign in to comment.