From 0672205aad93cf8c5c81dfb1521ec9af8b5dd6aa Mon Sep 17 00:00:00 2001 From: Steven Meyer <108885656+meyertst-aws@users.noreply.github.com> Date: Wed, 21 Feb 2024 08:45:03 -0500 Subject: [PATCH] CPP: Cleanup makefiles (#6139) --- cpp/example_code/lambda/tests/CMakeLists.txt | 40 ++++++++------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/cpp/example_code/lambda/tests/CMakeLists.txt b/cpp/example_code/lambda/tests/CMakeLists.txt index 7d94f5a2610..886bdd1eb20 100644 --- a/cpp/example_code/lambda/tests/CMakeLists.txt +++ b/cpp/example_code/lambda/tests/CMakeLists.txt @@ -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() @@ -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() @@ -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})