Minimal example.
This commit is contained in:
commit
c77773a843
17
CMakeLists.txt
Normal file
17
CMakeLists.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
cmake_minimum_required(VERSION 3.8)
|
||||
project(test_project)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
|
||||
|
||||
add_executable(modules_test)
|
||||
target_sources(modules_test
|
||||
PRIVATE main.cpp
|
||||
PUBLIC FILE_SET CXX_MODULES FILES module.cppm
|
||||
)
|
||||
|
27
flake.lock
Normal file
27
flake.lock
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1725930920,
|
||||
"narHash": "sha256-RVhD9hnlTT2nJzPHlAqrWqCkA7T6CYrP41IoVRkciZM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "44a71ff39c182edaf25a7ace5c9454e7cba2c658",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-24.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
44
flake.nix
Normal file
44
flake.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
|
||||
nixConfig.bash-prompt = "[shell $(pwd)]$ ";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in
|
||||
{
|
||||
|
||||
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
|
||||
|
||||
packages.x86_64-linux.default = pkgs.llvmPackages_17.libcxxStdenv.mkDerivation {
|
||||
name = "modules_test";
|
||||
src = ./.;
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cmake
|
||||
llvmPackages_17.clang-tools
|
||||
ninja
|
||||
];
|
||||
buildInputs = with pkgs; [
|
||||
llvmPackages_17.clang-tools
|
||||
];
|
||||
configurePhase = ''
|
||||
cmake . -GNinja
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
ninja modules_test
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
ls
|
||||
mkdir -p $out/bin
|
||||
cp modules_test $out/bin
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
13
main.cpp
Normal file
13
main.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) 2024 University College Roosevelt
|
||||
//
|
||||
// All rights reserved.
|
||||
|
||||
//
|
||||
// Created by werner on 9/11/24.
|
||||
//
|
||||
|
||||
import Foomod;
|
||||
|
||||
int main() {
|
||||
return add(1,2);
|
||||
}
|
20
module.cppm
Normal file
20
module.cppm
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) 2024 University College Roosevelt
|
||||
//
|
||||
// All rights reserved.
|
||||
|
||||
//
|
||||
// Created by werner on 9/11/24.
|
||||
//
|
||||
|
||||
module;
|
||||
|
||||
#include <iostream>
|
||||
|
||||
export module Foomod;
|
||||
|
||||
export int add(int a, int b) {
|
||||
|
||||
std::cout << "Look at me using iostream!" << std::endl;
|
||||
|
||||
return a + b;
|
||||
}
|
Loading…
Reference in a new issue