Skip to content

Commit

Permalink
Fix CMAKE code formats
Browse files Browse the repository at this point in the history
Note that rest of lint errors are not solved yet.
  • Loading branch information
alinaliBQ committed Nov 24, 2023
1 parent 43aa536 commit 8979ff4
Show file tree
Hide file tree
Showing 15 changed files with 1,090 additions and 1,013 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,15 @@ add_subdirectory(${PERFORMANCE_HELPER})
add_subdirectory(${RESULTS_PTESTS})
add_subdirectory(${EXECUTION_PTESTS})

if (NOT "$ENV{BOOST_ROOT}" STREQUAL "")
set(BOOST_ROOT "$ENV{BOOST_ROOT}")
if(NOT "$ENV{BOOST_ROOT}" STREQUAL "")
set(BOOST_ROOT "$ENV{BOOST_ROOT}")
endif()

# gtest
include(gtest/googletest.cmake)
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -fPIC")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -fPIC -Wno-error=maybe-uninitialized")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -fPIC -Wno-error=maybe-uninitialized")
endif()
fetch_googletest(
${PROJECT_SOURCE_DIR}/gtest
${PROJECT_BINARY_DIR}/googletest
)

fetch_googletest(${PROJECT_SOURCE_DIR}/gtest ${PROJECT_BINARY_DIR}/googletest)
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright <2022> Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ find_package(Boost 1.71 REQUIRED COMPONENTS thread)
find_package(ODBC REQUIRED)
# Source, headers, and include dirs
set(SOURCE_FILES performance_odbc_results.cpp)
include_directories(${PERFORMANCE_HELPER} SYSTEM ${ODBC_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
include_directories(${PERFORMANCE_HELPER} SYSTEM ${ODBC_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS})

# Generate executable
add_executable(performance_results ${SOURCE_FILES})

# Library dependencies
target_link_libraries(performance_results performance_helper gtest_main ${ODBC_LIBRARIES} ${Boost_LIBRARIES})
target_link_libraries(performance_results
performance_helper
gtest_main
${ODBC_LIBRARIES}
${Boost_LIBRARIES})
target_compile_definitions(performance_results PUBLIC _UNICODE UNICODE)
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ find_package(ODBC REQUIRED)

# Source, headers, and include dirs
set(SOURCE_FILES performance_helper.cpp)
set(HEADER_FILES performance_helper.h)
set(HEADER_FILES performance_helper.h)

# Generate dll (SHARED)
add_library(performance_helper ${SOURCE_FILES} ${HEADER_FILES})
add_library(performance_helper ${SOURCE_FILES} ${HEADER_FILES})
include_directories(${ODBC_INCLUDE_DIRS})

# Library dependencies
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -fPIC")
target_link_libraries(performance_helper gtest_main ${ODBC_LIBRARIES})
target_compile_definitions(performance_helper PUBLIC _UNICODE UNICODE)

target_compile_definitions(performance_helper PUBLIC _UNICODE UNICODE)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# Modifications Copyright Amazon.com, Inc. or its affiliates.
# Modifications Copyright Amazon.com, Inc. or its affiliates.
# SPDX-License-Identifier: MIT.

cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
Expand All @@ -29,16 +29,12 @@ project(googletest-download NONE)

include(ExternalProject)

ExternalProject_Add(
googletest
SOURCE_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-src"
BINARY_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-build"
GIT_REPOSITORY
https://github.com/google/googletest.git
GIT_TAG
release-1.10.0
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
externalproject_add(googletest
SOURCE_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-src"
BINARY_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-build"
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND "")
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,21 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# Modifications Copyright Amazon.com, Inc. or its affiliates.
# Modifications Copyright Amazon.com, Inc. or its affiliates.
# SPDX-License-Identifier: MIT.

macro(fetch_googletest _download_module_path _download_root)
set(GOOGLETEST_DOWNLOAD_ROOT ${_download_root})
configure_file(
${_download_module_path}/googletest-download.cmake
${_download_root}/CMakeLists.txt
@ONLY
)
unset(GOOGLETEST_DOWNLOAD_ROOT)
set(GOOGLETEST_DOWNLOAD_ROOT ${_download_root})
configure_file(${_download_module_path}/googletest-download.cmake
${_download_root}/CMakeLists.txt @ONLY)
unset(GOOGLETEST_DOWNLOAD_ROOT)

execute_process(
COMMAND
"${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY
${_download_root}
)
execute_process(
COMMAND
"${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY
${_download_root}
)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${_download_root})
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY ${_download_root})

# adds the targers: gtest, gtest_main, gmock, gmock_main
add_subdirectory(
${_download_root}/googletest-src EXCLUDE_FROM_ALL
${_download_root}/googletest-build EXCLUDE_FROM_ALL
)
endmacro()
# adds the targers: gtest, gtest_main, gmock, gmock_main
add_subdirectory(${_download_root}/googletest-src EXCLUDE_FROM_ALL
${_download_root}/googletest-build EXCLUDE_FROM_ALL)
endmacro()
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright <2022> Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
Expand All @@ -19,52 +19,64 @@ string(STRIP ${ODBC_DRIVER_VERSION} ODBC_DRIVER_VERSION)
project(Timestream-ODBC VERSION ${ODBC_DRIVER_VERSION})

# Mac
if (UNIX AND APPLE)
set(AWS_CMAKE_DIR ${CMAKE_SOURCE_DIR}/aws-sdk-cpp/install/lib)
if(UNIX AND APPLE)
set(AWS_CMAKE_DIR ${CMAKE_SOURCE_DIR}/aws-sdk-cpp/install/lib)
endif()

# Linux
if (UNIX AND NOT APPLE)
if (${INSTALLER_TYPE} STREQUAL "RPM" AND ${BITNESS} EQUAL 64)
set(AWS_CMAKE_DIR ${CMAKE_SOURCE_DIR}/aws-sdk-cpp/install/lib64)
else()
set(AWS_CMAKE_DIR ${CMAKE_SOURCE_DIR}/aws-sdk-cpp/install/lib)
endif()
# Linux
if(UNIX AND NOT APPLE)
if(${INSTALLER_TYPE} STREQUAL "RPM" AND ${BITNESS} EQUAL 64)
set(AWS_CMAKE_DIR ${CMAKE_SOURCE_DIR}/aws-sdk-cpp/install/lib64)
else()
set(AWS_CMAKE_DIR ${CMAKE_SOURCE_DIR}/aws-sdk-cpp/install/lib)
endif()
endif()

# Windows
if (WIN32)
set(AWS_CMAKE_DIR ${CMAKE_SOURCE_DIR}/../build/aws-sdk/install/lib)

set(CMAKE_BUILD_DIR ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
set(AWS_DLL_DIR ${CMAKE_SOURCE_DIR}/../build/aws-sdk/install/bin)
set(AWS_LIB_DIR ${CMAKE_SOURCE_DIR}/../build/aws-sdk/install/lib)

# copy AWS DLL to ${CMAKE_BUILD_DIR} as they are needed for Windows building and test running
configure_file(${AWS_DLL_DIR}/aws-cpp-sdk-core.dll ${CMAKE_BUILD_DIR}/aws-cpp-sdk-core.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-cpp-sdk-timestream-query.dll ${CMAKE_BUILD_DIR}/aws-cpp-sdk-timestream-query.dll COPYONLY)
# Timestream-write dll is needed for data writer tool
configure_file(${AWS_DLL_DIR}/aws-cpp-sdk-timestream-write.dll ${CMAKE_BUILD_DIR}/aws-cpp-sdk-timestream-write.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-cpp-sdk-sts.dll ${CMAKE_BUILD_DIR}/aws-cpp-sdk-sts.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-auth.dll ${CMAKE_BUILD_DIR}/aws-c-auth.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-cal.dll ${CMAKE_BUILD_DIR}/aws-c-cal.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-common.dll ${CMAKE_BUILD_DIR}/aws-c-common.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-compression.dll ${CMAKE_BUILD_DIR}/aws-c-compression.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-event-stream.dll ${CMAKE_BUILD_DIR}/aws-c-event-stream.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-checksums.dll ${CMAKE_BUILD_DIR}/aws-checksums.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-http.dll ${CMAKE_BUILD_DIR}/aws-c-http.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-io.dll ${CMAKE_BUILD_DIR}/aws-c-io.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-mqtt.dll ${CMAKE_BUILD_DIR}/aws-c-mqtt.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-crt-cpp.dll ${CMAKE_BUILD_DIR}/aws-crt-cpp.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-s3.dll ${CMAKE_BUILD_DIR}/aws-c-s3.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-sdkutils.dll ${CMAKE_BUILD_DIR}/aws-c-sdkutils.dll COPYONLY)
if(WIN32)
set(AWS_CMAKE_DIR ${CMAKE_SOURCE_DIR}/../build/aws-sdk/install/lib)

set(CMAKE_BUILD_DIR ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
set(AWS_DLL_DIR ${CMAKE_SOURCE_DIR}/../build/aws-sdk/install/bin)
set(AWS_LIB_DIR ${CMAKE_SOURCE_DIR}/../build/aws-sdk/install/lib)

# copy AWS DLL to ${CMAKE_BUILD_DIR} as they are needed for Windows building and test running
configure_file(${AWS_DLL_DIR}/aws-cpp-sdk-core.dll
${CMAKE_BUILD_DIR}/aws-cpp-sdk-core.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-cpp-sdk-timestream-query.dll
${CMAKE_BUILD_DIR}/aws-cpp-sdk-timestream-query.dll COPYONLY)
# Timestream-write dll is needed for data writer tool
configure_file(${AWS_DLL_DIR}/aws-cpp-sdk-timestream-write.dll
${CMAKE_BUILD_DIR}/aws-cpp-sdk-timestream-write.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-cpp-sdk-sts.dll
${CMAKE_BUILD_DIR}/aws-cpp-sdk-sts.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-auth.dll ${CMAKE_BUILD_DIR}/aws-c-auth.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-cal.dll ${CMAKE_BUILD_DIR}/aws-c-cal.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-common.dll ${CMAKE_BUILD_DIR}/aws-c-common.dll
COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-compression.dll
${CMAKE_BUILD_DIR}/aws-c-compression.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-event-stream.dll
${CMAKE_BUILD_DIR}/aws-c-event-stream.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-checksums.dll ${CMAKE_BUILD_DIR}/aws-checksums.dll
COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-http.dll ${CMAKE_BUILD_DIR}/aws-c-http.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-io.dll ${CMAKE_BUILD_DIR}/aws-c-io.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-mqtt.dll ${CMAKE_BUILD_DIR}/aws-c-mqtt.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-crt-cpp.dll ${CMAKE_BUILD_DIR}/aws-crt-cpp.dll
COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-s3.dll ${CMAKE_BUILD_DIR}/aws-c-s3.dll COPYONLY)
configure_file(${AWS_DLL_DIR}/aws-c-sdkutils.dll ${CMAKE_BUILD_DIR}/aws-c-sdkutils.dll
COPYONLY)
endif()

# ensure AWS SDK libraries built by us could be found by find_package
set(s2n_DIR "${AWS_CMAKE_DIR}/s2n/cmake")
set(aws-cpp-sdk-timestream-query_DIR "${AWS_CMAKE_DIR}/cmake/aws-cpp-sdk-timestream-query")
set(aws-cpp-sdk-timestream-query_DIR
"${AWS_CMAKE_DIR}/cmake/aws-cpp-sdk-timestream-query")
# Timestream-write directory value is needed for data writer tool
set(aws-cpp-sdk-timestream-write_DIR "${AWS_CMAKE_DIR}/cmake/aws-cpp-sdk-timestream-write")
set(aws-cpp-sdk-timestream-write_DIR
"${AWS_CMAKE_DIR}/cmake/aws-cpp-sdk-timestream-write")
set(aws-cpp-sdk-sts_DIR "${AWS_CMAKE_DIR}/cmake/aws-cpp-sdk-sts")
set(aws-cpp-sdk-core_DIR "${AWS_CMAKE_DIR}/cmake/aws-cpp-sdk-core")
set(aws-crt-cpp_DIR "${AWS_CMAKE_DIR}/aws-crt-cpp/cmake")
Expand All @@ -82,68 +94,70 @@ set(aws-c-sdkutils_DIR "${AWS_CMAKE_DIR}/aws-c-sdkutils/cmake")
set(AWSSDK_DIR "${AWS_CMAKE_DIR}/cmake/AWSSDK")

include("${CMAKE_CURRENT_SOURCE_DIR}/modules/code-coverage.cmake")
if (NOT "$ENV{BOOST_ROOT}" STREQUAL "")
set(BOOST_ROOT "$ENV{BOOST_ROOT}")
if(NOT "$ENV{BOOST_ROOT}" STREQUAL "")
set(BOOST_ROOT "$ENV{BOOST_ROOT}")
endif()
set(CMAKE_CXX_STANDARD 11)

set(CMAKE_PROJECT_VERSION ${PROJECT_VERSION})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIGNITE_IMPL -DIGNITE_FRIEND -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -DIGNITE_IMPL -DIGNITE_FRIEND -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
)

set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(PROJECT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/..")

list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib"
isSystemDir)

if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")

add_definitions(-DUNICODE=1)
if (WIN32)
if(WIN32)

set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
else()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/bin")
endif()

if (MSVC)
add_compile_options(/source-charset:utf-8 /execution-charset:utf-8)
if(MSVC)
add_compile_options(/source-charset:utf-8 /execution-charset:utf-8)

add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
endif()

option (WITH_ODBC OFF)
option (WITH_ODBC_MSI OFF)
option (WITH_THIN_CLIENT OFF)
option (WITH_TESTS OFF)
option (WARNINGS_AS_ERRORS OFF)

if (${WARNINGS_AS_ERRORS})
if (MSVC)
add_compile_options(/WX)
else()
add_compile_options(-Wall -Wextra -Werror -Wno-variadic-macros)
endif()
option(WITH_ODBC OFF)
option(WITH_ODBC_MSI OFF)
option(WITH_THIN_CLIENT OFF)
option(WITH_TESTS OFF)
option(WARNINGS_AS_ERRORS OFF)

if(${WARNINGS_AS_ERRORS})
if(MSVC)
add_compile_options(/WX)
else()
add_compile_options(-Wall -Wextra -Werror -Wno-variadic-macros)
endif()
endif()

if (${WITH_ODBC})
add_subdirectory(odbc)
if(${WITH_ODBC})
add_subdirectory(odbc)
endif()

if (${WITH_TESTS})
enable_testing()
if(${WITH_TESTS})
enable_testing()

if (EXISTS ${CMAKE_SOURCE_DIR}/tests)
add_subdirectory(tests)
endif()
if(EXISTS ${CMAKE_SOURCE_DIR}/tests)
add_subdirectory(tests)
endif()
endif()

Loading

0 comments on commit 8979ff4

Please sign in to comment.