drop-in replacement with a future library implementation (#59).main
@@ -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 ) |
@@ -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) |
@@ -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" | |||