diff --git a/CMakeLists.txt b/CMakeLists.txt index e509717..a48b071 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) add_library(muopt INTERFACE) add_library(muopt::muopt ALIAS muopt) -target_include_directories(muopt INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_include_directories( + muopt INTERFACE + $ + $ +) target_compile_features(muopt INTERFACE cxx_std_17) # ------------------------------------------------------------------------------ @@ -50,3 +54,40 @@ endif() if(MUOPT_BUILD_FUZZ) add_subdirectory(fuzz) endif() + +# ------------------------------------------------------------------------------ +# Install & Package Export +# ------------------------------------------------------------------------------ + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/muoptConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/muoptConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/muopt +) + +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/muoptConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + +install(DIRECTORY include/muopt DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +install(TARGETS muopt EXPORT muoptTargets) + +install( + EXPORT muoptTargets + FILE muoptTargets.cmake + NAMESPACE muopt:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/muopt +) + +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/muoptConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/muoptConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/muopt +) diff --git a/cmake/muoptConfig.cmake.in b/cmake/muoptConfig.cmake.in new file mode 100644 index 0000000..bdcb850 --- /dev/null +++ b/cmake/muoptConfig.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/muoptTargets.cmake") +check_required_components(muopt) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..fce6221 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1782949081, + "narHash": "sha256-vp6Y/Grm98ESt6ceOkWiHWyZRDV3J1RID4w+6NWK9yA=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "17c9d6cdfc60c64f4ee8d306f9bc0b4ccb51481e", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1785090369, + "narHash": "sha256-m0pDuRJG7EDo9ri+4Ksu83VsI+PlxNC9lNBfydejce4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "624af665418d3c65d544145b4d34ad696439570e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1782614948, + "narHash": "sha256-ePjCwr1sNm9NYUqywL7QfK3JnlS015msC+eBu2zKlp8=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "db3f255737b94216eb71cce308e2912cf6bc2d7c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..97530c6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,67 @@ +{ + description = "muopt"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + + outputs = + inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + inputs.flake-parts.flakeModules.easyOverlay + ]; + + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + perSystem = + { pkgs, ... }: + let + version = "0.1.0"; + + muopt = pkgs.stdenv.mkDerivation { + pname = "muopt"; + inherit version; + src = ./.; + + nativeBuildInputs = [ pkgs.cmake ]; + cmakeFlags = [ + "-DMUOPT_BUILD_EXAMPLES=OFF" + "-DMUOPT_BUILD_TESTS=OFF" + "-DMUOPT_BUILD_FUZZ=OFF" + ]; + + meta = { + description = "A header-only C++17 micro-library for argument parsing"; + homepage = "https://github.com/secona/muopt"; + license = pkgs.lib.licenses.mit; + platforms = pkgs.lib.platforms.all; + }; + }; + in + { + overlayAttrs = { inherit muopt; }; + + packages.default = muopt; + + devShells.default = + pkgs.mkShell.override + { + stdenv = pkgs.clangStdenv; + } + { + packages = with pkgs; [ + clang-tools + cmake + ninja + ]; + }; + }; + }; +}