2020-11-05 17:02:06 +01:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
|
2020-11-05 18:21:52 +01:00
|
|
|
# Use Release as default type
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif()
|
|
|
|
|
2020-11-06 13:03:16 +01:00
|
|
|
|
2020-11-06 15:45:41 +01:00
|
|
|
# =====COMPILER=====
|
2020-12-01 16:17:46 +01:00
|
|
|
set(CMAKE_C_COMPILER "clang-11")
|
2020-11-06 13:03:16 +01:00
|
|
|
set(CMAKE_C_STANDARD 11)
|
2020-11-05 17:02:06 +01:00
|
|
|
|
2020-11-06 15:45:41 +01:00
|
|
|
|
2020-11-05 17:02:06 +01:00
|
|
|
project(stj VERSION 0.1)
|
|
|
|
|
2020-11-06 15:45:41 +01:00
|
|
|
|
|
|
|
# =====COMPILE FLAGS=====
|
2020-11-07 14:49:29 +01:00
|
|
|
add_definitions(-DVERSION="${CMAKE_PROJECT_VERSION}" -D_XOPEN_SOURCE=600)
|
2020-11-06 15:45:41 +01:00
|
|
|
|
|
|
|
# Debug flags
|
2020-11-07 14:49:29 +01:00
|
|
|
# -g flag gets auto-added by CMake for the debug build
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -O0 -march=native")
|
2020-11-06 15:45:41 +01:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
2020-11-07 14:49:29 +01:00
|
|
|
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address -pedantic")
|
2020-11-06 15:45:41 +01:00
|
|
|
|
|
|
|
# Release flags
|
2020-11-07 14:49:29 +01:00
|
|
|
# -O3 gets added automatically by CMake
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Werror -march=native -pedantic-errors")
|
2020-11-06 15:45:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
# =====EXECUTABLE=====
|
2020-11-05 17:02:06 +01:00
|
|
|
file(GLOB st_SRC "st/*.c" "st/*.h")
|
|
|
|
file(GLOB main_SRC "*.c" "*.h")
|
|
|
|
|
|
|
|
add_executable(stj x.c "${st_SRC}" "${main_SRC}")
|
|
|
|
|
2020-11-06 15:45:41 +01:00
|
|
|
|
|
|
|
# =====PACKAGES & LIBRARIES=====
|
2020-11-05 17:02:06 +01:00
|
|
|
find_package(Freetype 2 REQUIRED)
|
|
|
|
target_include_directories(stj PRIVATE "${FREETYPE_INCLUDE_DIRS}")
|
|
|
|
target_link_libraries(stj PRIVATE "${FREETYPE_LIBRARIES}")
|
|
|
|
|
|
|
|
find_package(Fontconfig REQUIRED)
|
|
|
|
target_include_directories(stj PRIVATE "${Fontconfig_INCLUDE_DIRS}")
|
|
|
|
target_link_libraries(stj PRIVATE "${Fontconfig_LIBRARIES}")
|
|
|
|
|
|
|
|
find_package(X11 REQUIRED)
|
|
|
|
target_include_directories(stj PRIVATE "${X11_INCLUDE_DIR}")
|
|
|
|
target_link_libraries(stj PRIVATE "${X11_LIBRARIES}")
|
|
|
|
|
|
|
|
target_link_libraries(stj PRIVATE m)
|
|
|
|
target_link_libraries(stj PRIVATE rt)
|
|
|
|
target_link_libraries(stj PRIVATE util)
|
|
|
|
target_link_libraries(stj PRIVATE Xft)
|
|
|
|
target_link_libraries(stj PRIVATE Xrender)
|