Skip to content
Open
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
40 changes: 40 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.5)

project(rustex LANGUAGES CXX VERSION 1.0.0 DESCRIPTION "Rust-style mutex type for C++" HOMEPAGE_URL "https://github.com/dragazo/rustex")

include(GNUInstallDirs)

string(REPLACE "/${CMAKE_LIBRARY_ARCHITECTURE}" "" CMAKE_INSTALL_LIBDIR_ARCHIND "${CMAKE_INSTALL_LIBDIR}")

set(RUSTEX_MAIN_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(RUSTEX_MAIN_PROJECT ON)
endif()

option(RUSTEX_BUILD_TESTS "Build tests" ON)

set(CMAKE_CONFIG_DEST "${CMAKE_INSTALL_LIBDIR_ARCHIND}/cmake/${PROJECT_NAME}")

add_library(rustex INTERFACE)
target_include_directories(rustex INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:include>)

if(RUSTEX_MAIN_PROJECT)
include(CMakePackageConfigHelpers)
install(FILES rustex.h DESTINATION include)
install(TARGETS rustex EXPORT rustex-targets)
install(EXPORT rustex-targets
FILE rustex-config.cmake
NAMESPACE rustex::
DESTINATION lib/cmake/rustex)

write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/rustex-config-version.cmake" COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/rustex-config-version.cmake" DESTINATION lib/cmake/rustex)
endif()

if (RUSTEX_BUILD_TESTS)
add_executable(rustex_test test/test.cpp)
target_link_libraries(rustex_test rustex)
set_property(TARGET rustex_test PROPERTY CXX_STANDARD 17)
endif()
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,29 @@ void bar()
}
```

# Using rustex in your project
# Adding rustex to your project

`rustex` is a single-file header-only library for C++17.
All you need to do for compilation is include `rustex.h`.
## Simple

1. Drop [rustex.h](https://raw.githubusercontent.com/dragazo/rustex/master/rustex.h) wherever you like in your source tree

## CMake Classic

```sh
git clone https://github.com/dragazo/rustex.git
mkdir -p rustex/build
cd rustex/build
cmake ..
sudo make install
```

## CMake FetchContent

```cmake
include(FetchContent)
FetchContent_Declare(
rustex
GIT_REPOSITORY https://github.com/dragazo/rustex.git
)
FetchContent_MakeAvailable(rustex)
```
31 changes: 0 additions & 31 deletions rustex.sln

This file was deleted.

142 changes: 0 additions & 142 deletions rustex.vcxproj

This file was deleted.

27 changes: 0 additions & 27 deletions rustex.vcxproj.filters

This file was deleted.

File renamed without changes.