diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e6547b..6f296db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,11 +10,33 @@ find_package(CLI11 REQUIRED) set(BUILD_DIR "${PROJECT_SOURCE_DIR}/build") set(CLI11_DIR ${BUILD_DIR}) -file(GLOB SOURCES "src/*.cpp") +# include_directories(include) -add_executable(${PROJECT_NAME} ${SOURCES}) -target_link_libraries(${PROJECT_NAME} CLI11::CLI11) -install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) +add_library(challenge SHARED + src/File.cpp + ) +target_include_directories(challenge PUBLIC include) + +add_executable(${PROJECT_NAME} + src/cppchallenge.cpp + ) + +target_link_libraries(${PROJECT_NAME} + CLI11::CLI11 + challenge + ) + +set_target_properties(${PROJECT_NAME} + PROPERTIES + PUBLIC_HEADER + include/File.h +) + +install(TARGETS ${PROJECT_NAME} challenge + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include + ) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(packdeb) diff --git a/cppchallenge.cpp b/cppchallenge.cpp deleted file mode 100644 index 79b7a10..0000000 --- a/cppchallenge.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "CLI/CLI.hpp" -#include - -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 : diff --git a/include/File.h b/include/File.h new file mode 100644 index 0000000..52b3b6b --- /dev/null +++ b/include/File.h @@ -0,0 +1,13 @@ +#include + +class File { + +private: + const std::string name; + +public: + File(const std::string); + const std::string getName() const; +}; + +// vim: set ts=4 expandtab : diff --git a/src/File.cpp b/src/File.cpp new file mode 100644 index 0000000..cedc888 --- /dev/null +++ b/src/File.cpp @@ -0,0 +1,12 @@ +#include "File.h" + +File::File(const std::string name): + name(name) +{ +} + +const std::string File::getName() const { + return name; +} + +// vim: set ts=4 expandtab : diff --git a/src/cppchallenge.cpp b/src/cppchallenge.cpp index 79b7a10..a137a37 100644 --- a/src/cppchallenge.cpp +++ b/src/cppchallenge.cpp @@ -1,10 +1,15 @@ #include "CLI/CLI.hpp" +#include "File.h" #include 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; }