Added Makefile cmake wrapper
							parent
							
								
									6a203b3fe5
								
							
						
					
					
						commit
						d83fb29d6b
					
				| 
						 | 
					@ -1,13 +1,7 @@
 | 
				
			||||||
# IDE Directories
 | 
					# IDE Directories
 | 
				
			||||||
.vim/
 | 
					.vim/
 | 
				
			||||||
.vscode/
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# CMake files
 | 
					# CMake build dir
 | 
				
			||||||
CMakeCache.txt
 | 
					build/
 | 
				
			||||||
CMakeFiles/
 | 
					 | 
				
			||||||
cmake_install.cmake
 | 
					 | 
				
			||||||
compile_commands.json
 | 
					 | 
				
			||||||
Makefile
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Final binary
 | 
					# compile_commands.json symlink
 | 
				
			||||||
stj
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,45 @@
 | 
				
			||||||
 | 
					SRC_DIR=src
 | 
				
			||||||
 | 
					RELEASE_DIR=build/release
 | 
				
			||||||
 | 
					DEBUG_DIR=build/debug
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					all: debug
 | 
				
			||||||
 | 
					.PHONY: all
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					clean:
 | 
				
			||||||
 | 
						@ rm -rf build
 | 
				
			||||||
 | 
					.PHONY: clean
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Release
 | 
				
			||||||
 | 
					run-release: release
 | 
				
			||||||
 | 
						@ ./$(RELEASE_DIR)	
 | 
				
			||||||
 | 
					.PHONY: run-release
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					release: $(RELEASE_DIR)/Makefile
 | 
				
			||||||
 | 
						@ make -C $(RELEASE_DIR)
 | 
				
			||||||
 | 
					.PHONY: release
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$(RELEASE_DIR)/Makefile: $(SRC_DIR)/CMakeLists.txt
 | 
				
			||||||
 | 
						@ cmake -H$(SRC_DIR) -B$(RELEASE_DIR) -DCMAKE_BUILD_TYPE=Release
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					clean-release:
 | 
				
			||||||
 | 
						@ rm -rf build/release
 | 
				
			||||||
 | 
					.PHONY: clean-release
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Debug
 | 
				
			||||||
 | 
					run-debug: debug
 | 
				
			||||||
 | 
						@ ./$(DEBUG_DIR)	
 | 
				
			||||||
 | 
					.PHONY: run-debug
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					debug: $(DEBUG_DIR)/Makefile
 | 
				
			||||||
 | 
						@ make -C $(DEBUG_DIR)
 | 
				
			||||||
 | 
					.PHONY: debug
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$(DEBUG_DIR)/Makefile: $(SRC_DIR)/CMakeLists.txt
 | 
				
			||||||
 | 
						@ cmake -H$(SRC_DIR) -B$(DEBUG_DIR) -DCMAKE_BUILD_TYPE=Debug
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					clean-debug:
 | 
				
			||||||
 | 
						@ rm -rf build/debug
 | 
				
			||||||
 | 
					.PHONY: clean-debug
 | 
				
			||||||
							
								
								
									
										35
									
								
								config.mk
								
								
								
								
							
							
						
						
									
										35
									
								
								config.mk
								
								
								
								
							| 
						 | 
					@ -1,35 +0,0 @@
 | 
				
			||||||
# st version
 | 
					 | 
				
			||||||
VERSION = 0.8.4
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Customize below to fit your system
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# paths
 | 
					 | 
				
			||||||
PREFIX = /usr/local
 | 
					 | 
				
			||||||
MANPREFIX = $(PREFIX)/share/man
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
X11INC = /usr/X11R6/include
 | 
					 | 
				
			||||||
X11LIB = /usr/X11R6/lib
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PKG_CONFIG = pkg-config
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# includes and libs
 | 
					 | 
				
			||||||
INCS = -I$(X11INC) \
 | 
					 | 
				
			||||||
       `$(PKG_CONFIG) --cflags fontconfig` \
 | 
					 | 
				
			||||||
       `$(PKG_CONFIG) --cflags freetype2`
 | 
					 | 
				
			||||||
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
 | 
					 | 
				
			||||||
       `$(PKG_CONFIG) --libs fontconfig` \
 | 
					 | 
				
			||||||
       `$(PKG_CONFIG) --libs freetype2`
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# flags
 | 
					 | 
				
			||||||
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
 | 
					 | 
				
			||||||
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
 | 
					 | 
				
			||||||
STLDFLAGS = $(LIBS) $(LDFLAGS)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# OpenBSD:
 | 
					 | 
				
			||||||
#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
 | 
					 | 
				
			||||||
#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
 | 
					 | 
				
			||||||
#       `$(PKG_CONFIG) --libs fontconfig` \
 | 
					 | 
				
			||||||
#       `$(PKG_CONFIG) --libs freetype2`
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# compiler and linker
 | 
					 | 
				
			||||||
# CC = c99
 | 
					 | 
				
			||||||
| 
						 | 
					@ -5,9 +5,17 @@ if (NOT CMAKE_BUILD_TYPE)
 | 
				
			||||||
    set(CMAKE_BUILD_TYPE Release)
 | 
					    set(CMAKE_BUILD_TYPE Release)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Set build dirs (keeps things clean)
 | 
				
			||||||
 | 
					if(CMAKE_BUILD_TYPE STREQUAL "Debug")
 | 
				
			||||||
 | 
					    set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 | 
				
			||||||
 | 
					    # TODO add adress sanitizer flags n stuff
 | 
				
			||||||
 | 
					elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
 | 
				
			||||||
 | 
					    # TODO add optimization flags
 | 
				
			||||||
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Set Compiler
 | 
					# Set Compiler
 | 
				
			||||||
set(CMAKE_C_COMPILER "clang-10")
 | 
					set(CMAKE_C_COMPILER "clang-10")
 | 
				
			||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 | 
					set(CMAKE_C_STANDARD 11)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
project(stj VERSION 0.1)
 | 
					project(stj VERSION 0.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,9 +25,6 @@ file(GLOB main_SRC "*.c" "*.h")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_executable(stj x.c "${st_SRC}" "${main_SRC}")
 | 
					add_executable(stj x.c "${st_SRC}" "${main_SRC}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Set the standard to C11
 | 
					 | 
				
			||||||
set_property(TARGET stj PROPERTY C_STANDARD 11)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Find required packages
 | 
					# Find required packages
 | 
				
			||||||
find_package(Freetype 2 REQUIRED)
 | 
					find_package(Freetype 2 REQUIRED)
 | 
				
			||||||
target_include_directories(stj PRIVATE "${FREETYPE_INCLUDE_DIRS}")
 | 
					target_include_directories(stj PRIVATE "${FREETYPE_INCLUDE_DIRS}")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in New Issue