]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/nowide/CMakeLists.txt
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / nowide / CMakeLists.txt
CommitLineData
20effc67
TL
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
f67539c2
TL
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
16cmake_minimum_required(VERSION 3.9)
17# Version number starts at 10 to avoid conflicts with Boost version
1e59de90 18set(_version 11.1.4)
f67539c2
TL
19if(BOOST_SUPERPROJECT_SOURCE_DIR)
20 set(_version ${BOOST_SUPERPROJECT_VERSION})
21endif()
22project(boost_nowide VERSION ${_version} LANGUAGES CXX)
23
24if(POLICY CMP0074)
25 cmake_policy(SET CMP0074 NEW)
26endif()
27
28list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
29
30if(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})
33endif()
34
f67539c2 35include(BoostAddWarnings)
20effc67 36include(CheckCXXSourceCompiles)
f67539c2
TL
37if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
38 include(CTest)
1e59de90
TL
39 set(def_INSTALL ON)
40 set(def_WERROR ON)
41elseif(BOOST_SUPERPROJECT_SOURCE_DIR)
42 set(Boost_NOWIDE_INSTALL OFF) # Done by the superproject
43 set(def_WERROR ON)
44else()
45 set(def_INSTALL OFF)
46 set(def_WERROR OFF)
47endif()
48
49if(NOT BOOST_SUPERPROJECT_SOURCE_DIR)
50 option(Boost_NOWIDE_INSTALL "Install library" "${def_INSTALL}")
f67539c2 51endif()
1e59de90
TL
52option(Boost_NOWIDE_WERROR "Treat warnings as errors" "${def_WERROR}")
53
f67539c2 54
20effc67
TL
55file(READ ${CMAKE_CURRENT_SOURCE_DIR}/config/check_lfs_support.cpp lfsSource)
56check_cxx_source_compiles("${lfsSource}" BOOST_NOWIDE_HAS_LFS)
1e59de90
TL
57file(READ ${CMAKE_CURRENT_SOURCE_DIR}/config/check_attribute_init_priority.cpp attributeInitPrioritySource)
58check_cxx_source_compiles("${attributeInitPrioritySource}" BOOST_NOWIDE_HAS_INIT_PRIORITY)
20effc67 59
f67539c2
TL
60# Using glob here is ok as it is only for headers
61file(GLOB_RECURSE headers include/*.hpp)
1e59de90 62add_library(boost_nowide src/console_buffer.cpp src/cstdio.cpp src/cstdlib.cpp src/filebuf.cpp src/iostream.cpp src/stat.cpp ${headers})
f67539c2
TL
63add_library(Boost::nowide ALIAS boost_nowide)
64set_target_properties(boost_nowide PROPERTIES
65 CXX_VISIBILITY_PRESET hidden
66 VISIBILITY_INLINES_HIDDEN ON
67 VERSION ${PROJECT_VERSION}
68 EXPORT_NAME nowide
69)
70if(BUILD_SHARED_LIBS)
71 target_compile_definitions(boost_nowide PUBLIC BOOST_NOWIDE_DYN_LINK)
72endif()
20effc67
TL
73if(NOT BOOST_NOWIDE_HAS_LFS)
74 target_compile_definitions(boost_nowide PRIVATE BOOST_NOWIDE_NO_LFS)
75endif()
1e59de90
TL
76if(BOOST_NOWIDE_HAS_INIT_PRIORITY)
77 target_compile_definitions(boost_nowide PRIVATE BOOST_NOWIDE_HAS_INIT_PRIORITY)
78endif()
f67539c2
TL
79target_compile_definitions(boost_nowide PUBLIC BOOST_NOWIDE_NO_LIB)
80target_include_directories(boost_nowide PUBLIC include)
81boost_add_warnings(boost_nowide pedantic ${Boost_NOWIDE_WERROR})
20effc67 82target_compile_features(boost_nowide PUBLIC cxx_std_11)
f67539c2 83
1e59de90
TL
84if(BOOST_SUPERPROJECT_SOURCE_DIR OR TARGET Boost::config)
85 target_link_libraries(boost_nowide PUBLIC
86 Boost::config
87 )
f67539c2 88else()
1e59de90
TL
89 if(NOT TARGET Boost::boost)
90 # Default boost libs are static on windows and dynamic on linux
91 if(WIN32 AND NOT DEFINED Boost_USE_STATIC_LIBS)
92 set(Boost_USE_STATIC_LIBS ON)
93 endif()
94 find_package(Boost 1.56 REQUIRED)
f67539c2 95 endif()
f67539c2
TL
96 target_link_libraries(boost_nowide PUBLIC Boost::boost)
97endif()
98
99if(BUILD_TESTING)
100 add_subdirectory(test)
101endif()
102
103if(Boost_NOWIDE_INSTALL)
104 include(InstallTargets)
105 install_targets(TARGETS boost_nowide NAMESPACE Boost CONFIG_FILE ${PROJECT_SOURCE_DIR}/Config.cmake.in)
106endif()