63 lines
1.8 KiB
CMake
63 lines
1.8 KiB
CMake
cmake_minimum_required(VERSION 3.0)
|
|
|
|
# Use Release as default type
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
endif()
|
|
|
|
set(SYSTEM_TYPE x64)
|
|
|
|
|
|
# =====COMMON SETTINGS=====
|
|
set(CMAKE_C_COMPILER "clang-11")
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
project(stj VERSION 0.1)
|
|
|
|
add_definitions(-DVERSION="${CMAKE_PROJECT_VERSION}" -D_XOPEN_SOURCE=600)
|
|
|
|
|
|
# =====BUILD TYPES=====
|
|
# Debug
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -Wall -O0 -fsanitize=address -fno-omit-frame-pointer")
|
|
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address -pedantic")
|
|
|
|
# Arch doesn't use static libraries
|
|
if(NOT EXISTS "/etc/arch-release")
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -static-libasan")
|
|
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -static-libasan")
|
|
endif()
|
|
|
|
# Release
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -Werror -pedantic-errors")
|
|
|
|
|
|
# =====EXECUTABLE=====
|
|
file(GLOB st_SRC "st/*.c" "st/*.h")
|
|
file(GLOB main_SRC "*.c" "*.h")
|
|
|
|
add_executable(stj x.c "${st_SRC}" "${main_SRC}")
|
|
|
|
|
|
# =====PACKAGES & LIBRARIES=====
|
|
find_package(Freetype 2 REQUIRED)
|
|
target_include_directories(stj PRIVATE "${FREETYPE_INCLUDE_DIRS}")
|
|
target_link_libraries(stj PRIVATE "${FREETYPE_LIBRARIES}")
|
|
target_link_libraries(stj PRIVATE Xft)
|
|
target_link_libraries(stj PRIVATE Xrender)
|
|
|
|
find_package(Fontconfig 2 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}")
|
|
|
|
# Normally provided with clang
|
|
target_link_libraries(stj PRIVATE m)
|
|
# I'm not sure if I actually need this, so keeping it here for reference
|
|
# target_link_libraries(stj PRIVATE rt)
|
|
|
|
target_link_libraries(stj PRIVATE util)
|