better project structure

This commit is contained in:
2018-12-10 20:18:46 -05:00
commit 8de34bc077
12 changed files with 391 additions and 0 deletions

16
framework/CMakeLists.txt Normal file
View File

@@ -0,0 +1,16 @@
project(framework)
add_library(framework
src/hello.cpp)
target_link_libraries(framework
glfw)
target_include_directories(framework
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
src)
export(TARGETS framework glfw FILE FrameworkConfig.cmake)

10
framework/include/hello.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef GL_TEMPLATE_HELLO_H
#define GL_TEMPLATE_HELLO_H
#include <string>
void hello();
int showWindow(const std::string &title);
#endif //GL_TEMPLATE_HELLO_H

24
framework/src/hello.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include "hello.h"
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <string>
void hello() {
printf("Hello, World!\n");
}
int showWindow(const std::string &title) {
if (!glfwInit()) return EXIT_FAILURE;
GLFWwindow *window = glfwCreateWindow(1280, 720, title.c_str(), nullptr, nullptr);
while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
return EXIT_SUCCESS;
}