Compare commits

..

3 Commits

Author SHA1 Message Date
ronh f643d41561 wip 2023-03-08 22:38:01 -06:00
ronh aea438416d wip 2023-03-08 22:31:27 -06:00
ronh ccaba7d26f wip 2023-03-08 19:23:01 -06:00
6 changed files with 22 additions and 68 deletions
+5 -10
View File
@@ -10,12 +10,13 @@ find_package(CLI11 REQUIRED)
set(BUILD_DIR "${PROJECT_SOURCE_DIR}/build")
set(CLI11_DIR ${BUILD_DIR})
# include_directories(include)
# file(GLOB SOURCES "src/*.cpp")
include_directories(include)
add_library(challenge SHARED
src/File.cpp
)
target_include_directories(challenge PUBLIC include)
add_executable(${PROJECT_NAME}
src/cppchallenge.cpp
@@ -26,16 +27,10 @@ target_link_libraries(${PROJECT_NAME}
challenge
)
set_target_properties(${PROJECT_NAME}
PROPERTIES
PUBLIC_HEADER
include/File.h
)
install(TARGETS ${PROJECT_NAME} challenge
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
INCLUDES DESTINATION include
)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+1 -44
View File
@@ -1,44 +1 @@
A basic C++ exercise which uses `conan` to satisfy dependencies before building a shared library and
an executable that links it. Also produces a `.deb` package which installs the executable, library,
and public headers.
## Prerequisites
* Ubuntu 22.04 (or equivalent)
* Additional required packages:
* `g++`
* `cmake`
* `python3-venv`
## Setup
Create a `python` virtual environment, install `conan`, and create a default profile:
```bash
python3 -m venv conan.venv
source conan.venv/bin/activate
pip install conan
conan profile detect
```
## Building and running
1. To build, run:
```bash
./build.sh
```
2. The build command will generate a `deb` package in the `_packages` directory. To install (to
`/usr/local`) run:
```
sudo dpkg -i _packages/_packages/cppchallenge_1.0.0_*.deb
sudo ldconfig
```
__TODO__: The `sudo ldconfig` step should be added to the `deb` package `postinst` step...
3. To run:
```
$ cppchallenge
Hello World!
File name is: aname
$ cppchallenge --help
Just a simple 'hello'
Usage: cppchallenge [OPTIONS]
Options:
-h,--help Print this help message and exit
```
A basic C++ exercise.
+11
View File
@@ -0,0 +1,11 @@
#include "CLI/CLI.hpp"
#include <iostream>
int main(int argc, char *argv[]){
CLI::App app{"Just a simple 'hello'"};
CLI11_PARSE(app, argc, argv);
std::cout << "Hello World!" << std::endl;
return 0;
}
// vim: set ts=4 expandtab :
+3 -5
View File
@@ -3,11 +3,9 @@
class File {
private:
const std::string name;
std::string name;
public:
File(const std::string);
const std::string getName() const;
File(std::string);
std::string getName();
};
// vim: set ts=4 expandtab :
+2 -4
View File
@@ -1,12 +1,10 @@
#include "File.h"
File::File(const std::string name):
File::File(std::string name):
name(name)
{
}
const std::string File::getName() const {
std::string File::getName() {
return name;
}
// vim: set ts=4 expandtab :
-5
View File
@@ -1,15 +1,10 @@
#include "CLI/CLI.hpp"
#include "File.h"
#include <iostream>
int main(int argc, char *argv[]){
CLI::App app{"Just a simple 'hello'"};
CLI11_PARSE(app, argc, argv);
File afile("aname");
std::cout << "Hello World!" << std::endl;
std::cout << "File name is: " << afile.getName() << std::endl;
return 0;
}