cmake_minimum_required(VERSION 3.0) # Use Release as default type if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) 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(CMAKE_C_COMPILER "clang-10") set(CMAKE_C_STANDARD 11) project(stj VERSION 0.1) # List all files needed in final binary file(GLOB st_SRC "st/*.c" "st/*.h") file(GLOB main_SRC "*.c" "*.h") add_executable(stj x.c "${st_SRC}" "${main_SRC}") # Find required packages 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}") # Needed to work; copied from original Makefile 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) # Add version as flag set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVERSION=\"${CMAKE_PROJECT_VERSION}\"")