Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vidur part2 #75

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ ShangEn/build/*
BenHall/lab1/build
RishiB/build/*
Ujaan/Lab-2/Part-1/build/*
/.vscode
Vidur/*/result
4 changes: 3 additions & 1 deletion Vidur/CMakeLists.txt → Vidur/Part-1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ target_include_directories(helloworld_lib PUBLIC include)

add_executable(HelloWorld src/main.cpp)

target_link_libraries(HelloWorld PUBLIC helloworld_lib)
target_link_libraries(HelloWorld PUBLIC helloworld_lib)

install(TARGETS HelloWorld DESTINATION ${CMAKE_INSTALL_BINDIR})
9 changes: 9 additions & 0 deletions Vidur/Part-1/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ stdenv, cmake }:

stdenv.mkDerivation rec {
pname = "helloapp";
version = "1.0.0";
src = ./.; # Path to your source directory

nativeBuildInputs = [ cmake ];
}
27 changes: 27 additions & 0 deletions Vidur/Part-1/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions Vidur/Part-1/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
description = "part 1 flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs = { self, nixpkgs }:
let
hellolib_overlay = final: prev: {
hellolib = final.callPackage ./default.nix { };
};
my_overlays = [ hellolib_overlay ];


pkgs = import nixpkgs {
system = "aarch64-darwin";
overlays = [ self.overlays.default ];
};
in
{
packages.x86_64-linux.default = pkgs.hellolib;
packages.aarch64-darwin.default = pkgs.hellolib;
overlays.default = nixpkgs.lib.composeManyExtensions my_overlays;
};
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions Vidur/Part-2/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ stdenv, cmake, hellolib }:

stdenv.mkDerivation rec {
pname = "helloapp";
version = "1.0.0";
src = ./helloapp; # Path to your source directory

nativeBuildInputs = [ cmake ];
buildInputs = [hellolib];
}
27 changes: 27 additions & 0 deletions Vidur/Part-2/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions Vidur/Part-2/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
description = "part 1 flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs = { self, nixpkgs }:
let
helloapp_overlay = final: prev: rec {
hellolib = final.callPackage ./hellolib.nix { };
helloapp = final.callPackage ./default.nix { inherit hellolib; };
};
my_overlays = [ helloapp_overlay ];


pkgs = import nixpkgs {
system = "aarch64-darwin";
overlays = [ helloapp_overlay ];
};
in
{
packages.aarch64-darwin.default = pkgs.helloapp;
overlays.default = nixpkgs.lib.composeManyExtensions my_overlays;
};
}
10 changes: 10 additions & 0 deletions Vidur/Part-2/helloapp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.24)
project(hello_app LANGUAGES CXX)

find_package(hellolib REQUIRED)

add_executable(hello_app main.cpp)

target_link_libraries(hello_app PUBLIC hellolib::hellolib)

install(TARGETS hello_app DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
6 changes: 6 additions & 0 deletions Vidur/Part-2/helloapp/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "hello_world.h"

int main(void) {
Hello hello;
hello.hello_world();
}
9 changes: 9 additions & 0 deletions Vidur/Part-2/hellolib.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ stdenv, cmake }:

stdenv.mkDerivation rec {
pname = "hellolib";
version = "1.0.0";
src = ./hellolib; # Path to your source directory

nativeBuildInputs = [ cmake ];
}
49 changes: 49 additions & 0 deletions Vidur/Part-2/hellolib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 3.24)
project(hellolib LANGUAGES CXX)

add_library(hellolib STATIC src/hello_world.cpp)

# be sure that you use the generator expressions
# ($<BUILD_INTERFACE: and $<INSTALL_INTERFACE:) for your include directory setups
target_include_directories(hellolib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

include(GNUInstallDirs)
install(TARGETS hellolib
EXPORT hellolibTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION include
)

# NAMESPACE sets the namespace that your target will live within.
# you can have multiple targets under the same namespace
install(EXPORT hellolibTargets
FILE hellolibTargets.cmake
NAMESPACE hellolib::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hellolib
)

# this looks for your .cmake.in file that you created in step 1.
# if you set the directory differently you may need to handle this differently
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/hellolib.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/hellolibConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hellolib
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/hellolibConfig.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hellolib
)


# actually install your header files
install(
DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
FILES_MATCHING PATTERN "*.h*"
)
10 changes: 10 additions & 0 deletions Vidur/Part-2/hellolib/cmake/hellolib.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@PACKAGE_INIT@

# if you have find_package calls, use find_dependency() here with the package
# that you need to find_package() for. this handles transitive dep finding so
# your downstream cmake doesnt have to `find_package()` it instead gets done
# upon package configuration

include("${CMAKE_CURRENT_LIST_DIR}/hellolibTargets.cmake")

check_required_components(hellolib)
9 changes: 9 additions & 0 deletions Vidur/Part-2/hellolib/include/hello_world.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef _HELLO_WORLD_CLASS_H_
#define _HELLO_WORLD_CLASS_H_

class Hello {
public:
void hello_world();
};

#endif
6 changes: 6 additions & 0 deletions Vidur/Part-2/hellolib/src/hello_world.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "hello_world.h"
#include <iostream>

void Hello::hello_world() {
std::cout << "Hello, World!\n";
}
10 changes: 10 additions & 0 deletions Vidur/Part-3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.24)
project(hello_app LANGUAGES CXX)

find_package(hellolib REQUIRED)

add_executable(hello_app main.cpp)

target_link_libraries(hello_app PUBLIC hellolib::hellolib)

install(TARGETS hello_app DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
10 changes: 10 additions & 0 deletions Vidur/Part-3/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ stdenv, cmake, hellolib }:

stdenv.mkDerivation rec {
pname = "helloapp";
version = "1.0.0";
src = ./.; # Path to your source directory

nativeBuildInputs = [ cmake ];
buildInputs = [hellolib];
}
96 changes: 96 additions & 0 deletions Vidur/Part-3/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading