Skip to content

Commit

Permalink
Added cmake building system for a new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
dorosch committed Sep 23, 2022
1 parent 18df25f commit 39d0ad6
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ imgui*
target/*
resources/*
.vscode

*/build/*


5 changes: 0 additions & 5 deletions new_structure/README.md

This file was deleted.

30 changes: 30 additions & 0 deletions new_structure/radian/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.4)

project(radian VERSION 1.0 LANGUAGES CXX)

file(
GLOB_RECURSE SOURCES CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/include/*.hpp"
"${PROJECT_SOURCE_DIR}/src/*.cpp"
)
file(
GLOB_RECURSE PUBLIC_HEADERS CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/include/*.hpp"
)

configure_file(
"${PROJECT_SOURCE_DIR}/include/radian.hpp.in"
"${PROJECT_SOURCE_DIR}/include/radian.hpp"
)

add_library(radian SHARED ${SOURCES})
target_compile_options(radian PUBLIC -Wall -Wextra -pedantic)
target_include_directories(radian PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
set_target_properties(radian PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED TRUE CXX_EXTENSIONS FALSE)
set_target_properties(radian PROPERTIES PUBLIC_HEADER ${PUBLIC_HEADERS})

install(
TARGETS radian
LIBRARY DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/lib"
PUBLIC_HEADER DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/include"
)
File renamed without changes.
11 changes: 11 additions & 0 deletions new_structure/radian/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Radian

```bash
$ sudo apt install libspdlog-dev
```

```bash
$ cmake -B build .
$ make -C build
$ ./build/app
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef __RADIAN__
#define __RADIAN__

#define VERSION_MAJOR 1
#define VERSION_MINOR 0

#include <memory>
#include <exception>

Expand Down
43 changes: 43 additions & 0 deletions new_structure/radian/include/radian.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef __RADIAN__
#define __RADIAN__

#define VERSION_MAJOR @radian_VERSION_MAJOR@
#define VERSION_MINOR @radian_VERSION_MINOR@

#include <memory>
#include <exception>

#include "tools/logger.hpp"

namespace Radian {
class Exception : public std::exception {
public:
virtual ~Exception() {}
virtual const char* what() const noexcept = 0;
};


class Application {
public:
std::unique_ptr<Tool::Logger> logger;

Application();
virtual ~Application();
virtual void startup() = 0;
virtual void run() = 0;
virtual void shutdown() = 0 ;
};


class Engine {
private:
std::unique_ptr<Application> _app;

public:
void run(std::unique_ptr<Application>);
};

static std::unique_ptr<Radian::Engine> engine = std::make_unique<Radian::Engine>();
}

#endif
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions new_structure/sandbox/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.4)

project(app LANGUAGES CXX)

file(
GLOB_RECURSE SOURCES CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/include/*.hpp"
)

# TODO: Find a better way to add a main project
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../radian/include)

add_executable(${CMAKE_PROJECT_NAME} ${SOURCES})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../radian ${CMAKE_CURRENT_BINARY_DIR}/radian)
target_link_libraries(${CMAKE_PROJECT_NAME} radian)
target_compile_options(${CMAKE_PROJECT_NAME} PUBLIC -Wall -Wextra -pedantic)
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED TRUE CXX_EXTENSIONS FALSE)
File renamed without changes.

0 comments on commit 39d0ad6

Please sign in to comment.