diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..17dd37e --- /dev/null +++ b/CMakeLists.txt @@ -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 + $ + $) + +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() diff --git a/README.md b/README.md index 3980a0c..07f0667 100644 --- a/README.md +++ b/README.md @@ -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) +``` diff --git a/rustex.sln b/rustex.sln deleted file mode 100644 index 975d5ea..0000000 --- a/rustex.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.1000 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rustex", "rustex.vcxproj", "{5B724519-75A6-436B-ABDD-A15E8DBF2C48}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5B724519-75A6-436B-ABDD-A15E8DBF2C48}.Debug|x64.ActiveCfg = Debug|x64 - {5B724519-75A6-436B-ABDD-A15E8DBF2C48}.Debug|x64.Build.0 = Debug|x64 - {5B724519-75A6-436B-ABDD-A15E8DBF2C48}.Debug|x86.ActiveCfg = Debug|Win32 - {5B724519-75A6-436B-ABDD-A15E8DBF2C48}.Debug|x86.Build.0 = Debug|Win32 - {5B724519-75A6-436B-ABDD-A15E8DBF2C48}.Release|x64.ActiveCfg = Release|x64 - {5B724519-75A6-436B-ABDD-A15E8DBF2C48}.Release|x64.Build.0 = Release|x64 - {5B724519-75A6-436B-ABDD-A15E8DBF2C48}.Release|x86.ActiveCfg = Release|Win32 - {5B724519-75A6-436B-ABDD-A15E8DBF2C48}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {A76491A5-825E-4571-808E-ACD52DE057D0} - EndGlobalSection -EndGlobal diff --git a/rustex.vcxproj b/rustex.vcxproj deleted file mode 100644 index 3e8ec7e..0000000 --- a/rustex.vcxproj +++ /dev/null @@ -1,142 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {5B724519-75A6-436B-ABDD-A15E8DBF2C48} - rustex - 10.0 - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - true - stdcpp17 - true - - - Console - - - - - Level3 - Disabled - true - true - stdcpp17 - true - - - Console - - - - - Level3 - MaxSpeed - true - true - true - true - stdcpp17 - true - - - Console - true - true - - - - - Level3 - MaxSpeed - true - true - true - true - stdcpp17 - true - - - Console - true - true - - - - - - - - - - - - \ No newline at end of file diff --git a/rustex.vcxproj.filters b/rustex.vcxproj.filters deleted file mode 100644 index d33ea85..0000000 --- a/rustex.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/test.cpp b/test/test.cpp similarity index 100% rename from test.cpp rename to test/test.cpp