Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.1)
project(subprocess VERSION 0.0.1 LANGUAGES CXX)
cmake_minimum_required(VERSION 3.5)
project(subprocess VERSION 2.2 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to use")
option(EXPORT_COMPILE_COMMANDS "create clang compile database" ON)
Expand All @@ -10,10 +10,51 @@ find_package(Threads REQUIRED)

add_library(subprocess INTERFACE)
target_link_libraries(subprocess INTERFACE Threads::Threads)
target_include_directories(subprocess INTERFACE . )
target_sources(subprocess PUBLIC
FILE_SET HEADERS
FILES
cpp-subprocess/subprocess.hpp
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/
)
add_library(cpp-subprocess::subprocess ALIAS subprocess)

if(SUBPROCESS_INSTALL)
install(FILES subprocess.hpp DESTINATION include/cpp-subprocess/)
install(
TARGETS subprocess COMPONENT subprocess
EXPORT subprocess
FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

include(CMakePackageConfigHelpers)

configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/subprocess-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/subprocess-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/subprocess"
PATH_VARS PROJECT_NAME PROJECT_VERSION
)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/beman.exemplar-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion
)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/subprocess-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/subprocess-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/subprocess"
COMPONENT subprocess
)

install(
EXPORT subprocess
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/beman.exemplar"
NAMESPACE cpp-subprocess::
FILE subprocess-targets.cmake
COMPONENT subprocess
)
endif()

if(SUBPROCESS_TESTS)
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ and they will be fixed as they are reported.
Subprocess library has just a single source `subprocess.hpp` present at the top directory of this repository. All you need to do is add

```cpp
#inlcude "cpp-subprocess/subprocess.hpp"
#include "cpp-subprocess/subprocess.hpp"

using namespace subprocess;
// OR
Expand All @@ -33,6 +33,20 @@ to the files where you want to make use of subprocessing. Make sure to add neces

Checkout http://templated-thoughts.blogspot.in/2016/03/sub-processing-with-modern-c.html as well.

## CMake Projects

```cmake
include(FetchContent)
FetchContent_Declare(
cpp-subprocess
GIT_REPOSITORY https://github.com/arun11299/cpp-subprocess.git
GIT_TAG v2.2
)
FetchContent_MakeAvailable(cpp-subprocess)

target_link_libraries(<your_target> PRIVATE cpp-subprocess::subprocess)
```

## Compiler Support
Linux - g++ 4.8 and above
Mac OS - Clang 3.4 and later
Expand Down
7 changes: 7 additions & 0 deletions cmake/subprocess-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(SUBPROCESS_VERSION @PROJECT_VERSION@)

@PACKAGE_INIT@

include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake)

check_required_components(@PROJECT_NAME@)
File renamed without changes.
2 changes: 1 addition & 1 deletion test/test_cat.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <iostream>
#include <subprocess.hpp>
#include <cpp-subprocess/subprocess.hpp>

namespace sp = subprocess;

Expand Down
2 changes: 1 addition & 1 deletion test/test_double_quotes.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <subprocess.hpp>
#include <cpp-subprocess/subprocess.hpp>

#include <cassert>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion test/test_env.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <iostream>
#include <subprocess.hpp>
#include <cpp-subprocess/subprocess.hpp>

using namespace subprocess;

Expand Down
2 changes: 1 addition & 1 deletion test/test_err_redirection.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <iostream>
#include <subprocess.hpp>
#include <cpp-subprocess/subprocess.hpp>

using namespace subprocess;

Expand Down
2 changes: 1 addition & 1 deletion test/test_exception.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <cassert>
#include <cstring>
#include <subprocess.hpp>
#include <cpp-subprocess/subprocess.hpp>

namespace sp = subprocess;

Expand Down
2 changes: 1 addition & 1 deletion test/test_redirection.cc.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <subprocess.hpp>
#include <cpp-subprocess/subprocess.hpp>

#include <cstdlib>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion test/test_ret_code.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <iostream>
#include <subprocess.hpp>
#include <cpp-subprocess/subprocess.hpp>

namespace sp = subprocess;

Expand Down
2 changes: 1 addition & 1 deletion test/test_subprocess.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <iostream>
#include <subprocess.hpp>
#include <cpp-subprocess/subprocess.hpp>

using namespace subprocess;

Expand Down