Added extra compiler flags
parent
209f27d114
commit
66093b4858
11
Makefile
11
Makefile
|
@ -1,6 +1,7 @@
|
||||||
SRC_DIR=src
|
SRC_DIR = src
|
||||||
RELEASE_DIR=build/release
|
RELEASE_DIR = build/release
|
||||||
DEBUG_DIR=build/debug
|
DEBUG_DIR = build/debug
|
||||||
|
BINARY = stj
|
||||||
|
|
||||||
all: debug
|
all: debug
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
@ -13,7 +14,7 @@ clean:
|
||||||
|
|
||||||
# Release
|
# Release
|
||||||
run-release: release
|
run-release: release
|
||||||
@ ./$(RELEASE_DIR)
|
@ ./$(RELEASE_DIR)/$(BINARY)
|
||||||
.PHONY: run-release
|
.PHONY: run-release
|
||||||
|
|
||||||
release: $(RELEASE_DIR)/Makefile
|
release: $(RELEASE_DIR)/Makefile
|
||||||
|
@ -30,7 +31,7 @@ clean-release:
|
||||||
|
|
||||||
# Debug
|
# Debug
|
||||||
run-debug: debug
|
run-debug: debug
|
||||||
@ ./$(DEBUG_DIR)
|
@ ./$(DEBUG_DIR)/$(BINARY)
|
||||||
.PHONY: run-debug
|
.PHONY: run-debug
|
||||||
|
|
||||||
debug: $(DEBUG_DIR)/Makefile
|
debug: $(DEBUG_DIR)/Makefile
|
||||||
|
|
|
@ -5,27 +5,39 @@ if (NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set build dirs (keeps things clean)
|
# Create compile_commands.json
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
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
|
|
||||||
|
# =====COMPILER=====
|
||||||
set(CMAKE_C_COMPILER "clang-10")
|
set(CMAKE_C_COMPILER "clang-10")
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
|
||||||
|
|
||||||
project(stj VERSION 0.1)
|
project(stj VERSION 0.1)
|
||||||
|
|
||||||
# List all files needed in final binary
|
|
||||||
|
# =====COMPILE FLAGS=====
|
||||||
|
# General flags
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVERSION=\"${CMAKE_PROJECT_VERSION}\"")
|
||||||
|
|
||||||
|
# Debug flags
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -Wall -O0 -march=native")
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
||||||
|
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
||||||
|
|
||||||
|
# Release flags
|
||||||
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -Werror -march=native")
|
||||||
|
|
||||||
|
|
||||||
|
# =====EXECUTABLE=====
|
||||||
file(GLOB st_SRC "st/*.c" "st/*.h")
|
file(GLOB st_SRC "st/*.c" "st/*.h")
|
||||||
file(GLOB main_SRC "*.c" "*.h")
|
file(GLOB main_SRC "*.c" "*.h")
|
||||||
|
|
||||||
add_executable(stj x.c "${st_SRC}" "${main_SRC}")
|
add_executable(stj x.c "${st_SRC}" "${main_SRC}")
|
||||||
|
|
||||||
# Find required packages
|
|
||||||
|
# =====PACKAGES & LIBRARIES=====
|
||||||
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}")
|
||||||
target_link_libraries(stj PRIVATE "${FREETYPE_LIBRARIES}")
|
target_link_libraries(stj PRIVATE "${FREETYPE_LIBRARIES}")
|
||||||
|
@ -38,12 +50,8 @@ find_package(X11 REQUIRED)
|
||||||
target_include_directories(stj PRIVATE "${X11_INCLUDE_DIR}")
|
target_include_directories(stj PRIVATE "${X11_INCLUDE_DIR}")
|
||||||
target_link_libraries(stj PRIVATE "${X11_LIBRARIES}")
|
target_link_libraries(stj PRIVATE "${X11_LIBRARIES}")
|
||||||
|
|
||||||
# Needed to work; copied from original Makefile
|
|
||||||
target_link_libraries(stj PRIVATE m)
|
target_link_libraries(stj PRIVATE m)
|
||||||
target_link_libraries(stj PRIVATE rt)
|
target_link_libraries(stj PRIVATE rt)
|
||||||
target_link_libraries(stj PRIVATE util)
|
target_link_libraries(stj PRIVATE util)
|
||||||
target_link_libraries(stj PRIVATE Xft)
|
target_link_libraries(stj PRIVATE Xft)
|
||||||
target_link_libraries(stj PRIVATE Xrender)
|
target_link_libraries(stj PRIVATE Xrender)
|
||||||
|
|
||||||
# Add version as flag
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVERSION=\"${CMAKE_PROJECT_VERSION}\"")
|
|
||||||
|
|
Reference in New Issue