mirror of
https://github.com/arun11299/cpp-subprocess.git
synced 2025-08-03 11:56:37 -04:00
Improve CMake setup (#118)
* Support CMake 4 CMake 4 has removed compatibility with CMake < 3.5 Bumping minimum required version to 3.5 enables CMake 4 to build this code. * Move header into subdir * Improve CMake setup This commit configures and installs CMake metadata files. This also provides the namespaced ALIAS target `cpp-subprocess::subprocess`. * Update README with CMake instructions * Update include paths in tests
This commit is contained in:
parent
9974ff69cd
commit
f6232a7f26
@ -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)
|
||||
@ -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)
|
||||
|
16
README.md
16
README.md
@ -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
|
||||
@ -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
|
||||
|
7
cmake/subprocess-config.cmake
Normal file
7
cmake/subprocess-config.cmake
Normal file
@ -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@)
|
0
subprocess.hpp → cpp-subprocess/subprocess.hpp
Executable file → Normal file
0
subprocess.hpp → cpp-subprocess/subprocess.hpp
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
#include <iostream>
|
||||
#include <subprocess.hpp>
|
||||
#include <cpp-subprocess/subprocess.hpp>
|
||||
|
||||
namespace sp = subprocess;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <subprocess.hpp>
|
||||
#include <cpp-subprocess/subprocess.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <iostream>
|
||||
#include <subprocess.hpp>
|
||||
#include <cpp-subprocess/subprocess.hpp>
|
||||
|
||||
using namespace subprocess;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <iostream>
|
||||
#include <subprocess.hpp>
|
||||
#include <cpp-subprocess/subprocess.hpp>
|
||||
|
||||
using namespace subprocess;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <subprocess.hpp>
|
||||
#include <cpp-subprocess/subprocess.hpp>
|
||||
|
||||
namespace sp = subprocess;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <subprocess.hpp>
|
||||
#include <cpp-subprocess/subprocess.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <iostream>
|
||||
#include <subprocess.hpp>
|
||||
#include <cpp-subprocess/subprocess.hpp>
|
||||
|
||||
namespace sp = subprocess;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <iostream>
|
||||
#include <subprocess.hpp>
|
||||
#include <cpp-subprocess/subprocess.hpp>
|
||||
|
||||
using namespace subprocess;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user