From 4d1f0160c155c8e04150370ad3d3dfdbd39fb7f4 Mon Sep 17 00:00:00 2001 From: Dane Johnson Date: Thu, 14 Jan 2021 14:36:37 -0600 Subject: [PATCH] Port to CMake --- .gitignore | 2 +- CMakeLists.txt | 37 +++++++++++++++++++++++++++++++++++++ Makefile | 14 -------------- core/Makefile | 8 -------- scripting/Makefile | 12 ------------ 5 files changed, 38 insertions(+), 35 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile delete mode 100644 core/Makefile delete mode 100644 scripting/Makefile diff --git a/.gitignore b/.gitignore index 458c8c1..8326e08 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ *.o -couch +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c5a2124 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.13) +project(Couch) +set(CMAKE_MODULE_PATH, ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR/cmake.}) + +## Find OPENGL packages +find_package(OpenGL REQUIRED) +find_package(GLEW REQUIRED) +find_package(glfw3 3.3 REQUIRED) + +## Find SWIG +find_package(SWIG REQUIRED) + +## Find Lua +find_package(Lua REQUIRED) + +file(GLOB_RECURSE sources core/*.cpp core/*.h) +file(GLOB shaders shaders/*) + +add_compile_definitions(LUA_SCRIPTING) +add_executable(couch ${sources}) +include_directories(core) +target_link_libraries(couch glfw) +target_link_libraries(couch OpenGL::GL) +target_link_libraries(couch GLEW) +target_link_libraries(couch lua) + +file(COPY shaders DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + +include(UseSWIG) +set_property(SOURCE scripting/couch.i PROPERTY CPLUSPLUS ON) +swig_add_library(couchlua + TYPE STATIC + LANGUAGE lua + SOURCES scripting/couch.i) +target_link_libraries(couch couchlua) + + diff --git a/Makefile b/Makefile deleted file mode 100644 index 2d0eff5..0000000 --- a/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -include common.mk - -CORE_SRC = $(wildcard core/*.cpp) -CORE_OBJ = $(CORE_SRC:.cpp=.o) - -all: couch -couch: $(CORE_OBJ) scripting/couch_wrap.o - $(CXX) $(LIBS) -o $@ $^ - -$(CORE_OBJ): %.o: %.cpp - $(MAKE) -C core $(notdir $@) - -scripting/couch_wrap.o: scripting/couch.i - $(MAKE) -C scripting $(notdir $@) diff --git a/core/Makefile b/core/Makefile deleted file mode 100644 index ea22c7d..0000000 --- a/core/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -include ../common.mk - -CXXFLAGS := $(CXXFLAGS) -DLUA_SCRIPTING - -SOURCES = $(wildcard *.cpp) -OBJS = $(SOURCES:.cpp=.o) - -all: $(OBJS) diff --git a/scripting/Makefile b/scripting/Makefile deleted file mode 100644 index cdc18e7..0000000 --- a/scripting/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -include ../common.mk - -SWIG := swig -SWIG_OPTS := -lua - -all: couch_wrap.o - -couch_wrap.o: couch_wrap.cpp - $(CXX) $(CXXFLAGS) -I../core -c -o $@ $^ - -couch_wrap.cpp: couch.i - $(SWIG) -c++ $(SWIG_OPTS) -I../core -o $@ $^