drop-in replacement with a future library implementation (#59).main
| option(UNITTEST "Build Unit Tests" ON) | option(UNITTEST "Build Unit Tests" ON) | ||||
| option(COVERAGE "Enable Coverage" OFF) | option(COVERAGE "Enable Coverage" OFF) | ||||
| message(STATUS "Coverage : ${COVERAGE}") | message(STATUS "Coverage : ${COVERAGE}") | ||||
| option(ENABLE_COMPAT_HEADER "Enable compatible header 'scope'" OFF) | |||||
| message(STATUS "Compatible Header : ${ENABLE_COMPAT_HEADER}") | |||||
| if( CMAKE_BUILD_TYPE ) | if( CMAKE_BUILD_TYPE ) | ||||
| set(CMAKE_CXX_EXTENSIONS OFF) | set(CMAKE_CXX_EXTENSIONS OFF) | ||||
| add_library(ScopeGuard INTERFACE) | add_library(ScopeGuard INTERFACE) | ||||
| target_include_directories(ScopeGuard INTERFACE | target_include_directories(ScopeGuard INTERFACE | ||||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | $<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 ) | if( UNITTEST ) |
| install(TARGETS ScopeGuard EXPORT ScopeGuard-config DESTINATION include) | install(TARGETS ScopeGuard EXPORT ScopeGuard-config DESTINATION include) | ||||
| install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" 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) | install(EXPORT ScopeGuard-config DESTINATION share/scopeguard/cmake) |
| /* | |||||
| * 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" | |||||