123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- # MinIO C++ Library for Amazon S3 Compatible Cloud Storage
- # Copyright 2021 MinIO, Inc.
- #
- # Licensed 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.
- project(miniocpp)
- cmake_minimum_required(VERSION 3.10)
- macro(set_globals)
- set(CMAKE_BUILD_TYPE_INIT Release)
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
- set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
- set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG} --coverage")
- set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS_DEBUG} --coverage")
- set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} --coverage")
- set(CMAKE_MODULE_LINKER_FLAGS_COVERAGE "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} --coverage")
- endmacro()
- # specify the C++ standard
- set(CMAKE_CXX_STANDARD 17)
- set(CMAKE_CXX_STANDARD_REQUIRED True)
- set(CMAKE_POSITION_INDEPENDENT_CODE ON)
- # prohibit in-source-builds
- IF (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
- MESSAGE(STATUS "In-source-builds are not allowed")
- MESSAGE(STATUS "Clean your source directory (e.g. delete the CMakeCache.txt file)")
- MESSAGE(FATAL_ERROR "Please create a separate build directory and call CMake again")
- ENDIF (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
- # Look for required libraries
- SET(requiredlibs)
- IF(CMAKE_COMPILER_IS_GNUCC)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
- IF(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0 AND NOT MINGW)
- list(APPEND requiredlibs stdc++fs)
- ENDIF()
- ENDIF()
- find_package(CURL REQUIRED)
- IF(CURL_FOUND)
- INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
- list(APPEND requiredlibs CURL::libcurl)
- ELSE(CURL_FOUND)
- MESSAGE(FATAL_ERROR "Could not find the CURL library and development files.")
- ENDIF(CURL_FOUND)
- if (MSVC)
- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/utf-cpp/include)
-
- set(STRPTIME
- ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/strptime/strptime.h
- ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/strptime/strptime.c
- )
- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/strptime)
- add_library(strptime STATIC ${STRPTIME})
- set_property(TARGET strptime PROPERTY
- MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
- endif()
- set(INIH
- ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/inih-r58/ini.c
- ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/inih-r58/ini.h
- ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/inih-r58/cpp/INIReader.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/inih-r58/cpp/INIReader.h
- )
- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/inih-r58)
- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/inih-r58/cpp)
- add_library(inih STATIC ${INIH})
- if (MSVC)
- set_property(TARGET inih PROPERTY
- MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
- endif()
-
- include (find_unofficial_curlpp.cmake)
- include (find_pugixml.cmake)
- include (find_nlohmann_json.cmake)
- find_package(ZLIB REQUIRED)
- IF(ZLIB_FOUND)
- INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
- list(APPEND requiredlibs ZLIB::ZLIB)
- ENDIF()
- find_package(OpenSSL REQUIRED)
- IF(OPENSSL_FOUND)
- INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
- list(APPEND requiredlibs OpenSSL::SSL OpenSSL::Crypto) # bugfix, because libcrypto is not found automatically
- ELSE(OPENSSL_FOUND)
- MESSAGE(FATAL_ERROR "Could not find the OpenSSL library and development files.")
- ENDIF(OPENSSL_FOUND)
- message(STATUS "Found required libs: ${requiredlibs}")
- INCLUDE (CheckIncludeFiles)
- INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
- SET(MINIOCPP_MAJOR_VERSION "0")
- SET(MINIOCPP_MINOR_VERSION "1")
- SET(MINIOCPP_PATCH_VERSION "0")
- add_subdirectory(include)
- add_subdirectory(src)
- if (MSVC)
- set_property(TARGET miniocpp PROPERTY
- MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
- endif()
- option(BUILD_EXAMPLES "Build examples" ON)
- if (BUILD_EXAMPLES)
- add_subdirectory(examples)
- endif (BUILD_EXAMPLES)
- option(BUILD_TESTS "Build tests" ON)
- if (BUILD_TESTS)
- add_subdirectory(tests)
- endif (BUILD_TESTS)
- option(BUILD_DOC "Build documentation" ON)
- if (BUILD_DOC)
- # check if Doxygen is installed
- find_package(Doxygen)
- if (DOXYGEN_FOUND)
- # set input and output files
- set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in)
- set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
- # request to configure the file
- configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
- message("Doxygen build started")
- # note the option ALL which allows to build the docs together with the application
- add_custom_target(doc_doxygen ALL
- COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- COMMENT "Generating API documentation with Doxygen"
- VERBATIM )
- else (DOXYGEN_FOUND)
- message("Doxygen need to be installed to generate the doxygen documentation")
- endif (DOXYGEN_FOUND)
- endif(BUILD_DOC)
- configure_file(miniocpp.pc.in miniocpp.pc @ONLY)
- install(FILES ${CMAKE_BINARY_DIR}/miniocpp.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
- if (MSVC)
- install(TARGETS strptime DESTINATION lib)
- install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/strptime/strptime.h DESTINATION include/strptime)
- endif()
- install(TARGETS inih DESTINATION lib)
- install(FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/inih-r58/ini.h
- DESTINATION include/inih-r58)
- install(FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/inih-r58/cpp/INIReader.h
- DESTINATION include/inih-r58/cpp)
|