使用 cmake 管理文件

This commit is contained in:
陈浩南 2023-09-26 12:58:34 +08:00
parent 5c921943de
commit 29a378acbc
5 changed files with 61 additions and 12 deletions

2
.gitignore vendored
View File

@ -5,5 +5,5 @@ main
plot
out.yaml
.ccls-cache
.xmake/
.cache
build/

26
CMakeLists.txt Normal file
View File

@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.14)
project(ufo VERSION 0.0.0 LANGUAGES CXX)
enable_testing()
include(GNUInstallDirs)
set_property(GLOBAL PROPERTY CXX_STANDARD 23)
set_property(GLOBAL PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(GLOBAL PROPERTY CXX_EXTENSIONS OFF)
find_package(yaml-cpp REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(fmt REQUIRED)
find_package(concurrencpp REQUIRED)
find_package(HighFive REQUIRED)
find_package(TBB REQUIRED)
find_package(Matplot++ REQUIRED)
find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED)
add_executable(ufo src/ufo.cpp)
target_include_directories(ufo PRIVATE ${PROJECT_SOURCE_DIR}/include ${ZPP_BITS_INCLUDE_DIR})
target_link_libraries(ufo PRIVATE
yaml-cpp Eigen3::Eigen fmt::fmt concurrencpp::concurrencpp HighFive_HighFive TBB::tbb Matplot++::matplot)
get_property(ImportedTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)
message("Imported targets: ${ImportedTargets}")
message("List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}")

View File

@ -807,11 +807,11 @@
"touchix": "touchix"
},
"locked": {
"lastModified": 1695648380,
"narHash": "sha256-8zQct7OdcAtzwsvyPy07wImEtO6v0Rz//grrDtol+Jo=",
"lastModified": 1695703232,
"narHash": "sha256-JqKKV5Zh3r4SAmK1Y0WdZaN5chRuaWRxw5hv9YPCRlQ=",
"owner": "CHN-beta",
"repo": "nixos",
"rev": "e21c7a916a66de6894c3e785a3a0d5f621458272",
"rev": "6318b938c2b3742874982d5d1a338656a50e493b",
"type": "github"
},
"original": {

View File

@ -5,20 +5,17 @@
outputs = inputs:
let
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
localPackages = inputs.nixos.nixosConfigurations.pc.pkgs.localPackages;
localPackages = import "${inputs.nixos}/local/pkgs" { inherit pkgs; inherit (inputs.nixpkgs) lib; };
in
{
devShell.x86_64-linux = pkgs.mkShell.override { stdenv = pkgs.stdenvNoCC; }
devShell.x86_64-linux = pkgs.mkShell.override { stdenv = pkgs.gcc13Stdenv; }
{
packages = with pkgs; [ xmake gcc13 pkg-config cmake ];
inputsFrom = with pkgs;
packages = with pkgs; [ pkg-config cmake ninja ];
buildInputs = with pkgs;
[
yaml-cpp eigen fmt localPackages.concurrencpp highfive
hdf5.dev tbb_2021_8.dev localPackages.matplotplusplus
yaml-cpp eigen fmt localPackages.concurrencpp highfive tbb_2021_8.dev localPackages.matplotplusplus
localPackages.zpp-bits
];
PKG_CONFIG_PATH = "${pkgs.tbb_2021_8.dev}/lib/pkgconfig:${pkgs.yaml-cpp}/share/pkgconfig";
yaml-cpp_DIR = "${pkgs.yaml-cpp}/share/cmake/yaml-cpp";
hardeningDisable = [ "all" ];
NIX_DEBUG = "1";
};

26
test.cpp Normal file
View File

@ -0,0 +1,26 @@
# include <eigen3/Eigen/Dense>
# include <zpp_bits.h>
# include <span>
# include <iostream>
namespace Eigen
{
constexpr auto serialize(auto & archive, Eigen::Matrix3d& matrix)
{
return archive(std::span<double, 9>(matrix.data(), 9));
}
constexpr auto serialize(auto & archive, const Eigen::Matrix3d& matrix)
{
return archive(std::span<const double, 9>(matrix.data(), 9));
}
}
int main()
{
auto [data, in, out] = zpp::bits::data_in_out();
Eigen::Matrix3d PrimativeCell = Eigen::Matrix3d::Identity();
out(PrimativeCell);
Eigen::Matrix3d PrimativeCell2;
in(PrimativeCell2);
std::cout << PrimativeCell2 << std::endl;
}