-
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
Lab 2 Part 2 #81
base: main
Are you sure you want to change the base?
Lab 2 Part 2 #81
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,9 @@ | ||
{ stdenv, cmake, helloworld_lib }: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "hello_world"; | ||
version = "0.1.0"; | ||
src = ./helloapp; | ||
nativeBuildInputs = [ cmake ]; | ||
buildInputs = [ helloworld_lib ]; | ||
} |
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 = "Lab 02 Part 2 Flake"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs"; | ||
utils.url = "github:numtide/flake-utils"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, utils }: | ||
let | ||
helloworld_overlay = final: prev: rec { | ||
helloworld_lib = final.callPackage ./hellolib.nix { }; | ||
helloworld = final.callPackage ./default.nix { | ||
inherit helloworld_lib; | ||
}; | ||
}; | ||
|
||
my_overlays = [ helloworld_overlay ]; | ||
|
||
pkgs = import nixpkgs { | ||
system = "x86_64-linux"; | ||
overlays = [ self.overlays.default ]; | ||
}; | ||
|
||
in { | ||
packages.x86_64-linux.default = pkgs.helloworld; | ||
overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.15...3.30) | ||
|
||
project(helloapp VERSION 1.0 | ||
DESCRIPTION "HyTech Software Training Lab 2 Part 2" | ||
LANGUAGES CXX) | ||
|
||
find_package(helloworld_lib REQUIRED) | ||
|
||
# creates a target executable file | ||
# helloworld is the name of the executable file that will be generated | ||
# main.cpp is the relative path to a source file | ||
add_executable(helloworld main.cpp) | ||
target_link_libraries(helloworld PUBLIC helloworld_lib::helloworld_lib) | ||
|
||
install(TARGETS helloworld RUNTIME DESTINATION bin) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "hello.h" | ||
|
||
int main() { | ||
Hello h; | ||
h.hello_world(); | ||
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 dont push up result symlink |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/nix/store/pkcy89nw9nk895xv2rn2n3ynb724jg2p-hello_world-0.1.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ stdenv, cmake }: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "hello_world"; | ||
version = "0.1.0"; | ||
src = ./hellolib; | ||
nativeBuildInputs = [ cmake ]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
cmake_minimum_required(VERSION 3.15...3.30) | ||
|
||
project(Lab2 VERSION 1.0 | ||
DESCRIPTION "HyTech Software Training Lab 2" | ||
LANGUAGES CXX) | ||
|
||
add_library(helloworld_lib SHARED src/hello.cpp) | ||
|
||
target_include_directories(helloworld_lib PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
|
||
include(GNUInstallDirs) | ||
|
||
install(TARGETS helloworld_lib | ||
EXPORT helloworld_libTargets | ||
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 helloworld_libTargets | ||
FILE helloworld_libTargets.cmake | ||
NAMESPACE helloworld_lib:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/helloworld_lib | ||
) | ||
|
||
# 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/helloworld_libConfig.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/helloworld_libConfig.cmake" | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/helloworld_lib | ||
) | ||
|
||
install(FILES | ||
"${CMAKE_CURRENT_BINARY_DIR}/helloworld_libConfig.cmake" | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/helloworld_lib | ||
) | ||
|
||
# actually install your header files | ||
install( | ||
DIRECTORY include/ | ||
DESTINATION ${CMAKE_INSTALL_PREFIX}/include | ||
FILES_MATCHING PATTERN "*.h*" | ||
) |
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}/helloworld_libTargets.cmake") | ||
|
||
check_required_components(helloworld_lib) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef _HELLO_H_ | ||
#define _HELLO_H_ | ||
|
||
class Hello { | ||
public: | ||
void hello_world(); | ||
}; | ||
|
||
#endif |
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 dont push up this file |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/nix/store/pkcy89nw9nk895xv2rn2n3ynb724jg2p-hello_world-0.1.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include<iostream> | ||
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. missing space |
||
#include "hello.h" | ||
|
||
void Hello::hello_world() { | ||
std::cout << "Hello, World!" << std::endl; | ||
} |
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.
no need to include flake utils here if not using it