# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License 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 permissions and # limitations under the License. # cmake_minimum_required(VERSION 3.20) # Update version number in ODBC_DRIVER_VERSION.txt file. file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/ODBC_DRIVER_VERSION.txt" ODBC_DRIVER_VERSION) string(STRIP ${ODBC_DRIVER_VERSION} ODBC_DRIVER_VERSION) project(DocumentDB-ODBC.C++ VERSION ${ODBC_DRIVER_VERSION}) include("${CMAKE_CURRENT_SOURCE_DIR}/modules/code-coverage.cmake") 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} -DDOCUMENTDB_IMPL -DDOCUMENTDB_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) list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) if("${isSystemDir}" STREQUAL "-1") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") endif("${isSystemDir}" STREQUAL "-1") add_definitions(-DUNICODE=1) if (WIN32) set (CMAKE_LIBRARY_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") endif() 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) 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 (${WITH_TESTS}) find_package(Java 1.8 REQUIRED) find_package(JNI REQUIRED) include(UseJava) endif() if (${WARNINGS_AS_ERRORS}) if (MSVC) add_compile_options(/WX) else() add_compile_options(-Wall -Wextra -Werror -Wno-variadic-macros) endif() endif() if (${WITH_TESTS}) enable_testing() if (EXISTS ${CMAKE_SOURCE_DIR}/tests) add_subdirectory(tests) endif() endif() if (${WITH_ODBC}) add_subdirectory(odbc) if (${WITH_TESTS} AND EXISTS ${CMAKE_SOURCE_DIR}/odbc-test) add_subdirectory(odbc-test) add_dependencies(documentdb-odbc-tests documentdb-odbc) endif() endif()