133 lines
3.4 KiB
CMake
133 lines
3.4 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
|
|
# -----------------------------
|
|
# Force Clang before project()
|
|
# -----------------------------
|
|
if(NOT DEFINED CMAKE_C_COMPILER)
|
|
set(CMAKE_C_COMPILER clang CACHE STRING "" FORCE)
|
|
endif()
|
|
if(NOT DEFINED CMAKE_CXX_COMPILER)
|
|
set(CMAKE_CXX_COMPILER clang++ CACHE STRING "" FORCE)
|
|
endif()
|
|
|
|
# -----------------------------
|
|
# Project setup
|
|
# -----------------------------
|
|
project(exalock LANGUAGES C CXX)
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
endif()
|
|
|
|
# -----------------------------
|
|
# Vendored dependencies (submodules)
|
|
# -----------------------------
|
|
add_subdirectory(external/spdlog)
|
|
add_subdirectory(external/tomlplusplus)
|
|
add_subdirectory(external/glm)
|
|
|
|
# stb is header-only
|
|
add_library(stb INTERFACE)
|
|
target_include_directories(stb INTERFACE external/stb)
|
|
|
|
# -----------------------------
|
|
# GLAD (official CMake integration)
|
|
# -----------------------------
|
|
add_subdirectory(external/glad/cmake)
|
|
|
|
# For OpenGL ES 2.0:
|
|
glad_add_library(glad_gles2 STATIC API gles2=2.0)
|
|
|
|
# For desktop OpenGL 3.3 core profile, you could use:
|
|
# glad_add_library(glad_gl33 STATIC API gl:core=3.3)
|
|
|
|
# -----------------------------
|
|
# System dependencies (ABI-bound)
|
|
# -----------------------------
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(WAYLAND REQUIRED
|
|
wayland-client
|
|
wayland-egl
|
|
)
|
|
pkg_check_modules(EGL REQUIRED egl)
|
|
pkg_check_modules(GLES REQUIRED glesv2)
|
|
pkg_check_modules(XKB REQUIRED xkbcommon)
|
|
pkg_check_modules(PAM REQUIRED pam)
|
|
pkg_check_modules(FREETYPE REQUIRED freetype2)
|
|
pkg_check_modules(HARFBUZZ REQUIRED harfbuzz)
|
|
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
|
|
|
|
# -----------------------------
|
|
# Executable
|
|
# -----------------------------
|
|
add_executable(${PROJECT_NAME} src/main.cpp)
|
|
|
|
# -----------------------------
|
|
# Auto-discover C++ and C source files
|
|
# -----------------------------
|
|
# C++ files
|
|
file(GLOB_RECURSE ALL_CPP "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
|
list(REMOVE_ITEM ALL_CPP "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp")
|
|
|
|
# C files
|
|
file(GLOB_RECURSE ALL_C "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c")
|
|
# Optionally remove main.c if you have it:
|
|
# list(REMOVE_ITEM ALL_C "${CMAKE_CURRENT_SOURCE_DIR}/src/main.c")
|
|
|
|
# Add them to the target
|
|
target_sources(${PROJECT_NAME} PRIVATE ${ALL_CPP} ${ALL_C})
|
|
|
|
# -----------------------------
|
|
# Include directories
|
|
# -----------------------------
|
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
|
src
|
|
${WAYLAND_INCLUDE_DIRS}
|
|
${EGL_INCLUDE_DIRS}
|
|
${GLES_INCLUDE_DIRS}
|
|
${XKB_INCLUDE_DIRS}
|
|
${PAM_INCLUDE_DIRS}
|
|
${FREETYPE_INCLUDE_DIRS}
|
|
${HARFBUZZ_INCLUDE_DIRS}
|
|
${FONTCONFIG_INCLUDE_DIRS}
|
|
)
|
|
|
|
# -----------------------------
|
|
# Link libraries
|
|
# -----------------------------
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE
|
|
spdlog::spdlog
|
|
tomlplusplus::tomlplusplus
|
|
glm::glm
|
|
stb
|
|
glad_gles2
|
|
${WAYLAND_LIBRARIES}
|
|
${EGL_LIBRARIES}
|
|
${GLES_LIBRARIES}
|
|
${XKB_LIBRARIES}
|
|
${PAM_LIBRARIES}
|
|
${FREETYPE_LIBRARIES}
|
|
${HARFBUZZ_LIBRARIES}
|
|
${FONTCONFIG_LIBRARIES}
|
|
)
|
|
|
|
# -----------------------------
|
|
# Compiler warnings
|
|
# -----------------------------
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
|
|
target_compile_options(${PROJECT_NAME} PRIVATE
|
|
-Wall
|
|
-Wextra
|
|
-Wpedantic
|
|
-Wconversion
|
|
-Wshadow
|
|
-Wnull-dereference
|
|
-Wdouble-promotion
|
|
)
|
|
endif()
|
|
|