]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/nowide/CMakeLists.txt
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / nowide / CMakeLists.txt
1 # Copyright 2019 - 2020 Alexander Grund
2 # Distributed under the Boost Software License, Version 1.0.
3 # (See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt)
4
5 # Builds the libraries for Boost.Nowide
6 #
7 # Options:
8 # Boost_NOWIDE_INSTALL
9 # Boost_NOWIDE_WERROR
10 # BUILD_TESTING
11 #
12 # Created target: Boost::nowide
13 #
14 # When not using CMake to link against the shared library on windows define -DBOOST_NOWIDE_DYN_LINK
15
16 cmake_minimum_required(VERSION 3.9)
17 # Version number starts at 10 to avoid conflicts with Boost version
18 set(_version 11.0.0)
19 if(BOOST_SUPERPROJECT_SOURCE_DIR)
20 set(_version ${BOOST_SUPERPROJECT_VERSION})
21 endif()
22 project(boost_nowide VERSION ${_version} LANGUAGES CXX)
23
24 if(POLICY CMP0074)
25 cmake_policy(SET CMP0074 NEW)
26 endif()
27
28 list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
29
30 if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
31 # Make sure all binarys (especially exe/dll) are in one directory for tests to work
32 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
33 endif()
34
35 include(BoostAddOptions)
36 include(BoostAddWarnings)
37 include(CheckCXXSourceCompiles)
38 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
39 include(CTest)
40 endif()
41
42 file(READ ${CMAKE_CURRENT_SOURCE_DIR}/config/check_lfs_support.cpp lfsSource)
43 check_cxx_source_compiles("${lfsSource}" BOOST_NOWIDE_HAS_LFS)
44
45 # Using glob here is ok as it is only for headers
46 file(GLOB_RECURSE headers include/*.hpp)
47 add_library(boost_nowide src/cstdio.cpp src/cstdlib.cpp src/filebuf.cpp src/iostream.cpp src/stat.cpp ${headers})
48 add_library(Boost::nowide ALIAS boost_nowide)
49 set_target_properties(boost_nowide PROPERTIES
50 CXX_VISIBILITY_PRESET hidden
51 VISIBILITY_INLINES_HIDDEN ON
52 VERSION ${PROJECT_VERSION}
53 EXPORT_NAME nowide
54 )
55 if(BUILD_SHARED_LIBS)
56 target_compile_definitions(boost_nowide PUBLIC BOOST_NOWIDE_DYN_LINK)
57 endif()
58 if(NOT BOOST_NOWIDE_HAS_LFS)
59 target_compile_definitions(boost_nowide PRIVATE BOOST_NOWIDE_NO_LFS)
60 endif()
61 target_compile_definitions(boost_nowide PUBLIC BOOST_NOWIDE_NO_LIB)
62 target_include_directories(boost_nowide PUBLIC include)
63 boost_add_warnings(boost_nowide pedantic ${Boost_NOWIDE_WERROR})
64 target_compile_features(boost_nowide PUBLIC cxx_std_11)
65
66 if(BOOST_SUPERPROJECT_SOURCE_DIR)
67 target_link_libraries(boost_nowide PUBLIC Boost::config)
68 else()
69 # Default boost libs are static on windows and dynamic on linux
70 if(WIN32 AND NOT DEFINED Boost_USE_STATIC_LIBS)
71 set(Boost_USE_STATIC_LIBS ON)
72 endif()
73 find_package(Boost 1.56 REQUIRED)
74 target_link_libraries(boost_nowide PUBLIC Boost::boost)
75 endif()
76
77 if(BUILD_TESTING)
78 add_subdirectory(test)
79 endif()
80
81 if(Boost_NOWIDE_INSTALL)
82 include(InstallTargets)
83 install_targets(TARGETS boost_nowide NAMESPACE Boost CONFIG_FILE ${PROJECT_SOURCE_DIR}/Config.cmake.in)
84 endif()