-
Notifications
You must be signed in to change notification settings - Fork 1
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
Dhruv - labs 1 and 2 #86
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cmake_minimum_required(VERSION 3.15...3.30) | ||
project(part1 LANGUAGES CXX) | ||
add_executable(test src/main.cpp) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <iostream> | ||
|
||
int main() | ||
{ | ||
std::cout << "Hello, World!\n"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.15...3.30) | ||
project(lab1p2 LANGUAGES CXX) | ||
|
||
add_library(part2lib SHARED src/hello_world.cpp) | ||
target_include_directories(part2lib PUBLIC include) | ||
|
||
add_executable(part2 src/main.cpp) | ||
target_link_libraries(part2 PUBLIC part2lib) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef HelloWorld | ||
#define HelloWorld | ||
#include <iostream> | ||
|
||
class HelloWorldLib | ||
{ | ||
public: | ||
HelloWorldLib() = default; | ||
void hello(); | ||
|
||
}; | ||
|
||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <iostream> | ||
#include <hello_world.hpp> | ||
|
||
void HelloWorldLib::hello() { | ||
std::cout << "Hello, World again\n"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <hello_world.hpp> | ||
|
||
int main() { | ||
HelloWorldLib obj; | ||
obj.hello(); | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use the top-level .gitignore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/result/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cmake_minimum_required(VERSION 3.15...3.30) | ||
project(lab2p1 LANGUAGES CXX) | ||
|
||
add_library(HelloWorldLib STATIC src/hello_world.cpp) | ||
target_include_directories(HelloWorldLib PUBLIC include) | ||
|
||
add_executable(HelloWorld src/main.cpp) | ||
target_link_libraries(HelloWorld PUBLIC HelloWorldLib) | ||
|
||
install(TARGETS HelloWorld DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{stdenv, cmake}: | ||
#instructions on how to build the nix package | ||
stdenv.mkDerivation rec { | ||
pname = "HelloLib"; | ||
version = "0.1.0"; | ||
src = ./.; | ||
nativeBuildInputs = [ cmake ]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
description = "flakep1"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | ||
}; | ||
|
||
outputs = {self, nixpkgs}: | ||
|
||
let | ||
HelloLib_overlay = final: prev: { #Overlays in Nix are functions that accept two arguments (usually called final and prev) and return a set of packages | ||
HelloLib = final.callPackage ./default.nix {}; #this makes "HelloLib" a package or sets it as a package here? | ||
}; | ||
|
||
my_overlays = [ HelloLib_overlay ]; #so this is where I would add multiple overlays if needed | ||
#HelloLib_overlay returns packages? | ||
|
||
pkgs = import nixpkgs { | ||
system = "x86_64-linux"; | ||
overlays = [ self.overlays.default ]; #are the self.overlays what I set earlier? | ||
}; | ||
|
||
in | ||
{ | ||
packages.x86_64-linux.default = pkgs.HelloLib; | ||
overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; | ||
}; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef HelloWorld | ||
#define HelloWorld | ||
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all caps please |
||
#include <iostream> | ||
|
||
class HelloWorldLib { | ||
public: | ||
HelloWorldLib() = default; | ||
void hello(); | ||
}; | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/nix/store/dinw5kxp8f9dcrfyr9igvpp96fd6mizf-HelloLib-0.1.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <iostream> | ||
#include <hello_world.hpp> | ||
|
||
void HelloWorldLib::hello() { | ||
std::cout << "hi"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <iostream> | ||
#include <hello_world.hpp> | ||
|
||
int main() { | ||
HelloWorldLib obj; | ||
obj.hello(); | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls use top-level .gitignore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/result/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ stdenv, cmake, hellolib }: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "hellolib_exe"; | ||
version = "0.1.0"; | ||
src = ./hellolib_exe; | ||
nativeBuildInputs = [ cmake ]; | ||
buildInputs = [ hellolib ]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
description = "lab2p2 flake"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | ||
}; | ||
|
||
outputs = { self, nixpkgs }: | ||
let | ||
pkgs = import nixpkgs { | ||
system = "x86_64-linux"; | ||
overlays = [ self.overlays.default ]; | ||
}; | ||
|
||
hellolib_overlay = final: prev: { | ||
hellolib = final.callPackage ./hellolib.nix { }; | ||
hellolib_exe = final.callPackage ./default.nix { }; | ||
}; | ||
my_overlays = [ hellolib_overlay ]; | ||
|
||
|
||
in | ||
{ | ||
packages.x86_64-linux.default = pkgs.hellolib; | ||
overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ stdenv, cmake, hellolib }: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "hellolib"; | ||
version = "0.1.0"; | ||
src = ./hellolib; | ||
nativeBuildInputs = [ cmake ]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
cmake_minimum_required(VERSION 3.15...3.30) | ||
|
||
project(HelloLib LANGUAGES CXX) | ||
|
||
add_library(HelloLib SHARED src/hellolib.cpp) | ||
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/HelloLibConfig.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 | ||
) | ||
|
||
install( | ||
DIRECTORY include/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
FILES_MATCHING PATTERN "*.hpp" | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@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 | ||
|
||
find_dependency(Boost) | ||
include("${CMAKE_CURRENT_LIST_DIR}/HelloLibTargets.cmake") | ||
|
||
check_required_components(HelloLib) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef HelloWorld | ||
#define HelloWorld | ||
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all caps pls |
||
#include <iostream> | ||
|
||
class HelloWorldLib { | ||
public: | ||
HelloWorldLib() = default; | ||
void hello(); | ||
}; | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <hellolib.hpp> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one is correct lol |
||
#include <iostream> | ||
|
||
void HelloWorldLib::hello() { | ||
std::cout << "Hello, world l2p2" << std::endl; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required(VERSION 3.15...3.30) | ||
project(lab2p2 LANGUAGES CXX) | ||
|
||
find_package(hellolib REQUIRED) | ||
|
||
add_executable(HelloWorld main.cpp) | ||
|
||
target_link_directories(HelloWorld PUBLIC HelloLib::HelloLib) | ||
|
||
install(TARGETS HelloWorld RUNTIME DESTINATION bin) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <hellolib.hpp> | ||
|
||
int main() { | ||
HelloWorldLib test; | ||
test.hello(); | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/nix/store/9c45sablrf4cgqysi7d53r1b2f6h98j7-hellolib-0.1.0 |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. top level |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/result/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required(VERSION 3.15...3.30) | ||
project(lab2p2 LANGUAGES CXX) | ||
|
||
find_package(hellolib REQUIRED) | ||
|
||
add_executable(HelloWorld main.cpp) | ||
|
||
target_link_directories(HelloWorld PUBLIC HelloLib::HelloLib) | ||
|
||
install(TARGETS HelloWorld RUNTIME ${CMAKE_INSTALL_PREFIX}/bin) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ stdenv, cmake, hellolib }: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "hellolib_exe"; | ||
version = "0.1.0"; | ||
src = ./.; | ||
nativeBuildInputs = [ cmake ]; | ||
buildInputs = [ hellolib ]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by convention these are supposed to be all caps