浏览代码

Create and install a compatible header (withouth extension) to enable

drop-in replacement with a future library implementation (#59).
main
offa 7 年前
父节点
当前提交
b397e24c76
共有 3 个文件被更改,包括 45 次插入1 次删除
  1. +16
    -1
      CMakeLists.txt
  2. +5
    -0
      cmake/Install.cmake
  3. +24
    -0
      cmake/scope.in

+ 16
- 1
CMakeLists.txt 查看文件

@@ -7,6 +7,8 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
option(UNITTEST "Build Unit Tests" ON)
option(COVERAGE "Enable Coverage" OFF)
message(STATUS "Coverage : ${COVERAGE}")
option(ENABLE_COMPAT_HEADER "Enable compatible header 'scope'" OFF)
message(STATUS "Compatible Header : ${ENABLE_COMPAT_HEADER}")


if( CMAKE_BUILD_TYPE )
@@ -35,10 +37,23 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)




add_library(ScopeGuard INTERFACE)
target_include_directories(ScopeGuard INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
$<INSTALL_INTERFACE:include>
)

if( ENABLE_COMPAT_HEADER )
configure_file(cmake/scope.in generated/scope COPYONLY)

target_include_directories(ScopeGuard INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>
$<INSTALL_INTERFACE:include>
)
endif()



if( UNITTEST )

+ 5
- 0
cmake/Install.cmake 查看文件

@@ -1,4 +1,9 @@

install(TARGETS ScopeGuard EXPORT ScopeGuard-config DESTINATION include)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" DESTINATION include)

if( ENABLE_COMPAT_HEADER )
install(DIRECTORY "${CMAKE_BINARY_DIR}/generated/" DESTINATION include)
endif()

install(EXPORT ScopeGuard-config DESTINATION share/scopeguard/cmake)

+ 24
- 0
cmake/scope.in 查看文件

@@ -0,0 +1,24 @@
/*
* Scope Guard
* Copyright (C) 2017 offa
*
* This file is part of Scope Guard.
*
* Scope Guard is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Scope Guard is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Scope Guard. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "scope.h"


正在加载...
取消
保存