| 1 | cmake_minimum_required(VERSION 3.16) |
| 2 | project(fortty LANGUAGES Fortran C) |
| 3 | |
| 4 | # C standard for GLAD |
| 5 | set(CMAKE_C_STANDARD 11) |
| 6 | set(CMAKE_C_STANDARD_REQUIRED ON) |
| 7 | |
| 8 | # Compiler warnings |
| 9 | if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") |
| 10 | add_compile_options(-Wall -Wextra -pedantic) |
| 11 | endif() |
| 12 | |
| 13 | # Find dependencies |
| 14 | find_package(glfw3 REQUIRED) |
| 15 | find_package(OpenGL REQUIRED) |
| 16 | find_package(Freetype REQUIRED) |
| 17 | |
| 18 | # C helper libraries (GLAD + FreeType wrappers) |
| 19 | add_library(helpers STATIC |
| 20 | src/gl/glad.c |
| 21 | c_src/gl_loader.c |
| 22 | c_src/freetype_helpers.c |
| 23 | ) |
| 24 | target_include_directories(helpers PUBLIC ${CMAKE_SOURCE_DIR}/include) |
| 25 | target_include_directories(helpers PRIVATE ${FREETYPE_INCLUDE_DIRS}) |
| 26 | target_link_libraries(helpers PRIVATE glfw ${FREETYPE_LIBRARIES}) |
| 27 | |
| 28 | # Fortran module output directory |
| 29 | set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules) |
| 30 | |
| 31 | # Fortran sources (order matters for module dependencies) |
| 32 | set(FORTRAN_SOURCES |
| 33 | src/core/types.f90 |
| 34 | src/gl/gl_bindings.f90 |
| 35 | src/text/glyph.f90 |
| 36 | src/gl/shader.f90 |
| 37 | src/text/font.f90 |
| 38 | src/text/atlas.f90 |
| 39 | src/text/renderer.f90 |
| 40 | src/window/glfw_bindings.f90 |
| 41 | src/window/window.f90 |
| 42 | src/fortty.f90 |
| 43 | ) |
| 44 | |
| 45 | # Main executable |
| 46 | add_executable(fortty ${FORTRAN_SOURCES}) |
| 47 | target_include_directories(fortty PRIVATE ${CMAKE_BINARY_DIR}/modules) |
| 48 | target_link_libraries(fortty PRIVATE helpers glfw OpenGL::GL ${FREETYPE_LIBRARIES}) |
| 49 | |
| 50 | # For Linux, we need dl for GLAD's dlopen |
| 51 | if(UNIX AND NOT APPLE) |
| 52 | target_link_libraries(fortty PRIVATE dl) |
| 53 | endif() |
| 54 |